[eslint] Allow "latest" as ecmaVersion (#13638)
This commit is contained in:
parent
313ecb579d
commit
c1f5ca6676
@ -11,7 +11,7 @@ exports.normalizeESLintConfig = function (options) {
|
||||
|
||||
return {
|
||||
babelOptions: { cwd: process.cwd(), ...babelOptions },
|
||||
ecmaVersion,
|
||||
ecmaVersion: ecmaVersion === "latest" ? 1e8 : ecmaVersion,
|
||||
sourceType,
|
||||
allowImportExportEverywhere,
|
||||
requireConfigFile,
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user