Skip to content

Commit 164c4d6

Browse files
committed
Test import attributes instead of deprecated import assertions
1 parent 80867d1 commit 164c4d6

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

babel.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"plugins": [
3-
"@babel/plugin-syntax-import-assertions",
3+
"@babel/plugin-syntax-import-attributes",
44
"@babel/plugin-transform-flow-strip-types"
55
]
66
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@babel/eslint-parser": "7.23.10",
14-
"@babel/plugin-syntax-import-assertions": "7.23.3",
14+
"@babel/plugin-syntax-import-attributes": "7.23.3",
1515
"@babel/plugin-transform-flow-strip-types": "7.23.3",
1616
"@typescript-eslint/parser": "6.21.0",
1717
"@vitest/coverage-v8": "^1.2.2",

test/imports.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ const flowTests = {
15841584
`import type a, {b} from "a"`,
15851585
`import type {} from "a"`,
15861586
`import type { } from "a"`,
1587-
`import json from "./foo.json" assert { type: "json" };`,
1587+
`import json from "./foo.json" with { type: "json" };`,
15881588

15891589
// typeof
15901590
`import typeof a from "a"`,
@@ -1681,11 +1681,11 @@ const flowTests = {
16811681
errors: 1,
16821682
},
16831683

1684-
// Import assertions.
1684+
// Import attributes.
16851685
{
16861686
code: input`
1687-
|import json from "./foo.json" assert { type: "json" };
1688-
|import {default as b} from "./bar.json" assert {
1687+
|import json from "./foo.json" with { type: "json" };
1688+
|import {default as b} from "./bar.json" with {
16891689
| // json
16901690
| type: "json",
16911691
| a: "b",
@@ -1695,12 +1695,12 @@ const flowTests = {
16951695
`,
16961696
output: (actual) => {
16971697
expect(actual).toMatchInlineSnapshot(`
1698-
|import {default as b} from "./bar.json" assert {
1698+
|import {default as b} from "./bar.json" with {
16991699
| // json
17001700
| type: "json",
17011701
| a: "b",
17021702
|} /* bar */
1703-
|import json from "./foo.json" assert { type: "json" };/* end
1703+
|import json from "./foo.json" with { type: "json" };/* end
17041704
| comment */
17051705
|;[].forEach()
17061706
`);
@@ -1977,11 +1977,11 @@ const typescriptTests = {
19771977
errors: 1,
19781978
},
19791979

1980-
// Import assertions.
1980+
// Import attributes.
19811981
{
19821982
code: input`
1983-
|import json from "./foo.json" assert { type: "json" };
1984-
|import {b, a} from "./bar.json" assert {
1983+
|import json from "./foo.json" with { type: "json" };
1984+
|import {b, a} from "./bar.json" with {
19851985
| // json
19861986
| type: "json",
19871987
| a: "b",
@@ -1991,12 +1991,12 @@ const typescriptTests = {
19911991
`,
19921992
output: (actual) => {
19931993
expect(actual).toMatchInlineSnapshot(`
1994-
|import {a,b} from "./bar.json" assert {
1994+
|import {a,b} from "./bar.json" with {
19951995
| // json
19961996
| type: "json",
19971997
| a: "b",
19981998
|} /* bar */
1999-
|import json from "./foo.json" assert { type: "json" };/* end
1999+
|import json from "./foo.json" with { type: "json" };/* end
20002000
| comment */
20012001
|;[].forEach()
20022002
`);

0 commit comments

Comments
 (0)