diff --git a/eslint/babel-eslint-parser/README.md b/eslint/babel-eslint-parser/README.md index d9ebe61f3f64..a70cb1c721db 100644 --- a/eslint/babel-eslint-parser/README.md +++ b/eslint/babel-eslint-parser/README.md @@ -56,7 +56,7 @@ Additional configuration options can be set in your ESLint configuration under t - `sourceType` can be set to `"module"`(default) or `"script"` if your code isn't using ECMAScript modules. - `allowImportExportEverywhere` (default `false`) can be set to `true` to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level. - `ecmaFeatures.globalReturn` (default `false`) allow return statements in the global scope when used with `sourceType: "script"`. -- `babelOptions` passes through Babel's configuration [loading](https://babeljs.io/docs/en/options#config-loading-options) and [merging](https://babeljs.io/docs/en/options#config-merging-options) options (for instance, in case of a monorepo). When not defined, @babel/eslint-parser will use Babel's default configuration file resolution logic. +- `babelOptions` is an object containing Babel configuration [options](https://babeljs.io/docs/en/options) that are passed to Babel's parser at runtime. For cases where users might not want to use a Babel configuration file or are running Babel through another tool (such as Webpack with `babel-loader`). **.eslintrc.js** diff --git a/eslint/babel-eslint-parser/src/configuration.js b/eslint/babel-eslint-parser/src/configuration.js index e6d036372f12..529e2d49e8ed 100644 --- a/eslint/babel-eslint-parser/src/configuration.js +++ b/eslint/babel-eslint-parser/src/configuration.js @@ -15,21 +15,6 @@ export function normalizeBabelParseConfig(options) { const parseOptions = { sourceType: options.sourceType, filename: options.filePath, - cwd: options.babelOptions.cwd, - root: options.babelOptions.root, - rootMode: options.babelOptions.rootMode, - envName: options.babelOptions.envName, - configFile: options.babelOptions.configFile, - babelrc: options.babelOptions.babelrc, - babelrcRoots: options.babelOptions.babelrcRoots, - extends: options.babelOptions.extends, - env: options.babelOptions.env, - overrides: options.babelOptions.overrides, - test: options.babelOptions.test, - include: options.babelOptions.include, - exclude: options.babelOptions.exclude, - ignore: options.babelOptions.ignore, - only: options.babelOptions.only, parserOpts: { allowImportExportEverywhere: options.allowImportExportEverywhere, allowReturnOutsideFunction: true, @@ -41,6 +26,7 @@ export function normalizeBabelParseConfig(options) { caller: { name: "@babel/eslint-parser", }, + ...options.babelOptions, }; if (options.requireConfigFile !== false) {