kitql
kitql copied to clipboard
Prettier crashes when importing json and asserting json type
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.
Thx for reporting, I'll have a look.
I can reproduce 👍 But didn't manage to find an easy fix :/
It's linked to https://github.com/trivago/prettier-plugin-sort-imports/issues/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 :/