dprint / dprint-plugin-prettier

Prettier wrapper plugin for dprint.
Other
96 stars 8 forks source link

Plugin is conflicting with the typescript/javascript plugin #78

Open hinogi opened 7 months ago

hinogi commented 7 months ago

If I leave the typescript settings empty but add "singleQuote": true to the prettier config in the dprint.json the default typescript double quote will overrule the prettier settings every time.

dsherret commented 7 months ago

What does your dprint.json config look like?

sschneider-ihre-pvs commented 7 months ago

cat .\dprint.json

{
  "typescript": {
  },
  "json": {
  },
  "markdown": {
  },
  "toml": {
  },
  "prettier": {
    "singleQuote": true,
    "plugin.jsDoc": true,
    "printWidth": 120,
    "trailingComma": "all",
    "arrowParens": "always",
    "semi": true
  },
  "excludes": [
    "**/node_modules",
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.89.1.wasm",
    "https://plugins.dprint.dev/json-0.19.1.wasm",
    "https://plugins.dprint.dev/markdown-0.16.3.wasm",
    "https://plugins.dprint.dev/toml-0.6.0.wasm",
    "https://plugins.dprint.dev/prettier-0.38.1.json@ae9b60b1ca7e22223cb47325b3d42c681444b46863d28ed92edc426f8a177e58"
  ]
}

but it only works correctly like this

{
  "prettier": {
    "singleQuote": true,
    "plugin.jsDoc": true,
    "printWidth": 120,
    "trailingComma": "all",
    "arrowParens": "always",
    "semi": true
  },
  "excludes": [
    "**/node_modules",
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/prettier-0.38.1.json@ae9b60b1ca7e22223cb47325b3d42c681444b46863d28ed92edc426f8a177e58"
  ]
}
dsherret commented 7 months ago

That will use the typescript plugin for formatting typescript files because it has higher precedence than prettier in the plugins array. You can change the typescript plugin to single quotes by doing:

{
  "typescript": {
    "quoteStyle": "preferSingle"
  }
  // etc...
}

Or you can just not use it and only use prettier by removing the "typescript" config key and removing it from the plugins array.

hinogi commented 7 months ago

I wasn't aware that the array is ordered by priority. So would it make sense to put typescript at the bottom and prettier at the top so that anything prettier does not cover has a fallback of for example typescript lsp or so?