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

Plugin is conflicting with the typescript/javascript plugin #78

Open
hinogi opened this issue Feb 20, 2024 · 4 comments
Open

Plugin is conflicting with the typescript/javascript plugin #78

hinogi opened this issue Feb 20, 2024 · 4 comments

Comments

@hinogi
Copy link

hinogi commented Feb 20, 2024

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
Copy link
Member

What does your dprint.json config look like?

@sschneider-ihre-pvs
Copy link

sschneider-ihre-pvs commented Feb 21, 2024

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
Copy link
Member

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
Copy link
Author

hinogi commented Feb 24, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants