diff --git a/tests/config/format-test.js b/tests/config/format-test.js index 4733d406a0f5..c63db9d586c1 100644 --- a/tests/config/format-test.js +++ b/tests/config/format-test.js @@ -55,8 +55,6 @@ const espreeDisabledTests = new Set( [ // These tests only work for `babel` "comments-closure-typecast", - // Unknown reason https://github.com/babel/babel/pull/14779#discussion_r928137651 - "strings", ].map((directory) => path.join(__dirname, "../format/js", directory)) ); const acornDisabledTests = espreeDisabledTests; diff --git a/tests/format/js/strings/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/strings/__snapshots__/jsfmt.spec.js.snap index c8f8fd1cc6ab..c69648792f68 100644 --- a/tests/format/js/strings/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/strings/__snapshots__/jsfmt.spec.js.snap @@ -65,6 +65,50 @@ const loremIpsumFooBazBar2 = ================================================================================ `; +exports[`non-octal-eight-and-nine.js [acorn] format 1`] = ` +"Invalid escape sequence (3:3) + 1 | // https://github.com/babel/babel/pull/11852 + 2 | +> 3 | "\\8","\\9"; + | ^ + 4 | () => { + 5 | "use strict"; + 6 | "\\8", "\\9";" +`; + +exports[`non-octal-eight-and-nine.js [espree] format 1`] = ` +"Invalid escape sequence (3:3) + 1 | // https://github.com/babel/babel/pull/11852 + 2 | +> 3 | "\\8","\\9"; + | ^ + 4 | () => { + 5 | "use strict"; + 6 | "\\8", "\\9";" +`; + +exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [acorn] format 1`] = ` +"Invalid escape sequence (3:3) + 1 | // https://github.com/babel/babel/pull/11852 + 2 | +> 3 | "\\8","\\9"; + | ^ + 4 | () => { + 5 | "use strict"; + 6 | "\\8", "\\9";" +`; + +exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [espree] format 1`] = ` +"Invalid escape sequence (3:3) + 1 | // https://github.com/babel/babel/pull/11852 + 2 | +> 3 | "\\8","\\9"; + | ^ + 4 | () => { + 5 | "use strict"; + 6 | "\\8", "\\9";" +`; + exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} format 1`] = ` ====================================options===================================== parsers: ["babel", "flow"] diff --git a/tests/format/js/strings/jsfmt.spec.js b/tests/format/js/strings/jsfmt.spec.js index 23e9edc554f5..c1f60b1648bb 100644 --- a/tests/format/js/strings/jsfmt.spec.js +++ b/tests/format/js/strings/jsfmt.spec.js @@ -1,2 +1,13 @@ -run_spec(import.meta, ["babel", "flow"]); -run_spec(import.meta, ["babel", "flow"], { trailingComma: "all" }); +run_spec(import.meta, ["babel", "flow"], { + errors: { + acorn: ["non-octal-eight-and-nine.js"], + espree: ["non-octal-eight-and-nine.js"], + }, +}); +run_spec(import.meta, ["babel", "flow"], { + trailingComma: "all", + errors: { + acorn: ["non-octal-eight-and-nine.js"], + espree: ["non-octal-eight-and-nine.js"], + }, +}); diff --git a/tests/format/typescript/optional-variance/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/optional-variance/__snapshots__/jsfmt.spec.js.snap index 6924ad0a2810..9db3e0deeea1 100644 --- a/tests/format/typescript/optional-variance/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/optional-variance/__snapshots__/jsfmt.spec.js.snap @@ -114,9 +114,6 @@ parsers: ["typescript"] printWidth: 80 | printWidth =====================================input====================================== -// valid JSX -() => {}; - type Covariant = { x: T; } @@ -180,12 +177,9 @@ declare class StateNode { } =====================================output===================================== -// valid JSX -() => {}; - -type Covariant = { x: T }; -type Contravariant = { f: (x: T) => void }; -type Invariant = { f: (x: T) => T }; +type Covariant = { x: T; }; +type Contravariant = { f: (x: T) => void; }; +type Invariant = { f: (x: T) => T; }; type T10 = T; type T11 = keyof T; type T12 = T[K]; @@ -231,3 +225,111 @@ exports[`with-jsx.tsx [typescript] format 1`] = ` 4 | type Covariant = { 5 | x: T;" `; + +exports[`with-jsx.tsx format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +type Covariant = { + x: T; +} +type Contravariant = { + f: (x: T) => void; +} +type Invariant = { + f: (x: T) => T; +} +type T10 = T; +type T11 = keyof T; +type T12 = T[K]; +type T13 = T[keyof T]; + +type Covariant1 = { + x: T; +} + +type Contravariant1 = keyof T; + +type Contravariant2 = { + f: (x: T) => void; +} + +type Invariant1 = { + f: (x: T) => T; +} + +type Invariant2 = { + f: (x: T) => T; +} +type Foo1 = { + x: T; + f: FooFn1; +} + +type Foo2 = { + x: T; + f: FooFn2; +} + +type Foo3 = { + x: T; + f: FooFn3; +} + +type T21 = T; + +interface Baz {} +interface Baz {} + +interface Parent { + child: Child | null; + parent: Parent | null; +} + +declare class StateNode { + _storedEvent: TEvent; + _action: ActionObject; + _state: StateNode; +} + +=====================================output===================================== +type Covariant = { x: T }; +type Contravariant = { f: (x: T) => void }; +type Invariant = { f: (x: T) => T }; +type T10 = T; +type T11 = keyof T; +type T12 = T[K]; +type T13 = T[keyof T]; + +type Covariant1 = { x: T }; + +type Contravariant1 = keyof T; + +type Contravariant2 = { f: (x: T) => void }; + +type Invariant1 = { f: (x: T) => T }; + +type Invariant2 = { f: (x: T) => T }; +type Foo1 = { x: T; f: FooFn1 }; + +type Foo2 = { x: T; f: FooFn2 }; + +type Foo3 = { x: T; f: FooFn3 }; + +type T21 = T; + +interface Baz {} +interface Baz {} + +interface Parent { child: Child | null; parent: Parent | null } + +declare class StateNode { + _storedEvent: TEvent; + _action: ActionObject; + _state: StateNode; +} + +================================================================================ +`; diff --git a/tests/format/typescript/optional-variance/jsfmt.spec.js b/tests/format/typescript/optional-variance/jsfmt.spec.js index 72e980aee6c2..29084a9c8a10 100644 --- a/tests/format/typescript/optional-variance/jsfmt.spec.js +++ b/tests/format/typescript/optional-variance/jsfmt.spec.js @@ -1,3 +1 @@ -run_spec(import.meta, ["typescript"], { - errors: { typescript: ["with-jsx.tsx"] }, -}); +run_spec(import.meta, ["typescript"]); diff --git a/tests/format/typescript/optional-variance/with-jsx.tsx b/tests/format/typescript/optional-variance/with-jsx.tsx index bd14abc7a9e5..9210edb034ae 100644 --- a/tests/format/typescript/optional-variance/with-jsx.tsx +++ b/tests/format/typescript/optional-variance/with-jsx.tsx @@ -1,6 +1,3 @@ -// valid JSX -() => {}; - type Covariant = { x: T; }