@babel/eslint-parser
raw JSON → 7.13.10 verified Sat Apr 25 auth: no javascript
An ESLint parser that leverages Babel's parser to lint all valid Babel code, including experimental and non-standard syntax (e.g., Flow, TypeScript). The current stable version is 7.29.2 (maintenance branch) with an 8.x release candidate targeting ESLint v9+. It requires @babel/core ≥7.11.0 and ESLint ≥7.5.0 (v7) or ESLint ≥9 (v8). Unlike alternatives like typescript-eslint, this parser supports the full range of Babel transforms and is maintained by the Babel core team. Release cadence is monthly for minor/patch versions.
Common errors
error Error: Could not find module '@babel/core' ↓
cause Missing @babel/core peer dependency.
fix
npm install @babel/core --save-dev
error Parsing error: Unknown parser option "requireConfigFile" ↓
cause Using an old version of ESLint (<7.5.0) that does not support this parser option.
fix
Upgrade ESLint to >=7.5.0 or remove requireConfigFile from parserOptions.
error TypeError: this.getAncestors is not a function ↓
cause Incompatible ESLint version; @babel/eslint-parser v7 requires ESLint >=7.5.0, v8 requires ESLint >=9.
fix
Match ESLint version to the parser version (e.g., ESLint 7 for @babel/eslint-parser v7).
error Error: No Babel config file detected for ... ↓
cause requireConfigFile is true (default) but no Babel configuration is found.
fix
Create a Babel config file or set requireConfigFile: false.
Warnings
breaking ESLint v7 and v8 support dropped in @babel/eslint-parser v8.0.0. ↓
fix Upgrade ESLint to v9 or stay on @babel/eslint-parser v7.x.
breaking The experimental-worker module has been made default in v8.0.0-rc.1. ↓
fix Remove any explicit references to 'experimental-worker' and use the default parser.
deprecated babel-eslint (no @) is deprecated. Use @babel/eslint-parser instead. ↓
fix Replace 'babel-eslint' with '@babel/eslint-parser' in devDependencies and ESLint config.
gotcha parserOptions.ecmaFeatures might still be needed for ESLint rules to recognize features like globalReturn. ↓
fix Add ecmaFeatures: { globalReturn: true } if using CommonJS modules.
gotcha Requires a valid Babel configuration file (babel.config.js, .babelrc, etc.) if requireConfigFile is true (default). ↓
fix Create a Babel config or set requireConfigFile: false (not recommended for transformed code).
Install
npm install babel-eslint-parser yarn add babel-eslint-parser pnpm add babel-eslint-parser Imports
- parser (ESLint config) wrong
parser: "babel-eslint"correctparser: "@babel/eslint-parser" - eslintConfig (module.exports) wrong
module.exports = { parser: "@babel/core" }correctmodule.exports = { parser: "@babel/eslint-parser" } - requireConfigFile option wrong
parserOptions: { requireConfigFile: true }correctparserOptions: { requireConfigFile: false }
Quickstart
// .eslintrc.js
module.exports = {
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
rules: {
"no-unused-vars": "warn",
},
};
// Lint a file
// npx eslint src/**/*.js