Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f686fcb

Browse files
authored
feat: add ecmaVersion: 2026, parsing using and await using (#19832)
* feat: add `ecmaVersion: 2026`, parsing `using` and `await using` * bump eslint-visitor-keys
1 parent 85c082c commit f686fcb

File tree

9 files changed

+68
-9
lines changed

9 files changed

+68
-9
lines changed

conf/ecma-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* The latest ECMAScript version supported by ESLint.
1010
* @type {number} year-based ECMAScript version
1111
*/
12-
const LATEST_ECMA_VERSION = 2025;
12+
const LATEST_ECMA_VERSION = 2026;
1313

1414
module.exports = {
1515
LATEST_ECMA_VERSION,

conf/globals.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ const es2025 = {
139139
Iterator: false,
140140
};
141141

142+
const es2026 = {
143+
...es2025,
144+
AsyncDisposableStack: false,
145+
DisposableStack: false,
146+
SuppressedError: false,
147+
};
148+
142149
//-----------------------------------------------------------------------------
143150
// Exports
144151
//-----------------------------------------------------------------------------
@@ -158,4 +165,5 @@ module.exports = {
158165
es2023,
159166
es2024,
160167
es2025,
168+
es2026,
161169
};

docs/src/use/configure/language-options-deprecated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ By the same token, supporting ES6 syntax is not the same as supporting new ES6 g
193193

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

196-
- `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.
196+
- `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, or 17 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), 2025 (same as 16), or 2026 (same as 17) to use the year-based naming. You can also set `"latest"` to use the most recently supported version.
197197
- `sourceType` - set to `"script"` (default) or `"module"` if your code is in ECMAScript modules.
198198
- `allowReserved` - allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
199199
- `ecmaFeatures` - an object indicating which additional language features you'd like to use:

lib/types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ export namespace Linter {
14161416
| 14
14171417
| 15
14181418
| 16
1419+
| 17
14191420
| 2015
14201421
| 2016
14211422
| 2017
@@ -1427,6 +1428,7 @@ export namespace Linter {
14271428
| 2023
14281429
| 2024
14291430
| 2025
1431+
| 2026
14301432
| "latest";
14311433

14321434
/**

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"cross-spawn": "^7.0.6",
123123
"debug": "^4.3.2",
124124
"escape-string-regexp": "^4.0.0",
125-
"eslint-scope": "^8.3.0",
126-
"eslint-visitor-keys": "^4.2.0",
127-
"espree": "^10.3.0",
125+
"eslint-scope": "^8.4.0",
126+
"eslint-visitor-keys": "^4.2.1",
127+
"espree": "^10.4.0",
128128
"esquery": "^1.5.0",
129129
"esutils": "^2.0.2",
130130
"fast-deep-equal": "^3.1.3",

tests/lib/linter/linter.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6090,7 +6090,7 @@ var a = "test2";
60906090
});
60916091

60926092
it("supports ECMAScript version 'latest'", () => {
6093-
const messages = linter.verify("let x = /(?<x>a)|(?<x>b)/;", {
6093+
const messages = linter.verify("{ using x = foo(); }", {
60946094
parserOptions: { ecmaVersion: "latest" },
60956095
});
60966096
const suppressedMessages = linter.getSuppressedMessages();
@@ -9173,9 +9173,7 @@ describe("Linter with FlatConfigArray", () => {
91739173
});
91749174

91759175
it("ecmaVersion should be 'latest' by default", () => {
9176-
const messages = linter.verify(
9177-
"let x = /(?<x>a)|(?<x>b)/;",
9178-
); // ECMAScript 2025 syntax
9176+
const messages = linter.verify("{ using x = foo(); }"); // ECMAScript 2026 syntax
91799177
const suppressedMessages = linter.getSuppressedMessages();
91809178

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

tests/lib/rules/no-restricted-syntax.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,41 @@ ruleTester.run("no-restricted-syntax", rule, {
350350
},
351351
],
352352
},
353+
354+
{
355+
code: "{ using x = foo(); }",
356+
options: ["VariableDeclaration[kind='using']"],
357+
languageOptions: {
358+
ecmaVersion: 2026,
359+
},
360+
errors: [
361+
{
362+
messageId: "restrictedSyntax",
363+
data: {
364+
message:
365+
"Using 'VariableDeclaration[kind='using']' is not allowed.",
366+
},
367+
type: "VariableDeclaration",
368+
},
369+
],
370+
},
371+
372+
{
373+
code: "async function f() { await using x = foo(); }",
374+
options: ["VariableDeclaration[kind='await using']"],
375+
languageOptions: {
376+
ecmaVersion: 17,
377+
},
378+
errors: [
379+
{
380+
messageId: "restrictedSyntax",
381+
data: {
382+
message:
383+
"Using 'VariableDeclaration[kind='await using']' is not allowed.",
384+
},
385+
type: "VariableDeclaration",
386+
},
387+
],
388+
},
353389
],
354390
});

tests/lib/rules/no-undef.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ ruleTester.run("no-undef", rule, {
224224
code: "[Float16Array, Iterator]",
225225
languageOptions: { ecmaVersion: 2025 },
226226
},
227+
{
228+
code: "AsyncDisposableStack; DisposableStack; SuppressedError",
229+
languageOptions: { ecmaVersion: 2026 },
230+
},
227231
],
228232
invalid: [
229233
{

tests/lib/types/types.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2022 } }, "test.js");
930930
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2023 } }, "test.js");
931931
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2024 } }, "test.js");
932932
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2025 } }, "test.js");
933+
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2026 } }, "test.js");
933934
linter.verify(SOURCE, { parserOptions: { ecmaVersion: "latest" } }, "test.js");
934935
linter.verify(
935936
SOURCE,
@@ -1180,6 +1181,11 @@ linterWithFlatConfig.verify(
11801181
[{ languageOptions: { ecmaVersion: 2025 } }],
11811182
"test.js",
11821183
);
1184+
linterWithFlatConfig.verify(
1185+
SOURCE,
1186+
[{ languageOptions: { ecmaVersion: 2026 } }],
1187+
"test.js",
1188+
);
11831189
linterWithFlatConfig.verify(
11841190
SOURCE,
11851191
[{ languageOptions: { ecmaVersion: "latest" } }],
@@ -1345,6 +1351,11 @@ linterWithEslintrcConfig.verify(
13451351
{ parserOptions: { ecmaVersion: 2025 } },
13461352
"test.js",
13471353
);
1354+
linterWithEslintrcConfig.verify(
1355+
SOURCE,
1356+
{ parserOptions: { ecmaVersion: 2026 } },
1357+
"test.js",
1358+
);
13481359
linterWithEslintrcConfig.verify(
13491360
SOURCE,
13501361
{ parserOptions: { ecmaVersion: "latest" } },

0 commit comments

Comments
 (0)