Skip to content

Commit

Permalink
[eslint] Allow "latest" as ecmaVersion (#13638)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 30, 2021
1 parent 313ecb5 commit c1f5ca6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/src/configuration.cjs
Expand Up @@ -11,7 +11,7 @@ exports.normalizeESLintConfig = function (options) {

return {
babelOptions: { cwd: process.cwd(), ...babelOptions },
ecmaVersion,
ecmaVersion: ecmaVersion === "latest" ? 1e8 : ecmaVersion,
sourceType,
allowImportExportEverywhere,
requireConfigFile,
Expand Down
19 changes: 19 additions & 0 deletions eslint/babel-eslint-tests/test/integration/eslint/config.js
Expand Up @@ -21,4 +21,23 @@ describe("ESLint config", () => {
});
expect(messages.length).toEqual(0);
});

it('should allow ecmaVersion to be "latest"', () => {
const linter = new eslint.Linter();
linter.defineParser("@babel/eslint-parser", parser);
// ImportDeclarations result in a parser error if ecmaVersion < 2015 and sourceType != "module".
const messages = linter.verify('import { hello } from "greetings"', {
parser: "@babel/eslint-parser",
parserOptions: {
ecmaVersion: "latest",
babelOptions: {
configFile: path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../../../babel-eslint-shared-fixtures/config/babel.config.js",
),
},
},
});
expect(messages.length).toEqual(0);
});
});

0 comments on commit c1f5ca6

Please sign in to comment.