Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier crashes when importing json and asserting json type #618

Open
harshmandan opened this issue Feb 16, 2024 · 3 comments
Open

Prettier crashes when importing json and asserting json type #618

harshmandan opened this issue Feb 16, 2024 · 3 comments
Labels
bug Something isn't working es-lint

Comments

@harshmandan
Copy link

harshmandan commented Feb 16, 2024

Describe the bug

When I try to import a json file inside a .js/.ts file and try to save it prettier crashes.

Severity

blocking an upgrade

Steps to Reproduce the Bug

Here's a sample file:

import firebaseJSON from '../../../firebase.json' assert { type: 'json' }

...

setKeys(firebaseJSON.emulators)

Saving this results in a crash with following log:

["ERROR" - 13:11:35] Error formatting document.
SyntaxError: This experimental syntax requires enabling one of the following parser plugin(s): "importAttributes", "importAssertions". (1:35)
...

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-6f9a3r?file=package.json,src%2Flib%2Futils%2Ftest.ts

To see the error you'll need to download the project and run it locally. All you have to do is try to save and format the lib/utils/test.ts file with prettier.

@jycouet
Copy link
Owner

jycouet commented Feb 16, 2024

Thx for reporting, I'll have a look.

@jycouet
Copy link
Owner

jycouet commented Feb 18, 2024

I can reproduce 👍
But didn't manage to find an easy fix :/

@jycouet jycouet added es-lint bug Something isn't working labels Mar 11, 2024
@jycouet
Copy link
Owner

jycouet commented Mar 14, 2024

It's linked to trivago/prettier-plugin-sort-imports#270

Even if I'm using a fork https://github.com/IanVS/prettier-plugin-sort-imports coming from https://github.com/the-guild-org/shared-config/blob/main/packages/prettier-config/package.json#L24

Deps hell :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working es-lint
Projects
None yet
Development

No branches or pull requests

2 participants