diff --git a/tests/format/misc/errors/js/reserved-word/__snapshots__/format.test.js.snap b/tests/format/misc/errors/js/reserved-word/__snapshots__/format.test.js.snap index 18dd37bc1..ad98e1a3e 100644 --- a/tests/format/misc/errors/js/reserved-word/__snapshots__/format.test.js.snap +++ b/tests/format/misc/errors/js/reserved-word/__snapshots__/format.test.js.snap @@ -1,5 +1,19 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`snippet: #0 [acorn] format 1`] = ` +"The keyword 'interface' is reserved (1:7) +> 1 | class interface {} + | ^ +Cause: The keyword 'interface' is reserved (1:6)" +`; + +exports[`snippet: #0 [acorn] format 2`] = ` +"Unexpected token (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^ +Cause: Unexpected token (1:7)" +`; + exports[`snippet: #0 [espree] format 1`] = ` "The keyword 'interface' is reserved (1:7) > 1 | class interface {} @@ -7,6 +21,34 @@ exports[`snippet: #0 [espree] format 1`] = ` Cause: The keyword 'interface' is reserved" `; +exports[`snippet: #0 [espree] format 2`] = ` +"Unexpected token asyn\\u{63} (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^ +Cause: Unexpected token asyn\\u{63}" +`; + +exports[`snippet: #0 [flow] format 1`] = ` +"Use of reserved word in strict mode (1:7) +> 1 | class interface {} + | ^^^^^^^^^" +`; + +exports[`snippet: #0 [flow] format 2`] = ` +"Unexpected identifier, expected a declaration, statement or export specifiers (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^^^^^^^^^^" +`; + +exports[`snippet: #0 [hermes] format 1`] = ` +"expected declaration in export (1:7) +> 1 | export asyn\\u{63} from "async"; + | ^ +Cause: expected declaration in export (1:7) +export asyn\\u{63} from "async"; + ^~~~~~~~~~" +`; + exports[`snippet: #0 [meriyah] format 1`] = ` "Unexpected strict mode reserved word (1:7) > 1 | class interface {} @@ -14,6 +56,39 @@ exports[`snippet: #0 [meriyah] format 1`] = ` Cause: [1:6-1:15]: Unexpected strict mode reserved word" `; +exports[`snippet: #0 [meriyah] format 2`] = ` +"Unexpected token: 'reserved if strict' (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^^^^^^^^^^ +Cause: [1:7-1:17]: Unexpected token: 'reserved if strict'" +`; + +exports[`snippet: #0 [oxc] format 1`] = ` +"Unexpected token (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^^^^^^^^^^" +`; + +exports[`snippet: #0 [oxc-ts] format 1`] = ` +"Keywords cannot contain escape characters (1:8) +> 1 | export asyn\\u{63} from "async"; + | ^^^^^^^^^^" +`; + +exports[`snippet: #0 [typescript] format 1`] = ` +"Declaration or statement expected. (1:1) +> 1 | export asyn\\u{63} from "async"; + | ^ +Cause: Declaration or statement expected." +`; + +exports[`snippet: #1 [acorn] format 1`] = ` +"The keyword 'interface' is reserved (1:8) +> 1 | import interface from "foo"; + | ^ +Cause: The keyword 'interface' is reserved (1:7)" +`; + exports[`snippet: #1 [espree] format 1`] = ` "The keyword 'interface' is reserved (1:8) > 1 | import interface from "foo"; @@ -21,6 +96,12 @@ exports[`snippet: #1 [espree] format 1`] = ` Cause: The keyword 'interface' is reserved" `; +exports[`snippet: #1 [flow] format 1`] = ` +"Use of reserved word in strict mode (1:8) +> 1 | import interface from "foo"; + | ^^^^^^^^^" +`; + exports[`snippet: #1 [meriyah] format 1`] = ` "Unexpected strict mode reserved word (1:8) > 1 | import interface from "foo"; diff --git a/tests/format/misc/errors/js/reserved-word/format.test.js b/tests/format/misc/errors/js/reserved-word/format.test.js index b668c9913..17103d170 100644 --- a/tests/format/misc/errors/js/reserved-word/format.test.js +++ b/tests/format/misc/errors/js/reserved-word/format.test.js @@ -3,5 +3,38 @@ runFormatTest( importMeta: import.meta, snippets: ["class interface {}", 'import interface from "foo";'], }, - ["espree", "meriyah"], + [ + // "babel", + // "babel-ts", + "acorn", + "espree", + "flow", + "meriyah", + // "typescript", + // "hermes", + // "oxc", + // "oxc-ts", + ], +); + +runFormatTest( + { + importMeta: import.meta, + snippets: [ + // cspell:disable-next-line + String.raw`export asyn\u{63} from "async";`, + ], + }, + [ + // "babel", + // "babel-ts", + "acorn", + "espree", + "flow", + "meriyah", + "typescript", + "hermes", + "oxc", + "oxc-ts", + ], ); diff --git a/tests/format/misc/errors/typescript/__snapshots__/format.test.js.snap b/tests/format/misc/errors/typescript/__snapshots__/format.test.js.snap index 794b8fcf6..1a6fb55b2 100644 --- a/tests/format/misc/errors/typescript/__snapshots__/format.test.js.snap +++ b/tests/format/misc/errors/typescript/__snapshots__/format.test.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`declare-getter.ts [babel-ts] format 1`] = ` +"'declare' is not allowed in getters. (2:3) + 1 | class Foo { +> 2 | declare get foo() + | ^ + 3 | } + 4 | +Cause: 'declare' is not allowed in getters. (2:2)" +`; + exports[`declare-getter.ts [typescript] format 1`] = ` "'declare' modifier cannot appear on class elements of this kind. (2:3) 1 | class Foo { @@ -10,6 +20,16 @@ exports[`declare-getter.ts [typescript] format 1`] = ` Cause: 'declare' modifier cannot appear on class elements of this kind." `; +exports[`declare-setter.ts [babel-ts] format 1`] = ` +"'declare' is not allowed in setters. (2:3) + 1 | class Foo { +> 2 | declare set foo(v) + | ^ + 3 | } + 4 | +Cause: 'declare' is not allowed in setters. (2:2)" +`; + exports[`declare-setter.ts [typescript] format 1`] = ` "'declare' modifier cannot appear on class elements of this kind. (2:3) 1 | class Foo { @@ -20,12 +40,12 @@ exports[`declare-setter.ts [typescript] format 1`] = ` Cause: 'declare' modifier cannot appear on class elements of this kind." `; -exports[`default-escaped.ts [typescript] format 1`] = ` -"Declaration or statement expected. (1:1) -> 1 | export asyn\\u{63} from "async"; - | ^ +exports[`export-declare.ts [babel-ts] format 1`] = ` +"'export declare' must be followed by an ambient declaration. (1:16) +> 1 | export declare foo; + | ^ 2 | -Cause: Declaration or statement expected." +Cause: 'export declare' must be followed by an ambient declaration. (1:15)" `; exports[`export-declare.ts [typescript] format 1`] = ` @@ -36,6 +56,16 @@ exports[`export-declare.ts [typescript] format 1`] = ` Cause: Declaration or statement expected." `; +exports[`invalid-jsx-1.tsx [babel-ts] format 1`] = ` +"Unexpected token \`>\`. Did you mean \`>\` or \`{'>'}\`? (3:45) + 1 | // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#-and--are-now-invalid-jsx-text-characters + 2 | +> 3 | let directions =