trivago/prettier-plugin-sort-imports

Unexpected token for import attribute "with"

Closed this issue · 1 comments

Your Environment

  • Prettier version: 3.2.5
  • node version 20.13.1:
  • package manager: npm@10.5.2
  • IDE: Webstorm

Describe the bug

Error if using import attribute with:

SyntaxError: Unexpected token, expected "{"

To Reproduce

import something from './something.json' with { type: 'json' };

https://v8.dev/features/import-attributes#deprecation-and-eventual-removal-of-assert

Expected behavior

Formatting works as for assert with importAssertions

import something from './something.json' assert { type: 'json' };

Screenshots, code sample, etc

see above

Configuration File (.prettierrc)

{
  "plugins": ["@trivago/prettier-plugin-sort-imports"],
  "singleQuote": true,
  "trailingComma": "es5",
  "importOrder": ["<THIRD_PARTY_MODULES>", "^@company/(.*)$", "^[./]"],
  "importOrderParserPlugins": ["typescript", "decorators-legacy", "importAttributes"],
  "importOrderSeparation": true,
  "importOrderSortSpecifiers": true
}

Error log

✖ prettier --write:
[error] script.mjs: SyntaxError: Unexpected token, expected "{" (2:58)
[error] 1 | import something from './something.json' assert { type: 'json' };

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇

Probably duplicate of #270