Created
April 16, 2025 08:15
-
-
Save bantic/5a9a237dc98775050e1c2fe6c412706b to your computer and use it in GitHub Desktop.
test eslint ecmaVersion for ts parser
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 = { | |
parser: "@typescript-eslint/parser", | |
parserOptions: { | |
ecmaVersion: 2015, | |
}, | |
plugins: ["@typescript-eslint"], | |
extends: ["plugin:@typescript-eslint/recommended"], | |
rules: { | |
"@typescript-eslint/no-explicit-any": "off", | |
}, | |
}; |
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/plugin-proposal-decorators": "^7.25.9", | |
"@typescript-eslint/eslint-plugin": "^8.30.1", | |
"@typescript-eslint/parser": "^8.30.1", | |
"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
const tests: any = {}; | |
tests.objspread = { ...{} }; // es2018 | |
tests.bign_syntaxt = 10n; // es2020 | |
const undef = undefined; | |
tests.nullish = undef ?? "foo"; // es2020 | |
tests.logical_assign ??= true; // es2021 | |
tests.regexp_indices = /foo/dg; // es2022 | |
tests.regexp_unicode = /foo/v; // es2024 | |
@annotation | |
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars | |
class MyClass {} | |
function annotation(target) { | |
target.annotated = true; | |
} |
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
Show hidden characters
{ | |
"compilerOptions": { | |
// The target value affects | |
// how the TS Language server parses the ts code. | |
// Change it to ES2020 to enable parsing the "10n" | |
// syntax, or es2022 to enable parsing the "/d" regex flag, | |
// or es2024 to parse the "/v" regex flag | |
"target": "ES2015" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment