diff --git a/tests/format/js/_errors_/import/__snapshots__/format.test.js.snap b/tests/format/js/_errors_/import/__snapshots__/format.test.js.snap index 01f0abcee..5e90ad9e0 100644 --- a/tests/format/js/_errors_/import/__snapshots__/format.test.js.snap +++ b/tests/format/js/_errors_/import/__snapshots__/format.test.js.snap @@ -236,6 +236,360 @@ exports[`snippet: #3 format[yuku-ts] 1`] = ` | ^^^^^^" `; +exports[`snippet: #4 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo").bar; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #4 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo").bar; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #4 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo").bar; + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #4 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo").bar; + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #4 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo").bar; + | ^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #4 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo").bar; + | ^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #4 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo").bar; + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #4 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo").bar; + | ^^^^^^" +`; + +exports[`snippet: #4 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo").bar; + | ^^^^^^" +`; + +exports[`snippet: #5 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")[bar]; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #5 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")[bar]; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #5 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo")[bar]; + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #5 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo")[bar]; + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #5 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")[bar]; + | ^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #5 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")[bar]; + | ^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #5 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo")[bar]; + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #5 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")[bar]; + | ^^^^^^" +`; + +exports[`snippet: #5 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")[bar]; + | ^^^^^^" +`; + +exports[`snippet: #6 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")\`bar\`; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #6 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")\`bar\`; + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #6 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo")\`bar\`; + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #6 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo")\`bar\`; + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #6 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")\`bar\`; + | ^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #6 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")\`bar\`; + | ^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #6 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo")\`bar\`; + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #6 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")\`bar\`; + | ^^^^^^" +`; + +exports[`snippet: #6 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")\`bar\`; + | ^^^^^^" +`; + +exports[`snippet: #7 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo").bar(qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #7 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo").bar(qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #7 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo").bar(qux); + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #7 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo").bar(qux); + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #7 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo").bar(qux); + | ^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #7 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo").bar(qux); + | ^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #7 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo").bar(qux); + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #7 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo").bar(qux); + | ^^^^^^" +`; + +exports[`snippet: #7 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo").bar(qux); + | ^^^^^^" +`; + +exports[`snippet: #8 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")[bar](qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #8 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")[bar](qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #8 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo")[bar](qux); + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #8 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo")[bar](qux); + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #8 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")[bar](qux); + | ^^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #8 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")[bar](qux); + | ^^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #8 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo")[bar](qux); + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #8 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")[bar](qux); + | ^^^^^^" +`; + +exports[`snippet: #8 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")[bar](qux); + | ^^^^^^" +`; + +exports[`snippet: #9 format[babel] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #9 format[babel-ts] 1`] = ` +"Cannot use new with import(). (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^ +Cause: Cannot use new with import(). (1:4)" +`; + +exports[`snippet: #9 format[flow] 1`] = ` +"Unexpected token \`import\` (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^ +Cause: Unexpected token \`import\` (1:4)" +`; + +exports[`snippet: #9 format[meriyah] 1`] = ` +"Cannot use new with import(...) (1:11) +> 1 | new import("foo")\`bar\`(qux); + | ^ +Cause: [1:10-1:11]: Cannot use new with import(...)" +`; + +exports[`snippet: #9 format[oxc] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #9 format[oxc-ts] 1`] = ` +"Cannot use new with dynamic import (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^^^^^^^^^^^^^^^^^^^^^^^" +`; + +exports[`snippet: #9 format[typescript] 1`] = ` +"Expression expected. (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^ +Cause: Expression expected." +`; + +exports[`snippet: #9 format[yuku] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^^^^^^" +`; + +exports[`snippet: #9 format[yuku-ts] 1`] = ` +"'import' is reserved and cannot be used as an identifier (1:5) +> 1 | new import("foo")\`bar\`(qux); + | ^^^^^^" +`; + exports[`static-import-source-should-not-has-extra-token.js format[babel] 1`] = ` "Unexpected token (4:16) 2 | // be parenthesized, that accidentally break #8016 diff --git a/tests/format/js/_errors_/import/format.test.js b/tests/format/js/_errors_/import/format.test.js index 82058f04b..3c16b1374 100644 --- a/tests/format/js/_errors_/import/format.test.js +++ b/tests/format/js/_errors_/import/format.test.js @@ -6,6 +6,12 @@ runFormatTest( "import(/* comment */);", "new import('./a.mjs');", "new import();", + 'new import("foo").bar;', + 'new import("foo")[bar];', + 'new import("foo")`bar`;', + 'new import("foo").bar(qux);', + 'new import("foo")[bar](qux);', + 'new import("foo")`bar`(qux);', ], }, [