-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Run prettier based on glob, not languageId #837
Comments
@remcohaszing I tried this trick yesterday and it works pretty well so far: {
"scripts": {
"fix:prettier": "prettier --write \"**/*\"",
"lint:prettier": "prettier --check \"**/*\""
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*": [
"prettier --write",
"git add"
]
},
} ↑ uses Then in ## Please check .eslintignore and .gitignore when changing this file
## file extensions
*.*
LICENSE
!*.js
!*.jsx
!*.json
!*.md
!*.mdx
!*.ts
!*.tsx
!*.yml
## copied from .gitignore
## - npm / yarn
*-debug.log
node_modules
package-lock.json
yarn-error.log
## - temporary local files
build
lib
## shared between eslint and prettier
foo/bar Having extensions (globs) whitelisted in |
This is how the VS Code API works. All formatters are registered based on language ID. One solution is to register the file extensions you are working with as a language that prettier and vscode know about.
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When prettier is run in CI, it looks somewhat like this:
yarn prettier --check '**/*.{html,json,md,scss,yaml,yml}'
However, in VSCode, prettier runs based on the
languageId
. This means there is an inconsistent behaviour between running prettier in CI and in the editor. (This applies on other plugins, such as ESLint, as well. IMHO this is incorrect behaviour.)A practical example:
I recently installed the Kubernetes extension. This means prettier VSCode no longer runs on my Helm chart files, as their language id is now
helm
. In CI, Prettier is being run, because the files are namedFoo.yaml
.I suggest to add a glob option. This makes prettier run based on file globs instead of language ids. This will allow VSCode prettier to run on files, even if plugins use different language ids. This would also implicitly fix #757.
The text was updated successfully, but these errors were encountered: