prettier-vscode: Extension doesn't ignore formatting for gitignored files
Summary
prettier 3.0 introduced ignoring gitignored files by default, however the vscode extension doesn’t ignore them, unlike .prettierignored files. Using the prettier cli to format works fine
Github Repository to Reproduce Issue
https://github.com/h-projects/gasbot/tree/59d05a8df6a72a92a84fd0273e29c23e191eb2e7 (.prettierignore file is still in there)
Steps To Reproduce:
- Have a
.prettierignorefile and a.gitignorefile, both with the same contents - Enable formatting on save (with the extension) in vscode
- Try to modify and save a file mentioned in
.prettierignore(it doesn’t get formatted, good) - Delete the
.prettierignorefile - Try to save the same file
Expected result
The file doesn’t get formatted, just like if .prettierignore was present
Actual result
The file gets formatted
Additional information
VS Code Version: 1.79.2
Prettier Extension Version: 9.19.0
OS and version: Windows 10 22H2, prettier 3.0.0
Prettier Log Output
Before removing `.prettierignore`
["INFO" - 12:36:11 PM] Formatting file:///c%3A/Users/Superchupu/OneDrive/Documentos/Programaci%C3%B3n/discordbot/gasbot/dist/index.js
["INFO" - 12:36:11 PM] Using config file at 'c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierrc.json'
["INFO" - 12:36:11 PM] PrettierInstance:
{
"modulePath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\node_modules\\prettier\\index.cjs",
"importResolver": {},
"callMethodResolvers": {},
"currentCallMethodId": 48,
"version": "3.0.0"
}
["INFO" - 12:36:11 PM] Using ignore file (if present) at c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierignore
["INFO" - 12:36:11 PM] File Info:
{
"ignored": true,
"inferredParser": null
}
["INFO" - 12:36:11 PM] File is ignored, skipping.
After removing the `.prettierignore` file, but still having the affected file gitignored
["INFO" - 12:32:52 PM] Formatting file:///c%3A/Users/Superchupu/OneDrive/Documentos/Programaci%C3%B3n/discordbot/gasbot/dist/index.js
["INFO" - 12:32:52 PM] Using config file at 'c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierrc.json'
["INFO" - 12:32:52 PM] PrettierInstance:
{
"modulePath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\node_modules\\prettier\\index.cjs",
"importResolver": {},
"callMethodResolvers": {},
"currentCallMethodId": 41,
"version": "3.0.0"
}
["INFO" - 12:32:52 PM] Using ignore file (if present) at c:\Users\Superchupu\OneDrive\Documentos\Programación\discordbot\gasbot\.prettierignore
["INFO" - 12:32:52 PM] File Info:
{
"ignored": false,
"inferredParser": "babel"
}
["INFO" - 12:32:52 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 12:32:52 PM] Prettier Options:
{
"filepath": "c:\\Users\\Superchupu\\OneDrive\\Documentos\\Programación\\discordbot\\gasbot\\dist\\index.js",
"parser": "babel",
"arrowParens": "avoid",
"endOfLine": "auto",
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none"
}
["INFO" - 12:32:52 PM] Formatting completed in 13ms.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 22 (4 by maintainers)
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
This is a bigger task than it seems. This extension relies on the Prettier API, but since there were issues integrating with Prettier v3, they had to revert back to Prettier v2. This won’t be fixed until Prettier v3 is supported again.
still not fixed
It looks like for now, we have only 2 options:
.gitignoreand.prettierignoreprettier-vscodethat usesprettier@3API required to ignore gitignored files)This is still an issue. The extension should be consistent with the prettier cli.
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.