Skip to content

Commit

Permalink
Use 'latest' as ecmaVersion (#1465)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Oct 11, 2021
1 parent 5f4c440 commit 9feb181
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion configs/base.js
Expand Up @@ -4,7 +4,7 @@ module.exports = {
es6: true,
},
parserOptions: {
ecmaVersion: 2021,
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -57,9 +57,9 @@
"devDependencies": {
"@babel/code-frame": "^7.14.5",
"@babel/core": "^7.15.5",
"@babel/eslint-parser": "^7.15.4",
"@babel/eslint-parser": "^7.15.7",
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
"@typescript-eslint/parser": "^4.31.0",
"@typescript-eslint/parser": "^4.32.0",
"ava": "^3.15.0",
"chalk": "^4.1.2",
"enquirer": "2.3.6",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -28,7 +28,7 @@ Configure it in `package.json`.
"es6": true
},
"parserOptions": {
"ecmaVersion": 2021,
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
Expand Down
2 changes: 0 additions & 2 deletions test/consistent-function-scoping.mjs
Expand Up @@ -16,8 +16,6 @@ const createError = (functionNameWithKind, loc) => ({
test({
testerOptions: {
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
ecmaFeatures: {
jsx: true,
},
Expand Down
4 changes: 0 additions & 4 deletions test/integration/config.js
Expand Up @@ -4,10 +4,6 @@ module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2021,
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
babelOptions: {
babelrc: false,
Expand Down
4 changes: 2 additions & 2 deletions test/integration/projects.mjs
Expand Up @@ -88,8 +88,8 @@ export default [
// 'build/**'
// ]
// },
'https://github.com/ElemeFE/element',
'https://github.com/iview/iview',
// 'https://github.com/ElemeFE/element',
// 'https://github.com/iview/iview',
'https://github.com/sindresorhus/create-dmg',
'https://github.com/sindresorhus/cp-file',
'https://github.com/sindresorhus/capture-website',
Expand Down
1 change: 1 addition & 0 deletions test/no-for-loop.mjs
Expand Up @@ -731,6 +731,7 @@ test({
test(avoidTestTitleConflict({
testerOptions: {
parserOptions: {
sourceType: 'script',
ecmaVersion: 5,
},
},
Expand Down
2 changes: 0 additions & 2 deletions test/no-keyword-prefix.mjs
Expand Up @@ -228,12 +228,10 @@ test({
},
{
code: 'function foo({ newBar = \'default value\' }) {};',
parserOptions: {ecmaVersion: 6},
errors: [errorNew],
},
{
code: 'const newFoo = 0; function foo({ newBar = newFoo}) {}',
parserOptions: {ecmaVersion: 6},
errors: [errorNew, errorNew],
},
{
Expand Down
1 change: 1 addition & 0 deletions test/prevent-abbreviations.mjs
Expand Up @@ -1271,6 +1271,7 @@ test.typescript(avoidTestTitleConflict(tests, 'typescript'));
test({
testerOptions: {
parserOptions: {
sourceType: 'script',
ecmaVersion: 5,
},
env: {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/eslint-remote-tester.config.js
Expand Up @@ -29,7 +29,7 @@ module.exports = {
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
Expand Down
10 changes: 9 additions & 1 deletion test/utils/parsers.mjs
Expand Up @@ -59,10 +59,18 @@ const vue = {
return require.resolve(this.name);
},
mergeParserOptions(options) {
return {
options = {
...defaultParserOptions,
...options,
};

// The `espree` version in `vue-eslint-parser` does not understand `'latest'` yet.
// https://github.com/vuejs/vue-eslint-parser/pull/113
if (options.ecmaVersion === 'latest') {
options.ecmaVersion = require('espree').latestEcmaVersion;
}

return options;
},
};

Expand Down
7 changes: 5 additions & 2 deletions test/utils/test.mjs
Expand Up @@ -59,10 +59,13 @@ class Tester {
}

runTest(tests) {
const {beforeAll, testerOptions, valid, invalid} = tests;
const {beforeAll, testerOptions = {}, valid, invalid} = tests;
const tester = avaRuleTester(test, {
parserOptions: defaultParserOptions,
...testerOptions,
parserOptions: {
...defaultParserOptions,
...testerOptions.parserOptions,
},
});

if (beforeAll) {
Expand Down

0 comments on commit 9feb181

Please sign in to comment.