trivago / prettier-plugin-sort-imports

A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order.
Apache License 2.0
3.37k stars 133 forks source link

Bun could not run prettier cli, crashed with the error #289

Open seitbekir opened 7 months ago

seitbekir commented 7 months ago

Your Environment

Describe the bug

I got an error trying to run script via package.json.

To Reproduce

add script "prettier": "prettier . --write"

... workdir % bun add --dev @trivago/prettier-plugin-sort-imports
... workdir % bun run prettier
$ prettier . --write
[error] Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "StringLiteral"
error: script "prettier" exited with code 1

Expected behavior

Formatting should run.

Screenshots, code sample, etc

See above

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

{
    "tabWidth": 4,
    "useTabs": false,
    "semi": true,
    "singleQuote": true,
    "trailingComma": "all",
    "bracketSpacing": true,
    "arrowParens": "always",
    "endOfLine": "lf",
    "plugins": ["@trivago/prettier-plugin-sort-imports"],
    "importOrder": [
        "^@/types/(.*)$",
        "^@/data/(.*)$",
        "^@/assets/(.*)$",
        "^[../]",
        "^[./]"
    ],
    "importOrderSeparation": true,
    "importOrderSortSpecifiers": true,
    "importOrderParserPlugins": ["typescript", "jsx"]
}

Error log

... workdir % bun prettier --log-level debug
$ prettier . --write --log-level debug
[debug] normalized argv: {"":["."],"cache":false,"color":true,"editorconfig":true,"write":true,"logLevel":"debug","configPrecedence":"cli-override","debugRepeat":0,"ignorePath":[".gitignore",".prettierignore"],"plugins":[],"_":["."],"__raw":{"_":["."],"cache":false,"color":true,"editorconfig":true,"write":true,"log-level":"debug","config-precedence":"cli-override","debug-repeat":0,"ignore-path":[".gitignore",".prettierignore"],"plugin":[]}}
[debug] resolve config from '/Users/macbookair13/node-dev/shiplog/.editorconfig'
[debug] loaded options `{"useTabs":false,"tabWidth":4,"endOfLine":"lf","semi":true,"singleQuote":true,"trailingComma":"all","bracketSpacing":true,"jsxBracketSameLine":false,"arrowParens":"always","plugins":["@trivago/prettier-plugin-sort-imports"],"importOrder":["^@/types/(.*)$","^@/data/(.*)$","^@/assets/(.*)$","^[../]","^[./]"],"importOrderSeparation":true,"importOrderSortSpecifiers":true,"importOrderParserPlugins":["typescript","jsx"]}`
[error] Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "StringLiteral"
error: script "prettier" exited with code 1

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