eslint-plugin-escompat

raw JSON →
3.11.4 verified Sat Apr 25 auth: no javascript

ESLint plugin (v3.11.4) that reports errors for JavaScript/TypeScript syntax which, if left untranspiled, will not work in target browsers, as defined by a Browserslist config. Unlike eslint-plugin-compat (which checks for missing polyfills), this focuses on native syntax incompatibilities. It ships with recommended configs for browser code and separate TypeScript configs per ECMAScript target year. Integrates with both legacy .eslintrc and flat eslint.config.js formats. Actively maintained with multiple releases per year since initial release.

error Error: Failed to load plugin 'escompat' declared in '.eslintrc'
cause Missing eslint-plugin-escompat package or incorrect plugin name in config.
fix
Run 'npm install --save-dev eslint-plugin-escompat' and ensure the plugin is listed as 'escompat' in plugins.
error Configuration for rule 'escompat/no-async-generator' is invalid
cause Rule is not recognized; either the plugin is not loaded, or the rule name is misspelled.
fix
Check that the plugin is correctly loaded and the rule name matches exactly (e.g., 'no-async-generator', not 'no-async-generator-something').
error Definition for rule 'escompat/no-*' was not found
cause The rule does not exist in the plugin version installed.
fix
Update to latest version: 'npm update eslint-plugin-escompat' and verify available rules in documentation.
error TypeError: Cannot read properties of undefined (reading 'includes')
cause Possibly related to a missing or malformed browserslist config causing rule parsing to fail.
fix
Ensure browserlist is defined properly in package.json or .browserslistrc (e.g., 'last 1 version').
breaking v3.11.2 fixed a breaking change where Browserslist API broke `this` context in custom browserslist configs.
fix Update to v3.11.2 or later.
deprecated .eslintrc (non-flat) config style is deprecated in ESLint 9; only flat config is recommended going forward.
fix Migrate to flat config (eslint.config.js) using eslint-plugin-escompat's flat configs.
gotcha Rules are only effective if you have a browserslist configured in package.json or .browserslistrc. Without one, all rules are disabled.
fix Add a browserslist to your project (e.g., 'last 1 version') or define it in a config file.
gotcha The 'recommended' config only enables rules that cover syntax not yet widely supported; it may not catch all potential incompatibilities. Always pair with eslint-plugin-compat for polyfill checks.
fix Use both eslint-plugin-escompat and eslint-plugin-compat for full coverage.
npm install eslint-plugin-escompat
yarn add eslint-plugin-escompat
pnpm add eslint-plugin-escompat

Flat config example enabling two escompat rules with browser globals.

// eslint.config.js
import globals from 'globals';
import escompat from 'eslint-plugin-escompat';

export default [
    {
        plugins: { escompat },
        languageOptions: { globals: globals.browser },
        rules: {
            'escompat/no-async-generator': 'error',
            'escompat/no-numeric-separators': 'error',
        }
    }
];