diff --git a/package.json b/package.json index 7d0997acc..c33d6b700 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "editorconfig": "0.15.3", "emoji-regex": "10.4.0", "escape-string-regexp": "5.0.0", - "espree": "10.3.0", + "espree": "10.4.0", "fast-glob": "3.3.3", "fast-json-stable-stringify": "2.1.0", "file-entry-cache": "10.1.1", diff --git a/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap b/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap index d4c9206a4..11edced75 100644 --- a/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap +++ b/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap @@ -799,17 +799,6 @@ import(prettier).then((module) => console.log(module)); ================================================================================ `; -exports[`explicit-resource-management.js [espree] format 1`] = ` -"Unexpected token handle (2:9) - 1 | function * g() { -> 2 | using handle = acquireFileHandle(); // block-scoped critical resource - | ^ - 3 | } // cleanup - 4 | - 5 | { -Cause: Unexpected token handle" -`; - exports[`explicit-resource-management.js [meriyah] format 1`] = ` "Unexpected token: 'identifier' (2:9) 1 | function * g() { diff --git a/tests/format/js/babel-plugins/format.test.js b/tests/format/js/babel-plugins/format.test.js index e678b73e3..ba925a06d 100644 --- a/tests/format/js/babel-plugins/format.test.js +++ b/tests/format/js/babel-plugins/format.test.js @@ -45,7 +45,6 @@ runFormatTest(import.meta, ["babel", "babel-ts", "babel-flow"], { "module-blocks.js", "async-do-expressions.js", "decorator-auto-accessors.js", - "explicit-resource-management.js", "source-phase-imports.js", "deferred-import-evaluation.js", "optional-chaining-assignment.js", diff --git a/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap b/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap index d38457c3b..6c255d065 100644 --- a/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap +++ b/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap @@ -1,13 +1,5 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`for-await-using-of-comments.js [espree] format 1`] = ` -"Unexpected token await (1:19) -> 1 | /*1*/ for /* 2 */ await /*3*/ ( /*4*/ using /*5*/ fo /*6*/ of /*7*/ of /*8*/) /*9*/; - | ^ - 2 | -Cause: Unexpected token await" -`; - exports[`for-await-using-of-comments.js [flow] format 1`] = ` "Unexpected token \`await\`, expected the token \`(\` (1:19) > 1 | /*1*/ for /* 2 */ await /*3*/ ( /*4*/ using /*5*/ fo /*6*/ of /*7*/ of /*8*/) /*9*/; @@ -59,14 +51,14 @@ Cause: Identifier 'f' has already been declared (2:19)" `; exports[`invalid-duplicate-using-bindings.js [espree] format 1`] = ` -"Unexpected token f (2:9) +"Identifier 'f' has already been declared (2:20) 1 | { > 2 | using f = foo(), f = foo(); - | ^ + | ^ 3 | } 4 | { 5 | using g = foo(); -Cause: Unexpected token f" +Cause: Identifier 'f' has already been declared" `; exports[`invalid-duplicate-using-bindings.js [flow] format 1`] = ` @@ -130,14 +122,6 @@ printWidth: 80 ================================================================================ `; -exports[`invalid-script-top-level-using-binding.js [espree] format 1`] = ` -"Unexpected token x (1:7) -> 1 | using x = bar(); - | ^ - 2 | -Cause: Unexpected token x" -`; - exports[`invalid-script-top-level-using-binding.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (1:7) > 1 | using x = bar(); @@ -177,17 +161,6 @@ using x = bar(); ================================================================================ `; -exports[`using-declarations.js [espree] format 1`] = ` -"Unexpected token a (2:17) - 1 | { -> 2 | using /* 1 */ a = foo(), /* 2 */ b = foo() - | ^ - 3 | } - 4 | - 5 | for(using /* 1 */ a = foo(), /* 2 */ b = foo();;); -Cause: Unexpected token a" -`; - exports[`using-declarations.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:17) 1 | { @@ -272,6 +245,17 @@ exports[`valid-await-expr-using.js [acorn] format 1`] = ` Cause: Unexpected token (2:13)" `; +exports[`valid-await-expr-using.js [espree] format 1`] = ` +"Unexpected token [ (2:14) + 1 | async function f() { +> 2 | await using[x]; + | ^ + 3 | await using.x + await using(x) ? await using?.x : await using\`x\`; + 4 | } + 5 | +Cause: Unexpected token [" +`; + exports[`valid-await-expr-using.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -302,6 +286,16 @@ exports[`valid-await-expr-using-in.js [acorn] format 1`] = ` Cause: Unexpected keyword 'in' (2:14)" `; +exports[`valid-await-expr-using-in.js [espree] format 1`] = ` +"Unexpected keyword 'in' (2:15) + 1 | async function f() { +> 2 | await using in foo; + | ^ + 3 | } + 4 | +Cause: Unexpected keyword 'in'" +`; + exports[`valid-await-expr-using-in.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -330,6 +324,16 @@ exports[`valid-await-expr-using-instanceof.js [acorn] format 1`] = ` Cause: Unexpected keyword 'instanceof' (2:14)" `; +exports[`valid-await-expr-using-instanceof.js [espree] format 1`] = ` +"Unexpected keyword 'instanceof' (2:15) + 1 | async function f() { +> 2 | await using instanceof foo; + | ^ + 3 | } + 4 | +Cause: Unexpected keyword 'instanceof'" +`; + exports[`valid-await-expr-using-instanceof.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -368,16 +372,6 @@ async function f() { ================================================================================ `; -exports[`valid-await-using-binding-basic.js [espree] format 1`] = ` -"Unexpected token basic (2:15) - 1 | async function f() { -> 2 | await using basic = getReader(); - | ^ - 3 | } - 4 | -Cause: Unexpected token basic" -`; - exports[`valid-await-using-binding-basic.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:15) 1 | async function f() { @@ -427,16 +421,6 @@ async function f() { ================================================================================ `; -exports[`valid-await-using-binding-escaped.js [espree] format 1`] = ` -"Unexpected token \\u0061b (2:15) - 1 | async function f() { -> 2 | await using \\u0061b = c; - | ^ - 3 | } - 4 | -Cause: Unexpected token \\u0061b" -`; - exports[`valid-await-using-binding-escaped.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:15) 1 | async function f() { @@ -486,16 +470,6 @@ async function f() { ================================================================================ `; -exports[`valid-await-using-binding-non-bmp.js [espree] format 1`] = ` -"Unexpected token 𠮷 (2:15) - 1 | async function f() { -> 2 | await using 𠮷 = foo(); - | ^ - 3 | } - 4 | -Cause: Unexpected token 𠮷" -`; - exports[`valid-await-using-binding-non-bmp.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:15) 1 | async function f() { @@ -544,17 +518,6 @@ async function f() { ================================================================================ `; -exports[`valid-await-using-binding-using.js [espree] format 1`] = ` -"Unexpected token using (2:15) - 1 | async function f() { -> 2 | await using using = of; - | ^ - 3 | for (await using using of of); - 4 | } - 5 | -Cause: Unexpected token using" -`; - exports[`valid-await-using-binding-using.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:15) 1 | async function f() { @@ -609,18 +572,6 @@ async function f() { ================================================================================ `; -exports[`valid-await-using-comments.js [espree] format 1`] = ` -"Unexpected token b (3:28) - 1 | async function f() { - 2 | { -> 3 | /*0*/await/*1*/using/*2*/b/*3*/=/*4*/f()/*5*/; - | ^ - 4 | } - 5 | { - 6 | /*0*/for/*1*/(/*2*/await/*3*/using/*4*/b/*5*/=/*6*/x/*7*/;/*8*/;/*9*/)/*10*/; -Cause: Unexpected token b" -`; - exports[`valid-await-using-comments.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (3:28) 1 | async function f() { @@ -747,17 +698,6 @@ printWidth: 80 ================================================================================ `; -exports[`valid-for-using-binding-of-of.js [espree] format 1`] = ` -"Assigning to rvalue (2:8) - 1 | async function f() { -> 2 | for (await using of of of); - | ^ - 3 | for await (await using of of of); - 4 | } - 5 | -Cause: Assigning to rvalue" -`; - exports[`valid-for-using-binding-of-of.js [flow] format 1`] = ` "Invalid left-hand side in for-of (2:8) 1 | async function f() { @@ -812,16 +752,6 @@ async function f() { ================================================================================ `; -exports[`valid-for-using-declaration.js [espree] format 1`] = ` -"Unexpected token basic (2:20) - 1 | async function f() { -> 2 | for (await using basic = reader();;); - | ^ - 3 | } - 4 | -Cause: Unexpected token basic" -`; - exports[`valid-for-using-declaration.js [flow] format 1`] = ` "Unexpected identifier, expected the token \`;\` (2:20) 1 | async function f() { @@ -1148,6 +1078,16 @@ exports[`valid-using-as-identifier-for-in.js [acorn] format 1`] = ` Cause: Unexpected keyword 'in' (1:11)" `; +exports[`valid-using-as-identifier-for-in.js [espree] format 1`] = ` +"Unexpected keyword 'in' (1:12) +> 1 | for (using in []); + | ^ + 2 | for (using.foo in []); + 3 | for (using().foo in []); + 4 | for (using\`\`.foo in []); +Cause: Unexpected keyword 'in'" +`; + exports[`valid-using-as-identifier-for-in.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -1212,6 +1152,14 @@ exports[`valid-using-as-identifier-in.js [acorn] format 1`] = ` Cause: Unexpected keyword 'in' (1:6)" `; +exports[`valid-using-as-identifier-in.js [espree] format 1`] = ` +"Unexpected keyword 'in' (1:7) +> 1 | using in using instanceof using; + | ^ + 2 | +Cause: Unexpected keyword 'in'" +`; + exports[`valid-using-as-identifier-in.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -1226,16 +1174,6 @@ using in using instanceof using; ================================================================================ `; -exports[`valid-using-binding-basic.js [espree] format 1`] = ` -"Unexpected token basic (2:9) - 1 | { -> 2 | using basic = getReader(); - | ^ - 3 | } - 4 | -Cause: Unexpected token basic" -`; - exports[`valid-using-binding-basic.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:9) 1 | { @@ -1285,14 +1223,6 @@ printWidth: 80 ================================================================================ `; -exports[`valid-using-binding-escaped.js [espree] format 1`] = ` -"Unexpected token \\u0061b (1:9) -> 1 | { using \\u0061b = c; } - | ^ - 2 | -Cause: Unexpected token \\u0061b" -`; - exports[`valid-using-binding-escaped.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (1:9) > 1 | { using \\u0061b = c; } @@ -1390,17 +1320,6 @@ printWidth: 80 ================================================================================ `; -exports[`valid-using-binding-using.js [espree] format 1`] = ` -"Unexpected token using (2:9) - 1 | { -> 2 | using using = of; - | ^ - 3 | for (using using of of); - 4 | } - 5 | -Cause: Unexpected token using" -`; - exports[`valid-using-binding-using.js [flow] format 1`] = ` "Unexpected identifier, expected the end of an expression statement (\`;\`) (2:9) 1 | { diff --git a/tests/format/js/explicit-resource-management/format.test.js b/tests/format/js/explicit-resource-management/format.test.js index 8d01127eb..653273f3a 100644 --- a/tests/format/js/explicit-resource-management/format.test.js +++ b/tests/format/js/explicit-resource-management/format.test.js @@ -58,28 +58,29 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], { "valid-module-block-top-level-using-binding.js", "valid-module-block-top-level-await-using-binding.js", ], - espree: [ - "for-await-using-of-comments.js", + acorn: [ "invalid-duplicate-using-bindings.js", - "invalid-script-top-level-using-binding.js", - "using-declarations.js", - // "valid-for-await-using-binding-escaped-of-of.js", - // "valid-for-using-binding-escaped-of-of.js", + // "invalid-script-top-level-using-binding.js", + "valid-await-expr-using-in.js", + "valid-await-expr-using-instanceof.js", + "valid-await-expr-using.js", "valid-module-block-top-level-using-binding.js", - "valid-using-binding-basic.js", - "valid-using-binding-escaped.js", - "valid-using-binding-non-bmp.js", - "valid-using-binding-using.js", - - "valid-await-using-binding-basic.js", - "valid-await-using-binding-escaped.js", - "valid-await-using-binding-non-bmp.js", - "valid-await-using-binding-using.js", - "valid-await-using-comments.js", - "valid-for-lhs-await-as-identifier.js", - "valid-for-using-binding-of-of.js", - "valid-for-using-declaration.js", "valid-module-block-top-level-await-using-binding.js", + "valid-using-as-identifier-for-in.js", + "valid-using-as-identifier-in.js", + "valid-using-binding-non-bmp.js", + ], + espree: [ + "invalid-duplicate-using-bindings.js", + // "invalid-script-top-level-using-binding.js", + "valid-await-expr-using-in.js", + "valid-await-expr-using-instanceof.js", + "valid-await-expr-using.js", + "valid-module-block-top-level-using-binding.js", + "valid-module-block-top-level-await-using-binding.js", + "valid-using-as-identifier-for-in.js", + "valid-using-as-identifier-in.js", + "valid-using-binding-non-bmp.js", ], meriyah: [ "for-await-using-of-comments.js", @@ -104,18 +105,6 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], { "valid-for-using-declaration.js", "valid-module-block-top-level-await-using-binding.js", ], - acorn: [ - "invalid-duplicate-using-bindings.js", - // "invalid-script-top-level-using-binding.js", - "valid-await-expr-using-in.js", - "valid-await-expr-using-instanceof.js", - "valid-await-expr-using.js", - "valid-module-block-top-level-using-binding.js", - "valid-module-block-top-level-await-using-binding.js", - "valid-using-as-identifier-for-in.js", - "valid-using-as-identifier-in.js", - "valid-using-binding-non-bmp.js", - ], oxc: [ // "invalid-duplicate-using-bindings.js", // "invalid-script-top-level-using-binding.js", diff --git a/yarn.lock b/yarn.lock index 3dc51a18f..2ef600251 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2631,7 +2631,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:8.15.0, acorn@npm:^8.14.0": +"acorn@npm:8.15.0, acorn@npm:^8.14.0, acorn@npm:^8.15.0": version: 8.15.0 resolution: "acorn@npm:8.15.0" bin: @@ -4332,10 +4332,10 @@ __metadata: languageName: node linkType: hard -"eslint-visitor-keys@npm:^4.2.0": - version: 4.2.0 - resolution: "eslint-visitor-keys@npm:4.2.0" - checksum: 10/9651b3356b01760e586b4c631c5268c0e1a85236e3292bf754f0472f465bf9a856c0ddc261fceace155334118c0151778effafbab981413dbf9288349343fa25 +"eslint-visitor-keys@npm:^4.2.0, eslint-visitor-keys@npm:^4.2.1": + version: 4.2.1 + resolution: "eslint-visitor-keys@npm:4.2.1" + checksum: 10/3ee00fc6a7002d4b0ffd9dc99e13a6a7882c557329e6c25ab254220d71e5c9c4f89dca4695352949ea678eb1f3ba912a18ef8aac0a7fe094196fd92f441bfce2 languageName: node linkType: hard @@ -4399,14 +4399,14 @@ __metadata: languageName: node linkType: hard -"espree@npm:10.3.0, espree@npm:^10.0.1, espree@npm:^10.3.0": - version: 10.3.0 - resolution: "espree@npm:10.3.0" +"espree@npm:10.4.0, espree@npm:^10.0.1, espree@npm:^10.3.0": + version: 10.4.0 + resolution: "espree@npm:10.4.0" dependencies: - acorn: "npm:^8.14.0" + acorn: "npm:^8.15.0" acorn-jsx: "npm:^5.3.2" - eslint-visitor-keys: "npm:^4.2.0" - checksum: 10/3412d44d4204c9e29d6b5dd0277400cfa0cd68495dc09eae1b9ce79d0c8985c1c5cc09cb9ba32a1cd963f48a49b0c46bdb7736afe395a300aa6bb1c0d86837e8 + eslint-visitor-keys: "npm:^4.2.1" + checksum: 10/9b355b32dbd1cc9f57121d5ee3be258fab87ebeb7c83fc6c02e5af1a74fc8c5ba79fe8c663e69ea112c3e84a1b95e6a2067ac4443ee7813bb85ac7581acb8bf9 languageName: node linkType: hard @@ -7354,7 +7354,7 @@ __metadata: eslint-plugin-simple-import-sort: "npm:12.1.1" eslint-plugin-unicorn: "npm:59.0.1" esm-utils: "npm:4.4.2" - espree: "npm:10.3.0" + espree: "npm:10.4.0" fast-glob: "npm:3.3.3" fast-json-stable-stringify: "npm:2.1.0" file-entry-cache: "npm:10.1.1"