diff --git a/tests/config/format-test/failed-format-tests.js b/tests/config/format-test/failed-format-tests.js index 49ffc6d40..48a1afc79 100644 --- a/tests/config/format-test/failed-format-tests.js +++ b/tests/config/format-test/failed-format-tests.js @@ -60,13 +60,14 @@ const disabledTests = new Map( yuku: ["js/await/await-with-parens.js"], "yuku-ts": ["js/await/await-with-parens.js"], hermes: [ - // Different result - "js/await/like-call.js", + "js/await/like-call.js", // Different result + "jsx/top-level-await/test.jsx", ], flow: [ "js/decorators/member-expression.js", // Parsing to different ASTs "js/await/await-with-parens.js", "js/await/like-call.js", + "jsx/top-level-await/test.jsx", ], typescript: [], yaml: [ diff --git a/tests/config/format-test/verify-fixtures.js b/tests/config/format-test/verify-fixtures.js index 48afb6ea6..3aaeba1cd 100644 --- a/tests/config/format-test/verify-fixtures.js +++ b/tests/config/format-test/verify-fixtures.js @@ -100,7 +100,6 @@ const categoryParsers = new Map([ "meriyah", "acorn", "espree", - "espree", "hermes", "oxc", "oxc-ts", @@ -117,7 +116,6 @@ const categoryParsers = new Map([ "meriyah", "acorn", "espree", - "espree", "hermes", "oxc", "oxc-ts", @@ -190,7 +188,11 @@ const verifyParsers = (context) => { const { explicitParsers: parsers, dirname } = context; if (!Array.isArray(parsers) || parsers.length === 0) { - throw new Error(`No parsers were specified for ${dirname}`); + throw new Error(`No parsers were specified for '${dirname}'.`); + } + + if (new Set(parsers).size !== parsers.length) { + throw new Error(`Parsers should be unique for '${dirname}'.`); } const category = getCategory(dirname); diff --git a/tests/format/js/_errors_/export-name/__snapshots__/format.test.js.snap b/tests/format/js/_errors_/export-name/__snapshots__/format.test.js.snap index 89a99c2d5..e2f51bc9e 100644 --- a/tests/format/js/_errors_/export-name/__snapshots__/format.test.js.snap +++ b/tests/format/js/_errors_/export-name/__snapshots__/format.test.js.snap @@ -42,13 +42,6 @@ exports[`snippet: #0 format[espree] 1`] = ` Cause: An export name cannot include a lone surrogate." `; -exports[`snippet: #0 format[espree] 2`] = ` -"An export name cannot include a lone surrogate. (1:10) -> 1 | import { "\\uD83C" as b } from "./foo"; - | ^ -Cause: An export name cannot include a lone surrogate." -`; - exports[`snippet: #0 format[flow] 1`] = ` "Unexpected string, expected an identifier (1:10) > 1 | import { "\\uD83C" as b } from "./foo"; @@ -138,13 +131,6 @@ exports[`snippet: #1 format[espree] 1`] = ` Cause: An export name cannot include a lone surrogate." `; -exports[`snippet: #1 format[espree] 2`] = ` -"An export name cannot include a lone surrogate. (1:10) -> 1 | export { "\\uD83C" } from "./foo"; - | ^ -Cause: An export name cannot include a lone surrogate." -`; - exports[`snippet: #1 format[flow] 1`] = ` "Unexpected string, expected an identifier (1:10) > 1 | export { "\\uD83C" } from "./foo"; @@ -234,13 +220,6 @@ exports[`snippet: #2 format[espree] 1`] = ` Cause: An export name cannot include a lone surrogate." `; -exports[`snippet: #2 format[espree] 2`] = ` -"An export name cannot include a lone surrogate. (1:10) -> 1 | export { "\\uD83C" as b } from "./foo"; - | ^ -Cause: An export name cannot include a lone surrogate." -`; - exports[`snippet: #2 format[flow] 1`] = ` "Unexpected string, expected an identifier (1:10) > 1 | export { "\\uD83C" as b } from "./foo"; @@ -330,13 +309,6 @@ exports[`snippet: #3 format[espree] 1`] = ` Cause: An export name cannot include a lone surrogate." `; -exports[`snippet: #3 format[espree] 2`] = ` -"An export name cannot include a lone surrogate. (1:15) -> 1 | export { b as "\\uD83C" } from "./foo"; - | ^ -Cause: An export name cannot include a lone surrogate." -`; - exports[`snippet: #3 format[flow] 1`] = ` "Unexpected string, expected an identifier (1:15) > 1 | export { b as "\\uD83C" } from "./foo"; diff --git a/tests/format/js/_errors_/export-name/format.test.js b/tests/format/js/_errors_/export-name/format.test.js index b02a068ce..86dd9f92a 100644 --- a/tests/format/js/_errors_/export-name/format.test.js +++ b/tests/format/js/_errors_/export-name/format.test.js @@ -18,7 +18,6 @@ runFormatTest( "meriyah", "acorn", "espree", - "espree", "hermes", "oxc", "oxc-ts", diff --git a/tests/format/js/_errors_/newline-before-arrow/__snapshots__/format.test.js.snap b/tests/format/js/_errors_/newline-before-arrow/__snapshots__/format.test.js.snap index 7257e179a..8208c5470 100644 --- a/tests/format/js/_errors_/newline-before-arrow/__snapshots__/format.test.js.snap +++ b/tests/format/js/_errors_/newline-before-arrow/__snapshots__/format.test.js.snap @@ -1,5 +1,14 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`newline-before-arrow.js format[__babel_estree] 1`] = ` +"No line break is allowed before '=>'. (2:3) + 1 | async x +> 2 | => x + | ^ + 3 | +Cause: No line break is allowed before '=>'. (2:2)" +`; + exports[`newline-before-arrow.js format[acorn] 1`] = ` "Unexpected token (2:1) 1 | async x @@ -18,7 +27,7 @@ exports[`newline-before-arrow.js format[babel] 1`] = ` Cause: No line break is allowed before '=>'. (2:2)" `; -exports[`newline-before-arrow.js format[babel-ts] 1`] = ` +exports[`newline-before-arrow.js format[babel-flow] 1`] = ` "No line break is allowed before '=>'. (2:3) 1 | async x > 2 | => x @@ -27,7 +36,7 @@ exports[`newline-before-arrow.js format[babel-ts] 1`] = ` Cause: No line break is allowed before '=>'. (2:2)" `; -exports[`newline-before-arrow.js format[babel-ts] 2`] = ` +exports[`newline-before-arrow.js format[babel-ts] 1`] = ` "No line break is allowed before '=>'. (2:3) 1 | async x > 2 | => x @@ -54,6 +63,17 @@ exports[`newline-before-arrow.js format[flow] 1`] = ` Cause: Illegal newline before arrow (2:0)" `; +exports[`newline-before-arrow.js format[hermes] 1`] = ` +"invalid expression (2:1) + 1 | async x +> 2 | => x + | ^ + 3 | +Cause: invalid expression (2:0) +=> x +^" +`; + exports[`newline-before-arrow.js format[meriyah] 1`] = ` "No line break is allowed after '=>' (2:1) 1 | async x @@ -71,6 +91,14 @@ exports[`newline-before-arrow.js format[oxc] 1`] = ` 3 |" `; +exports[`newline-before-arrow.js format[oxc-ts] 1`] = ` +"Line terminator not permitted before arrow (2:1) + 1 | async x +> 2 | => x + | ^^ + 3 |" +`; + exports[`newline-before-arrow.js format[typescript] 1`] = ` "Unexpected keyword or identifier. (1:1) > 1 | async x @@ -87,3 +115,11 @@ exports[`newline-before-arrow.js format[yuku] 1`] = ` 2 | => x 3 |" `; + +exports[`newline-before-arrow.js format[yuku-ts] 1`] = ` +"Expected a semicolon or an implicit semicolon after a statement, but found 'x' (1:7) +> 1 | async x + | ^ + 2 | => x + 3 |" +`; diff --git a/tests/format/js/_errors_/newline-before-arrow/format.test.js b/tests/format/js/_errors_/newline-before-arrow/format.test.js index acaca2d09..df40b2898 100644 --- a/tests/format/js/_errors_/newline-before-arrow/format.test.js +++ b/tests/format/js/_errors_/newline-before-arrow/format.test.js @@ -1,12 +1,16 @@ runFormatTest(import.meta, [ "babel", + "babel-flow", + "babel-ts", + "__babel_estree", "typescript", "flow", - "babel-ts", + "meriyah", "acorn", "espree", - "meriyah", - "babel-ts", + "hermes", "oxc", + "oxc-ts", "yuku", + "yuku-ts", ]); diff --git a/tests/format/jsx/_errors_/invalid-jsx-text/__snapshots__/format.test.js.snap b/tests/format/jsx/_errors_/invalid-jsx-text/__snapshots__/format.test.js.snap index 4e97b7e49..a5555b609 100644 --- a/tests/format/jsx/_errors_/invalid-jsx-text/__snapshots__/format.test.js.snap +++ b/tests/format/jsx/_errors_/invalid-jsx-text/__snapshots__/format.test.js.snap @@ -1,5 +1,12 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`snippet: #0 format[__babel_estree] 1`] = ` +"Unexpected token \`}\`. Did you mean \`}\` or \`{'}'}\`? (1:15) +> 1 | let x1 =
@@ -164,7 +164,7 @@ regression_extra_newline_2 = ( exports[`windows.js format 1`] = ` ====================================options===================================== -parsers: ["flow", "babel", "typescript"] +parsers: ["babel", "typescript", "flow"] printWidth: 80 (default) | =====================================input======================================