Last active
April 14, 2025 10:15
-
-
Save bantic/da604b51a8d412cf76a9e32064872fb9 to your computer and use it in GitHub Desktop.
test eslint ecmaVersion impact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// eslint-disable-next-line no-undef | |
module.exports = { | |
// If the line below is commented out, the eslint default parser is used, | |
// and the parserOptions.ecmaVersion becomes meaningful; it must be incremented | |
// to a value greater than 2024 to parse the entire test.js file. | |
// When the babel eslint-parser is used, the ecmaVersion option is ignored. | |
parser: "@babel/eslint-parser", | |
parserOptions: { | |
ecmaVersion: 2017, | |
requireConfigFile: false, | |
babelOptions: { | |
plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]], | |
}, | |
}, | |
extends: ["eslint:recommended"], | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test-eslint", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"@babel/eslint-parser": "^7.27.0", | |
"@babel/plugin-proposal-decorators": "^7.25.9", | |
"eslint": "^8.0.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tests = {}; | |
tests.objspread = { ...{} }; // es2018 | |
tests.bign_syntaxt = 10n; // es2020 | |
let undef; | |
tests.nullish = undef ?? "foo"; // es2020 | |
tests.logical_assign ??= true; // es2021 | |
tests.regexp_indices = /foo/dg; // es2022 | |
tests.regexp_unicode = /foo/v; // es2024 | |
// class annotation below requires: | |
// parser: @babel/eslint-parser | |
// with babelOptions: | |
// plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]], | |
// @annotation | |
// // eslint-disable-next-line no-unused-vars | |
// class MyClass {} | |
// function annotation(target) { | |
// target.annotated = true; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment