diff --git a/tests/format/js/_errors_/for-in-invalid-initializer/__snapshots__/format.test.js.snap b/tests/format/js/_errors_/for-in-invalid-initializer/__snapshots__/format.test.js.snap new file mode 100644 index 000000000..f9a569f8b --- /dev/null +++ b/tests/format/js/_errors_/for-in-invalid-initializer/__snapshots__/format.test.js.snap @@ -0,0 +1,169 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`snippet: #0 format[acorn] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (let a = 1 in b); + | ^ +Cause: for-in loop variable declaration may not have an initializer (1:5)" +`; + +exports[`snippet: #0 format[espree] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (let a = 1 in b); + | ^ +Cause: for-in loop variable declaration may not have an initializer" +`; + +exports[`snippet: #0 format[flow] 1`] = ` +"Invalid left-hand side in for-in (1:6) +> 1 | for (let a = 1 in b); + | ^ +Cause: Invalid left-hand side in for-in (1:5)" +`; + +exports[`snippet: #0 format[hermes] 1`] = ` +"for-in/for-of variable declaration may not be initialized (1:14) +> 1 | for (let a = 1 in b); + | ^ +Cause: for-in/for-of variable declaration may not be initialized (1:13) +for (let a = 1 in b); + ^" +`; + +exports[`snippet: #0 format[meriyah] 1`] = ` +"'for-in' loop head declarations can not have an initializer (1:10) +> 1 | for (let a = 1 in b); + | ^^^^^^^^ +Cause: [1:9-1:17]: 'for-in' loop head declarations can not have an initializer" +`; + +exports[`snippet: #0 format[oxc] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (let a = 1 in b); + | ^^^^^^^^^" +`; + +exports[`snippet: #0 format[oxc-ts] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (let a = 1 in b); + | ^^^^^^^^^" +`; + +exports[`snippet: #0 format[typescript] 1`] = ` +"The variable declaration of a 'for...in' statement cannot have an initializer. (1:10) +> 1 | for (let a = 1 in b); + | ^^^^^ +Cause: The variable declaration of a 'for...in' statement cannot have an initializer." +`; + +exports[`snippet: #1 format[acorn] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (const a = 1 in b); + | ^ +Cause: for-in loop variable declaration may not have an initializer (1:5)" +`; + +exports[`snippet: #1 format[espree] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (const a = 1 in b); + | ^ +Cause: for-in loop variable declaration may not have an initializer" +`; + +exports[`snippet: #1 format[flow] 1`] = ` +"Invalid left-hand side in for-in (1:6) +> 1 | for (const a = 1 in b); + | ^ +Cause: Invalid left-hand side in for-in (1:5)" +`; + +exports[`snippet: #1 format[hermes] 1`] = ` +"for-in/for-of variable declaration may not be initialized (1:16) +> 1 | for (const a = 1 in b); + | ^ +Cause: for-in/for-of variable declaration may not be initialized (1:15) +for (const a = 1 in b); + ^" +`; + +exports[`snippet: #1 format[meriyah] 1`] = ` +"'for-in' loop head declarations can not have an initializer (1:12) +> 1 | for (const a = 1 in b); + | ^^^^^^^^ +Cause: [1:11-1:19]: 'for-in' loop head declarations can not have an initializer" +`; + +exports[`snippet: #1 format[oxc] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (const a = 1 in b); + | ^^^^^^^^^^^" +`; + +exports[`snippet: #1 format[oxc-ts] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:6) +> 1 | for (const a = 1 in b); + | ^^^^^^^^^^^" +`; + +exports[`snippet: #1 format[typescript] 1`] = ` +"The variable declaration of a 'for...in' statement cannot have an initializer. (1:12) +> 1 | for (const a = 1 in b); + | ^^^^^ +Cause: The variable declaration of a 'for...in' statement cannot have an initializer." +`; + +exports[`snippet: #2 format[acorn] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:7) +> 1 | {for (using a = 1 in b);} + | ^ +Cause: for-in loop variable declaration may not have an initializer (1:6)" +`; + +exports[`snippet: #2 format[espree] 1`] = ` +"for-in loop variable declaration may not have an initializer (1:7) +> 1 | {for (using a = 1 in b);} + | ^ +Cause: for-in loop variable declaration may not have an initializer" +`; + +exports[`snippet: #2 format[flow] 1`] = ` +"Unexpected identifier, expected the token \`;\` (1:13) +> 1 | {for (using a = 1 in b);} + | ^ +Cause: Unexpected identifier, expected the token \`;\` (1:12)" +`; + +exports[`snippet: #2 format[hermes] 1`] = ` +"';' or 'in' expected inside 'for' (1:15) +> 1 | {for (using a = 1 in b);} + | ^ +Cause: ';' or 'in' expected inside 'for' (1:14) +{for (using a = 1 in b);} + ~~~~~~~~~~~~~^" +`; + +exports[`snippet: #2 format[meriyah] 1`] = ` +"'for-in' loop head declarations can not have an initializer (1:13) +> 1 | {for (using a = 1 in b);} + | ^^^^^^^^ +Cause: [1:12-1:20]: 'for-in' loop head declarations can not have an initializer" +`; + +exports[`snippet: #2 format[oxc] 1`] = ` +"Expected \`;\` but found \`)\` (1:23) +> 1 | {for (using a = 1 in b);} + | ^" +`; + +exports[`snippet: #2 format[oxc-ts] 1`] = ` +"Expected \`;\` but found \`)\` (1:23) +> 1 | {for (using a = 1 in b);} + | ^" +`; + +exports[`snippet: #2 format[typescript] 1`] = ` +"The variable declaration of a 'for...in' statement cannot have an initializer. (1:13) +> 1 | {for (using a = 1 in b);} + | ^^^^^ +Cause: The variable declaration of a 'for...in' statement cannot have an initializer." +`; diff --git a/tests/format/js/_errors_/for-in-invalid-initializer/format.test.js b/tests/format/js/_errors_/for-in-invalid-initializer/format.test.js new file mode 100644 index 000000000..7c4e3c572 --- /dev/null +++ b/tests/format/js/_errors_/for-in-invalid-initializer/format.test.js @@ -0,0 +1,25 @@ +runFormatTest( + { + importMeta: import.meta, + snippets: [ + "for (let a = 1 in b);", + "for (const a = 1 in b);", + "{for (using a = 1 in b);}", + ], + }, + [ + // "babel", + "acorn", + "espree", + "meriyah", + "typescript", + // "babel-ts", + "oxc", + "oxc-ts", + // "yuku", + // "yuku-ts", + "flow", + "hermes", + // "__babel_estree", + ], +);