Repository: prettier/prettier (JavaScript)

Issue:
Safely remove quotes from keys in Import Attributes
## Description

<!-- Please provide a brief summary of your changes: -->

Fixes #15563

## Checklist

<!-- Please ensure you’ve done all of these things (if applicable). -->
<!-- You can replace the `[ ]` with `[x]` to mark each task as done. -->

- [x] I’ve added tests to confirm my change works.
- [ ] (If changing the API or CLI) I’ve documented the changes I’ve made (in the `docs/` directory).
- [ ] (If the change is user-facing) I’ve added my changes to `changelog_unreleased/*/XXXX.md` file following `changelog_unreleased/TEMPLATE.md`.
- [x] I’ve read the [contributing guidelines](https://github.com/prettier/prettier/blob/main/CONTRIBUTING.md).

<!-- Please DO NOT remove the playground link -->

**✨[Try the playground for this PR](https://prettier.io/playground-redirect)✨**

Remove quotes in import attribute
**Prettier 3.0.3**
[Playground link](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAmAF98AzHCdfAcmvwHdUYALQ-AHRBgE9M5OknAFYBnaJ3xEQAGhARMMVNBHJQAQxwV6ABQ0IVKNQBt6a7itkAjHGrABrODADKa9HAAyqKHGSljIuCsbe0cnTFsvAHNkGBwAV0CQAPRUGPjEkSijOABFOIh4X39E0QAPJyzc-MKkPyMA2QBHarhtCkwDEDURAFpvOAATQZkuG1QjKIBhSnQ1ZC6jIxHMqEjsgEEYWNRLOPhtOBxPbyL6xOYYdCMAdWYmOBFwsDgnfSZUADcmbnmwEQsQB8EgBJKBDWBOMA4VAKdZgpw8bJpBKyTAUALXGyYeZoh6HD4+WReAJ4NpqSKzU4NEDhHAk+aWNSWOBLVHQ2DXVADFjIAAcAAZZDg4M1UMKyRS5rVirIYEzOdzmMgAEyyOIBAAqTIMdWpcHQzIGQwG7jUqzi5LgADFcLMtlF5mo9hAQEQiEA)
<!-- prettier-ignore -->
```sh
--parser babel
```

**Input:**
<!-- prettier-ignore -->
```jsx
import {} from '' with { "type":"json" }
```

**Output:**
<!-- prettier-ignore -->
```jsx
import {} from "" with { "type": "json" };

```

**Expected behavior:**

```jsx
import {} from "" with { type: "json" };
```



Hints:
For some reason FULL_TEST is failing. I'll investigate later.
It is intended to remove quotes from keys in object literals. Does Import Attribute keys have a different meaning depending on whether it is quoted or not?

---

**Prettier 3.0.3**
[Playground link](https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEAzCFMC8mwmAOiLhOUpgMyYC+A3KVCADQgQAOMAlumSgAhgCdREAO4AFMQjTIQwgDaThATwWcARqOFgA1nBgBlYQFs4AGT5Q4ybCrRwdew8ZPd9tgObIYogCuLiDO5nz+QSFovspwAIqBEPAOTiEAVmgAHiaxCUkpSI7KzpwAjgVw0hLcCijCaAC0dnAAJm0cIAHCfMq+AMIQ5ubCiirKnTFQPnEAgjABfNqB8NJwojZ2qSUhABYw5soA6rt88GheYHAm8md8AG5n6opgaFog98EAklDtsCZgUR8XizX4mGDqOLbUogbgSZxHPTcRRwuDOUT3eycWzomDVYQ+EbQkJeUToxTaYTaOATThw2wwI58VowXbIAAcAAZOKI4BU+Lz8YTRkU0pwYFSmSy2UgAEycQLOAAqVLqxRhcHM1Na7VaVmE00CBLgADEIKIRgtfGMVhAQAwGEA)
<!-- prettier-ignore -->
```sh
--parser babel
```

**Input:**
<!-- prettier-ignore -->
```jsx
const foo = { "foo": 3 };

```

**Output:**
<!-- prettier-ignore -->
```jsx
const foo = { foo: 3 };

```
I think it's similar to object expression. Only need quotes for special characters like `-`
Ah sorry, I misunderstood that output and expected were the opposite. understood. thank you.
@nicolo-ribaudo Is it safe to remove quotes from Import Attributes keys using the exact same algorithm as for object literal keys?
Yes, except for numeric keys like `"0"`.
... What about `"0n"`?
Also not safe — the only valid keys are strings and identifiers.

Patch:
diff --git a/src/language-js/clean.js b/src/language-js/clean.js
--- a/src/language-js/clean.js
+++ b/src/language-js/clean.js
@@ -79,7 +79,8 @@ function clean(original, cloned, parent) {
       original.type === "PropertyDefinition" ||
       original.type === "TSDeclareMethod" ||
       original.type === "TSPropertySignature" ||
-      original.type === "ObjectTypeProperty") &&
+      original.type === "ObjectTypeProperty" ||
+      original.type === "ImportAttribute") &&
     typeof original.key === "object" &&
     original.key &&
     (original.key.type === "Literal" ||
diff --git a/src/language-js/print/estree.js b/src/language-js/print/estree.js
--- a/src/language-js/print/estree.js
+++ b/src/language-js/print/estree.js
@@ -228,7 +228,7 @@ function printEstree(path, options, print, args) {
     case "ExportDefaultSpecifier":
       return printModuleSpecifier(path, options, print);
     case "ImportAttribute":
-      return [print("key"), ": ", print("value")];
+      return printProperty(path, options, print);
     case "Import":
       return "import";
 
diff --git a/src/language-js/print/property.js b/src/language-js/print/property.js
--- a/src/language-js/print/property.js
+++ b/src/language-js/print/property.js
@@ -26,7 +26,8 @@ function printPropertyKey(path, options, print) {
     const objectHasStringProp = (
       parent.properties ||
       parent.body ||
-      parent.members
+      parent.members ||
+      parent.attributes
     ).some(
       (prop) =>
         !prop.computed &&
diff --git a/src/language-js/utils/index.js b/src/language-js/utils/index.js
--- a/src/language-js/utils/index.js
+++ b/src/language-js/utils/index.js
@@ -616,6 +616,7 @@ function isStringPropSafeToUnquote(node, options) {
       )) ||
       (isSimpleNumber(node.key.value) &&
         String(Number(node.key.value)) === node.key.value &&
+        node.type !== "ImportAttribute" &&
         (options.parser === "babel" ||
           options.parser === "acorn" ||
           options.parser === "espree" ||


Test patch:
diff --git a/tests/format/js/import-attributes/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/import-attributes/__snapshots__/jsfmt.spec.js.snap
--- a/tests/format/js/import-attributes/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/format/js/import-attributes/__snapshots__/jsfmt.spec.js.snap
@@ -24,6 +24,84 @@ exports[`dynamic-import.js [meriyah] format 1`] = `
 Cause: [1:20]: Expected ')'"
 `;
 
+exports[`dynamic-import.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: Unexpected token (1:19)"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token , (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: Unexpected token ,"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Expected ')' (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: [1:20]: Expected ')'"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import("./foo.json", { with: { type: "json" } });
+
+=====================================output=====================================
+import("./foo.json", { with: { type: "json" } });
+
+================================================================================
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: Unexpected token (1:19)"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token , (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: Unexpected token ,"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Expected ')' (1:20)
+> 1 | import("./foo.json", { with: { type: "json" } });
+    |                    ^
+  2 |
+Cause: [1:20]: Expected ')'"
+`;
+
+exports[`dynamic-import.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import("./foo.json", { with: { type: "json" } });
+
+=====================================output=====================================
+import("./foo.json", { with: { type: "json" } });
+
+================================================================================
+`;
+
 exports[`dynamic-import.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
@@ -71,6 +149,126 @@ exports[`empty.js [meriyah] format 1`] = `
 Cause: [2:36]: Unexpected token: 'with'"
 `;
 
+exports[`empty.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (2:33)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                 ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: Unexpected token (2:32)"
+`;
+
+exports[`empty.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (2:33)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                 ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: Unexpected token with"
+`;
+
+exports[`empty.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (2:36)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                    ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: [2:36]: Unexpected token: 'with'"
+`;
+
+exports[`empty.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+export * as foo from "foo.json"
+export * as bar from "bar.json" with { }
+export * as baz from "baz.json" with { /* comment */ }
+
+import * as foo from "foo.json"
+import * as bar from "bar.json" with { }
+import * as baz from "baz.json" with { /* comment */ }
+
+=====================================output=====================================
+export * as foo from "foo.json";
+export * as bar from "bar.json" with {};
+export * as baz from "baz.json" /* comment */ with {};
+
+import * as foo from "foo.json";
+import * as bar from "bar.json" with {};
+import * as baz from "baz.json" /* comment */ with {};
+
+================================================================================
+`;
+
+exports[`empty.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (2:33)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                 ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: Unexpected token (2:32)"
+`;
+
+exports[`empty.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (2:33)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                 ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: Unexpected token with"
+`;
+
+exports[`empty.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (2:36)
+  1 | export * as foo from "foo.json"
+> 2 | export * as bar from "bar.json" with { }
+    |                                    ^
+  3 | export * as baz from "baz.json" with { /* comment */ }
+  4 |
+  5 | import * as foo from "foo.json"
+Cause: [2:36]: Unexpected token: 'with'"
+`;
+
+exports[`empty.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+export * as foo from "foo.json"
+export * as bar from "bar.json" with { }
+export * as baz from "baz.json" with { /* comment */ }
+
+import * as foo from "foo.json"
+import * as bar from "bar.json" with { }
+import * as baz from "baz.json" with { /* comment */ }
+
+=====================================output=====================================
+export * as foo from "foo.json";
+export * as bar from "bar.json" with {};
+export * as baz from "baz.json" /* comment */ with {};
+
+import * as foo from "foo.json";
+import * as bar from "bar.json" with {};
+import * as baz from "baz.json" /* comment */ with {};
+
+================================================================================
+`;
+
 exports[`empty.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
@@ -127,10 +325,41 @@ exports[`keyword-detect.js [meriyah] format 1`] = `
 Cause: [1:38]: Unexpected token: 'with'"
 `;
 
-exports[`keyword-detect.js format 1`] = `
+exports[`keyword-detect.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:35)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                   ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+Cause: Unexpected token (1:34)"
+`;
+
+exports[`keyword-detect.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:35)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                   ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+Cause: Unexpected token with"
+`;
+
+exports[`keyword-detect.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:38)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                      ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+Cause: [1:38]: Unexpected token: 'with'"
+`;
+
+exports[`keyword-detect.js - {"quoteProps":"consistent"} format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
 printWidth: 80
+quoteProps: "consistent"
                                                                                 | printWidth
 =====================================input======================================
 import "./test.json" /* assert */ with /* assert */  { type: "json" }
@@ -159,43 +388,216 @@ export * from "./test.json" /* with */ /* with */ assert { type: "json" };
 ================================================================================
 `;
 
-exports[`multi-types.js [acorn] format 1`] = `
-"Unexpected token (1:31)
-> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
-    |                               ^
-  2 |
-Cause: Unexpected token (1:30)"
+exports[`keyword-detect.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:35)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                   ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+Cause: Unexpected token (1:34)"
 `;
 
-exports[`multi-types.js [espree] format 1`] = `
-"Unexpected token with (1:31)
-> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
-    |                               ^
-  2 |
+exports[`keyword-detect.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:35)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                   ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
 Cause: Unexpected token with"
 `;
 
-exports[`multi-types.js [meriyah] format 1`] = `
-"Unexpected token: 'with' (1:34)
-> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
-    |                                  ^
-  2 |
-Cause: [1:34]: Unexpected token: 'with'"
+exports[`keyword-detect.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:38)
+> 1 | import "./test.json" /* assert */ with /* assert */  { type: "json" }
+    |                                      ^
+  2 | import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+  3 | import "./test.json" /* with */ assert /* with */  { type: "json" }
+  4 | import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+Cause: [1:38]: Unexpected token: 'with'"
 `;
 
-exports[`multi-types.js format 1`] = `
+exports[`keyword-detect.js - {"quoteProps":"preserve"} format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
 printWidth: 80
+quoteProps: "preserve"
                                                                                 | printWidth
 =====================================input======================================
-import json from "./foo.json" with { type: "json", type: "bar" };
-
-=====================================output=====================================
-import json from "./foo.json" with { type: "json", type: "bar" };
+import "./test.json" /* assert */ with /* assert */  { type: "json" }
+import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+import "./test.json" /* with */ assert /* with */  { type: "json" }
+import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
 
-================================================================================
-`;
+export {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+export {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+
+export * from "./test.json" /* assert */ with /* assert */  { type: "json" }
+export * from "./test.json" /* with */ assert /* with */  { type: "json" }
+
+=====================================output=====================================
+import "./test.json" /* assert */ /* assert */ with { type: "json" };
+import {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
+import "./test.json" /* with */ /* with */ assert { type: "json" };
+import {} from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+export {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
+export {} from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+export * from "./test.json" /* assert */ /* assert */ with { type: "json" };
+export * from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+================================================================================
+`;
+
+exports[`keyword-detect.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+                                                                                | printWidth
+=====================================input======================================
+import "./test.json" /* assert */ with /* assert */  { type: "json" }
+import {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+import "./test.json" /* with */ assert /* with */  { type: "json" }
+import {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+
+export {} from "./test.json" /* assert */ with /* assert */  { type: "json" }
+export {} from "./test.json" /* with */ assert /* with */  { type: "json" }
+
+export * from "./test.json" /* assert */ with /* assert */  { type: "json" }
+export * from "./test.json" /* with */ assert /* with */  { type: "json" }
+
+=====================================output=====================================
+import "./test.json" /* assert */ /* assert */ with { type: "json" };
+import {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
+import "./test.json" /* with */ /* with */ assert { type: "json" };
+import {} from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+export {} from "./test.json" /* assert */ /* assert */ with { type: "json" };
+export {} from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+export * from "./test.json" /* assert */ /* assert */ with { type: "json" };
+export * from "./test.json" /* with */ /* with */ assert { type: "json" };
+
+================================================================================
+`;
+
+exports[`multi-types.js [acorn] format 1`] = `
+"Unexpected token (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token (1:30)"
+`;
+
+exports[`multi-types.js [espree] format 1`] = `
+"Unexpected token with (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`multi-types.js [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:34)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                                  ^
+  2 |
+Cause: [1:34]: Unexpected token: 'with'"
+`;
+
+exports[`multi-types.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token (1:30)"
+`;
+
+exports[`multi-types.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`multi-types.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:34)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                                  ^
+  2 |
+Cause: [1:34]: Unexpected token: 'with'"
+`;
+
+exports[`multi-types.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+=====================================output=====================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+================================================================================
+`;
+
+exports[`multi-types.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token (1:30)"
+`;
+
+exports[`multi-types.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:31)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                               ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`multi-types.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:34)
+> 1 | import json from "./foo.json" with { type: "json", type: "bar" };
+    |                                  ^
+  2 |
+Cause: [1:34]: Unexpected token: 'with'"
+`;
+
+exports[`multi-types.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+=====================================output=====================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+================================================================================
+`;
+
+exports[`multi-types.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+                                                                                | printWidth
+=====================================input======================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+=====================================output=====================================
+import json from "./foo.json" with { type: "json", type: "bar" };
+
+================================================================================
+`;
 
 exports[`non-type.js [acorn] format 1`] = `
 "Unexpected token (1:28)
@@ -221,6 +623,84 @@ exports[`non-type.js [meriyah] format 1`] = `
 Cause: [1:31]: Unexpected token: 'with'"
 `;
 
+exports[`non-type.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:28)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                            ^
+  2 |
+Cause: Unexpected token (1:27)"
+`;
+
+exports[`non-type.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:28)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                            ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`non-type.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:31)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                               ^
+  2 |
+Cause: [1:31]: Unexpected token: 'with'"
+`;
+
+exports[`non-type.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import foo from "foo.json" with { lazy: "true" };
+
+=====================================output=====================================
+import foo from "foo.json" with { lazy: "true" };
+
+================================================================================
+`;
+
+exports[`non-type.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:28)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                            ^
+  2 |
+Cause: Unexpected token (1:27)"
+`;
+
+exports[`non-type.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:28)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                            ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`non-type.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:31)
+> 1 | import foo from "foo.json" with { lazy: "true" };
+    |                               ^
+  2 |
+Cause: [1:31]: Unexpected token: 'with'"
+`;
+
+exports[`non-type.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import foo from "foo.json" with { lazy: "true" };
+
+=====================================output=====================================
+import foo from "foo.json" with { lazy: "true" };
+
+================================================================================
+`;
+
 exports[`non-type.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
@@ -235,6 +715,194 @@ import foo from "foo.json" with { lazy: "true" };
 ================================================================================
 `;
 
+exports[`quoted-keys.js [acorn] format 1`] = `
+"Unexpected token (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token (1:28)"
+`;
+
+exports[`quoted-keys.js [espree] format 1`] = `
+"Unexpected token with (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token with"
+`;
+
+exports[`quoted-keys.js [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:32)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                                ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: [1:32]: Unexpected token: 'with'"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token (1:28)"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token with"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:32)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                                ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: [1:32]: Unexpected token: 'with'"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import json from './mod.js' with { "type":"json" };
+import json from './mod.js' with { "foobar":"json" };
+import json from './mod.js' with { "type-foo" :"json" };
+import json from './mod.js' with { "333foo" :"json" };
+import json from './mod.js' with { "0" :"json" };
+import json from './mod.js' with { "0n" :"json" };
+import json from './mod.js' with { "33333" :"json" };
+import json from './mod.js' with { "33333n" :"json" };
+import json from './mod.js' with { "33333b" :"json" };
+import json from './mod.js' with { "03333" :"json" };
+
+=====================================output=====================================
+import json from "./mod.js" with { type: "json" };
+import json from "./mod.js" with { foobar: "json" };
+import json from "./mod.js" with { "type-foo": "json" };
+import json from "./mod.js" with { "333foo": "json" };
+import json from "./mod.js" with { "0": "json" };
+import json from "./mod.js" with { "0n": "json" };
+import json from "./mod.js" with { "33333": "json" };
+import json from "./mod.js" with { "33333n": "json" };
+import json from "./mod.js" with { "33333b": "json" };
+import json from "./mod.js" with { "03333": "json" };
+
+================================================================================
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token (1:28)"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:29)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                             ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: Unexpected token with"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:32)
+> 1 | import json from './mod.js' with { "type":"json" };
+    |                                ^
+  2 | import json from './mod.js' with { "foobar":"json" };
+  3 | import json from './mod.js' with { "type-foo" :"json" };
+  4 | import json from './mod.js' with { "333foo" :"json" };
+Cause: [1:32]: Unexpected token: 'with'"
+`;
+
+exports[`quoted-keys.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import json from './mod.js' with { "type":"json" };
+import json from './mod.js' with { "foobar":"json" };
+import json from './mod.js' with { "type-foo" :"json" };
+import json from './mod.js' with { "333foo" :"json" };
+import json from './mod.js' with { "0" :"json" };
+import json from './mod.js' with { "0n" :"json" };
+import json from './mod.js' with { "33333" :"json" };
+import json from './mod.js' with { "33333n" :"json" };
+import json from './mod.js' with { "33333b" :"json" };
+import json from './mod.js' with { "03333" :"json" };
+
+=====================================output=====================================
+import json from "./mod.js" with { "type": "json" };
+import json from "./mod.js" with { "foobar": "json" };
+import json from "./mod.js" with { "type-foo": "json" };
+import json from "./mod.js" with { "333foo": "json" };
+import json from "./mod.js" with { "0": "json" };
+import json from "./mod.js" with { "0n": "json" };
+import json from "./mod.js" with { "33333": "json" };
+import json from "./mod.js" with { "33333n": "json" };
+import json from "./mod.js" with { "33333b": "json" };
+import json from "./mod.js" with { "03333": "json" };
+
+================================================================================
+`;
+
+exports[`quoted-keys.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+                                                                                | printWidth
+=====================================input======================================
+import json from './mod.js' with { "type":"json" };
+import json from './mod.js' with { "foobar":"json" };
+import json from './mod.js' with { "type-foo" :"json" };
+import json from './mod.js' with { "333foo" :"json" };
+import json from './mod.js' with { "0" :"json" };
+import json from './mod.js' with { "0n" :"json" };
+import json from './mod.js' with { "33333" :"json" };
+import json from './mod.js' with { "33333n" :"json" };
+import json from './mod.js' with { "33333b" :"json" };
+import json from './mod.js' with { "03333" :"json" };
+
+=====================================output=====================================
+import json from "./mod.js" with { type: "json" };
+import json from "./mod.js" with { foobar: "json" };
+import json from "./mod.js" with { "type-foo": "json" };
+import json from "./mod.js" with { "333foo": "json" };
+import json from "./mod.js" with { "0": "json" };
+import json from "./mod.js" with { "0n": "json" };
+import json from "./mod.js" with { "33333": "json" };
+import json from "./mod.js" with { "33333n": "json" };
+import json from "./mod.js" with { "33333b": "json" };
+import json from "./mod.js" with { "03333": "json" };
+
+================================================================================
+`;
+
 exports[`re-export.js [acorn] format 1`] = `
 "Unexpected token (1:44)
 > 1 | export { default as foo2 } from "foo.json" with { type: "json" };
@@ -265,6 +933,104 @@ exports[`re-export.js [meriyah] format 1`] = `
 Cause: [1:47]: Unexpected token: 'with'"
 `;
 
+exports[`re-export.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:44)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                            ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: Unexpected token (1:43)"
+`;
+
+exports[`re-export.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:44)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                            ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: Unexpected token with"
+`;
+
+exports[`re-export.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:47)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                               ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: [1:47]: Unexpected token: 'with'"
+`;
+
+exports[`re-export.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+export { default as foo2 } from "foo.json" with { type: "json" };
+export * from "foo.json" with { type: "json" };
+export * as foo3 from "foo.json" with { type: "json" };
+
+=====================================output=====================================
+export { default as foo2 } from "foo.json" with { type: "json" };
+export * from "foo.json" with { type: "json" };
+export * as foo3 from "foo.json" with { type: "json" };
+
+================================================================================
+`;
+
+exports[`re-export.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:44)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                            ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: Unexpected token (1:43)"
+`;
+
+exports[`re-export.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:44)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                            ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: Unexpected token with"
+`;
+
+exports[`re-export.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:47)
+> 1 | export { default as foo2 } from "foo.json" with { type: "json" };
+    |                                               ^
+  2 | export * from "foo.json" with { type: "json" };
+  3 | export * as foo3 from "foo.json" with { type: "json" };
+  4 |
+Cause: [1:47]: Unexpected token: 'with'"
+`;
+
+exports[`re-export.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+export { default as foo2 } from "foo.json" with { type: "json" };
+export * from "foo.json" with { type: "json" };
+export * as foo3 from "foo.json" with { type: "json" };
+
+=====================================output=====================================
+export { default as foo2 } from "foo.json" with { type: "json" };
+export * from "foo.json" with { type: "json" };
+export * as foo3 from "foo.json" with { type: "json" };
+
+================================================================================
+`;
+
 exports[`re-export.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
@@ -307,6 +1073,84 @@ exports[`static-import.js [meriyah] format 1`] = `
 Cause: [1:34]: Unexpected token: 'with'"
 `;
 
+exports[`static-import.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:31)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                               ^
+  2 |
+Cause: Unexpected token (1:30)"
+`;
+
+exports[`static-import.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:31)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                               ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`static-import.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:34)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                                  ^
+  2 |
+Cause: [1:34]: Unexpected token: 'with'"
+`;
+
+exports[`static-import.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import json from "./foo.json" with { type: "json" };
+
+=====================================output=====================================
+import json from "./foo.json" with { type: "json" };
+
+================================================================================
+`;
+
+exports[`static-import.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:31)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                               ^
+  2 |
+Cause: Unexpected token (1:30)"
+`;
+
+exports[`static-import.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:31)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                               ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`static-import.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:34)
+> 1 | import json from "./foo.json" with { type: "json" };
+    |                                  ^
+  2 |
+Cause: [1:34]: Unexpected token: 'with'"
+`;
+
+exports[`static-import.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import json from "./foo.json" with { type: "json" };
+
+=====================================output=====================================
+import json from "./foo.json" with { type: "json" };
+
+================================================================================
+`;
+
 exports[`static-import.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
@@ -345,6 +1189,84 @@ exports[`without-from.js [meriyah] format 1`] = `
 Cause: [1:17]: Unexpected token: 'with'"
 `;
 
+exports[`without-from.js - {"quoteProps":"consistent"} [acorn] format 1`] = `
+"Unexpected token (1:14)
+> 1 | import "foo" with { type: "json" }
+    |              ^
+  2 |
+Cause: Unexpected token (1:13)"
+`;
+
+exports[`without-from.js - {"quoteProps":"consistent"} [espree] format 1`] = `
+"Unexpected token with (1:14)
+> 1 | import "foo" with { type: "json" }
+    |              ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`without-from.js - {"quoteProps":"consistent"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:17)
+> 1 | import "foo" with { type: "json" }
+    |                 ^
+  2 |
+Cause: [1:17]: Unexpected token: 'with'"
+`;
+
+exports[`without-from.js - {"quoteProps":"consistent"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "consistent"
+                                                                                | printWidth
+=====================================input======================================
+import "foo" with { type: "json" }
+
+=====================================output=====================================
+import "foo" with { type: "json" };
+
+================================================================================
+`;
+
+exports[`without-from.js - {"quoteProps":"preserve"} [acorn] format 1`] = `
+"Unexpected token (1:14)
+> 1 | import "foo" with { type: "json" }
+    |              ^
+  2 |
+Cause: Unexpected token (1:13)"
+`;
+
+exports[`without-from.js - {"quoteProps":"preserve"} [espree] format 1`] = `
+"Unexpected token with (1:14)
+> 1 | import "foo" with { type: "json" }
+    |              ^
+  2 |
+Cause: Unexpected token with"
+`;
+
+exports[`without-from.js - {"quoteProps":"preserve"} [meriyah] format 1`] = `
+"Unexpected token: 'with' (1:17)
+> 1 | import "foo" with { type: "json" }
+    |                 ^
+  2 |
+Cause: [1:17]: Unexpected token: 'with'"
+`;
+
+exports[`without-from.js - {"quoteProps":"preserve"} format 1`] = `
+====================================options=====================================
+parsers: ["babel", "typescript"]
+printWidth: 80
+quoteProps: "preserve"
+                                                                                | printWidth
+=====================================input======================================
+import "foo" with { type: "json" }
+
+=====================================output=====================================
+import "foo" with { type: "json" };
+
+================================================================================
+`;
+
 exports[`without-from.js format 1`] = `
 ====================================options=====================================
 parsers: ["babel", "typescript"]
diff --git a/tests/format/js/import-attributes/jsfmt.spec.js b/tests/format/js/import-attributes/jsfmt.spec.js
--- a/tests/format/js/import-attributes/jsfmt.spec.js
+++ b/tests/format/js/import-attributes/jsfmt.spec.js
@@ -1,34 +1,44 @@
+const errors = {
+  acorn: [
+    "dynamic-import.js",
+    "empty.js",
+    "multi-types.js",
+    "static-import.js",
+    "re-export.js",
+    "without-from.js",
+    "non-type.js",
+    "keyword-detect.js",
+    "quoted-keys.js",
+  ],
+  espree: [
+    "dynamic-import.js",
+    "empty.js",
+    "multi-types.js",
+    "static-import.js",
+    "re-export.js",
+    "without-from.js",
+    "non-type.js",
+    "keyword-detect.js",
+    "quoted-keys.js",
+  ],
+  meriyah: [
+    "dynamic-import.js",
+    "empty.js",
+    "multi-types.js",
+    "static-import.js",
+    "re-export.js",
+    "without-from.js",
+    "non-type.js",
+    "keyword-detect.js",
+    "quoted-keys.js",
+  ],
+};
+runFormatTest(import.meta, ["babel", "typescript"], { errors });
 runFormatTest(import.meta, ["babel", "typescript"], {
-  errors: {
-    acorn: [
-      "dynamic-import.js",
-      "empty.js",
-      "multi-types.js",
-      "static-import.js",
-      "re-export.js",
-      "without-from.js",
-      "non-type.js",
-      "keyword-detect.js",
-    ],
-    espree: [
-      "dynamic-import.js",
-      "empty.js",
-      "multi-types.js",
-      "static-import.js",
-      "re-export.js",
-      "without-from.js",
-      "non-type.js",
-      "keyword-detect.js",
-    ],
-    meriyah: [
-      "dynamic-import.js",
-      "empty.js",
-      "multi-types.js",
-      "static-import.js",
-      "re-export.js",
-      "without-from.js",
-      "non-type.js",
-      "keyword-detect.js",
-    ],
-  },
+  quoteProps: "consistent",
+  errors,
+});
+runFormatTest(import.meta, ["babel", "typescript"], {
+  quoteProps: "preserve",
+  errors,
 });
diff --git a/tests/format/js/import-attributes/quoted-keys.js b/tests/format/js/import-attributes/quoted-keys.js
new file mode 100644
--- /dev/null
+++ b/tests/format/js/import-attributes/quoted-keys.js
@@ -0,0 +1,10 @@
+import json from './mod.js' with { "type":"json" };
+import json from './mod.js' with { "foobar":"json" };
+import json from './mod.js' with { "type-foo" :"json" };
+import json from './mod.js' with { "333foo" :"json" };
+import json from './mod.js' with { "0" :"json" };
+import json from './mod.js' with { "0n" :"json" };
+import json from './mod.js' with { "33333" :"json" };
+import json from './mod.js' with { "33333n" :"json" };
+import json from './mod.js' with { "33333b" :"json" };
+import json from './mod.js' with { "03333" :"json" };