eslint-plugin-compat is an ESLint plugin designed to lint the browser compatibility of JavaScript APIs used in your codebase. It leverages `caniuse` data and `browserslist` configurations to identify code that targets APIs unsupported by your specified browsers. The current stable version is 7.0.1, released as of March 2026, with a relatively frequent release cadence, often seeing multiple minor or patch releases per month, alongside periodic major updates for ESLint compatibility. Key differentiators include its tight integration with the `browserslist` ecosystem, allowing developers to define target environments consistently across various tools, and its explicit support for marking polyfilled APIs, preventing false positives. It's an essential tool for maintaining robust frontend code that functions reliably across diverse browser landscapes.
npm install eslint-plugin-compatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up `eslint-plugin-compat` using ESLint's flat configuration system (`eslint.config.mjs`). It imports the recommended flat configuration and shows how to configure target browsers and polyfills directly within the config, although a `browserslist` file or `package.json` entry is often preferred for browser targets.
Upgrade ESLint to version `^9.0.0 || ^10.0.0` in your project's `package.json`. If using ESLint 8 or older, you must either upgrade ESLint or remain on `eslint-plugin-compat` v6.x.
For new projects or when migrating, adopt the `eslint.config.mjs` flat configuration setup. If sticking with legacy `.eslintrc.*` files, use `plugin:compat/recommended` and adjust import paths accordingly.
To lint these conditionals, set `settings.ignoreConditionalChecks` to `true` in your ESLint configuration. This will force `eslint-plugin-compat` to report on API usage even within `if` statements.
To enable ES API linting, set `settings.lintAllEsApis` to `true` in your ESLint configuration. Monitor upstream releases for stability and potential breaking changes related to this feature.
Always define your target browsers explicitly using a `browserslist` key in `package.json` or a `.browserslistrc` file. Ensure it reflects your project's actual browser support requirements.
Run `npm install eslint-plugin-compat` or `yarn add eslint-plugin-compat` to install the package.
Ensure you are using `import compat from 'eslint-plugin-compat';` for ESLint flat config (`eslint.config.mjs`) and that your ESLint version supports flat config (ESLint 9+).
Either update your `browserslist` configuration to exclude browsers that don't support `Promise.allSettled`, or add `'Promise.allSettled'` to the `settings.polyfills` array in your ESLint config.
Ensure your `eslint.config.mjs` file is correctly formatted and discoverable. Check your ESLint extension settings in your IDE to ensure it's pointing to the correct config file type (flat vs. legacy).