Skip to content

Conversation

@sosukesuzuki
Copy link
Contributor

Description

Since resolving conflicts is annoying, I created a new PR.

Closes #15564
Fixes #15563

Checklist

  • 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.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@sosukesuzuki sosukesuzuki requested a review from fisker January 7, 2024 15:27
Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need update logic in

function printPropertyKey(path, options, print) {
, number/bigint can't be unquoted. #15563 (comment)

Prettier pr-15888
Playground link

--parser babel

Input:

import json from "./mod.json" with { "0": "json" };

Output:

import json from "./mod.json" with { 0: "json" };

Second Output:

SyntaxError: Unexpected token (1:38)
> 1 | import json from "./mod.json" with { 0: "json" };
    |                                      ^
  2 |

@sosukesuzuki sosukesuzuki requested a review from fisker January 8, 2024 06:06
Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug with --prose-wrap always --quote-props consistent

Prettier pr-15888
Playground link

--parser typescript
--quote-props consistent
--prose-wrap always

Input:

import json from "./mod.json" with { "type": "json" };

Output:

TypeError: Cannot read properties of undefined (reading 'some')
    at ft (https://deploy-preview-15888--prettier.netlify.app/lib/plugins/estree.js:36:29755)
    at hs (https://deploy-preview-15888--prettier.netlify.app/lib/plugins/estree.js:36:30369)
    at Ta (https://deploy-preview-15888--prettier.netlify.app/lib/plugins/estree.js:36:58094)
    at Vl (https://deploy-preview-15888--prettier.netlify.app/lib/plugins/estree.js:36:72252)
    at Object.Hl (https://deploy-preview-15888--prettier.netlify.app/lib/plugins/estree.js:36:72660)
    at Yn (https://deploy-preview-15888--prettier.netlify.app/lib/standalone.js:27:1809)
    at D (https://deploy-preview-15888--prettier.netlify.app/lib/standalone.js:27:1629)
    at s (https://deploy-preview-15888--prettier.netlify.app/lib/standalone.js:27:1437)
    at https://deploy-preview-15888--prettier.netlify.app/lib/standalone.js:15:4072
    at bt.each (https://deploy-preview-15888--prettier.netlify.app/lib/standalone.js:15:3975)

Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by mistake

@sosukesuzuki sosukesuzuki force-pushed the fix-import-attributes-key-print-2 branch from 6682e45 to e2c5580 Compare January 12, 2024 16:05
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" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need more tests for different --quote-props options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fisker fisker changed the title Safely remove quotes from keys in Import Attributes Unquote keys in import attributes Feb 7, 2024
@fisker fisker merged commit a642ecb into prettier:main Feb 7, 2024
@sosukesuzuki sosukesuzuki deleted the fix-import-attributes-key-print-2 branch February 7, 2024 06:57
@fisker
Copy link
Member

fisker commented Feb 7, 2024

Something is not right... I'll fix.

@kachkaev
Copy link
Member

kachkaev commented Jun 2, 2024

Related issue: #16340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove quotes in import attribute

3 participants