Skip to content

Commit

Permalink
feat: add ecmaVersion: 2025, parsing duplicate named capturing grou…
Browse files Browse the repository at this point in the history
…ps (#18596)
mdjermanovic authored Jun 18, 2024
1 parent c7ddee0 commit 8824aa1
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion conf/ecma-version.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
* The latest ECMAScript version supported by ESLint.
* @type {number} year-based ECMAScript version
*/
const LATEST_ECMA_VERSION = 2024;
const LATEST_ECMA_VERSION = 2025;

module.exports = {
LATEST_ECMA_VERSION
7 changes: 6 additions & 1 deletion conf/globals.js
Original file line number Diff line number Diff line change
@@ -133,6 +133,10 @@ const es2024 = {
...es2023
};

const es2025 = {
...es2024
};


//-----------------------------------------------------------------------------
// Exports
@@ -151,5 +155,6 @@ module.exports = {
es2021,
es2022,
es2023,
es2024
es2024,
es2025
};
2 changes: 1 addition & 1 deletion docs/src/use/configure/language-options-deprecated.md
Original file line number Diff line number Diff line change
@@ -193,7 +193,7 @@ By the same token, supporting ES6 syntax is not the same as supporting new ES6 g

Parser options are set in your `.eslintrc.*` file with the `parserOptions` property. The available options are:

* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, 14, or 15 to specify the version of ECMAScript syntax you want to use. You can also set it to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), 2023 (same as 14), or 2024 (same as 15) to use the year-based naming. You can also set `"latest"` to use the most recently supported version.
* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, or 16 to specify the version of ECMAScript syntax you want to use. You can also set it to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), 2023 (same as 14), 2024 (same as 15), or 2025 (same as 16) to use the year-based naming. You can also set `"latest"` to use the most recently supported version.
* `sourceType` - set to `"script"` (default) or `"module"` if your code is in ECMAScript modules.
* `allowReserved` - allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
* `ecmaFeatures` - an object indicating which additional language features you'd like to use:
2 changes: 1 addition & 1 deletion lib/shared/types.js
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ module.exports = {};
/**
* @typedef {Object} ParserOptions
* @property {EcmaFeatures} [ecmaFeatures] The optional features.
* @property {3|5|6|7|8|9|10|11|12|13|14|15|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024} [ecmaVersion] The ECMAScript version (or revision number).
* @property {3|5|6|7|8|9|10|11|12|13|14|15|16|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024|2025} [ecmaVersion] The ECMAScript version (or revision number).
* @property {"script"|"module"} [sourceType] The source code type.
* @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@
"escape-string-regexp": "^4.0.0",
"eslint-scope": "^8.0.1",
"eslint-visitor-keys": "^4.0.0",
"espree": "^10.0.1",
"espree": "^10.1.0",
"esquery": "^1.5.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
10 changes: 9 additions & 1 deletion tests/lib/linter/linter.js
Original file line number Diff line number Diff line change
@@ -5610,7 +5610,7 @@ var a = "test2";
});

it("supports ECMAScript version 'latest'", () => {
const messages = linter.verify("let x = /[\\q{abc|d}&&[A--B]]/v;", {
const messages = linter.verify("let x = /(?<x>a)|(?<x>b)/;", {
parserOptions: { ecmaVersion: "latest" }
});
const suppressedMessages = linter.getSuppressedMessages();
@@ -7867,6 +7867,14 @@ describe("Linter with FlatConfigArray", () => {
linter.verify("foo", config, filename);
});

it("ecmaVersion should be 'latest' by default", () => {
const messages = linter.verify("let x = /(?<x>a)|(?<x>b)/;"); // ECMAScript 2025 syntax
const suppressedMessages = linter.getSuppressedMessages();

assert.strictEqual(messages.length, 0); // No parsing errors
assert.strictEqual(suppressedMessages.length, 0);
});

it("ecmaVersion should be normalized to latest year by default", () => {
const config = {
plugins: {

0 comments on commit 8824aa1

Please sign in to comment.