[英]Why is VSCode suddenly only formatting my files partially? (Using ESLint + Prettier)
All of a sudden, VSCode ignores my semi-colon rule and whitespaces rule, but only enforces tabs and spacing when I save my Typescript files.突然之间,VSCode 忽略了我的分号规则和空格规则,但只在我保存 Typescript 文件时强制执行制表符和空格。
I'm using both ESLint and prettier.我同时使用 ESLint 和 prettier。
For instance, my Prettier has semi set to true in VSCode例如,我的 Prettier 在 VSCode 中将 semi 设置为 true
I also have this on my prettierrc file.我的 prettierrc 文件中也有这个。 Note the "semi: true".
注意“半:真”。
module.exports = {
arrowParens: "always",
printWidth: 80,
singleQuote: false,
jsxSingleQuote: false,
semi: true,
trailingComma: "all",
tabWidth: 2,
plugins: [require.resolve("prettier-plugin-tailwindcss")],
tailwindConfig: "./packages/config/tailwind",
};
But semi-colons aren't added to my Typescript files.但是分号没有添加到我的 Typescript 文件中。
I tried making sure that Prettier is my default formatter我尝试确保 Prettier 是我的默认格式化程序
I checked that "Format on Save is turned on"我检查了“保存时的格式已打开”
None of these seem to automatically add the semi-colon despite having "semi: true" in settings.尽管在设置中有“半:真”,但这些似乎都没有自动添加分号。
The interesting thing is that the my spacing=2 tabs are enforced when I hit save, so Prettier seems to be working.有趣的是,当我点击保存时,我的 spacing=2 选项卡被强制执行,所以 Prettier 似乎在工作。
It turns out that under my settings.json (Command+Shift+P, type settings and hit "Preferences: Open User Settings (JSON)", my Typescript default formatter was changed to "vscode.typescript-language-features" instead of "esbenp.prettier-vscode") I must have toggled the settings accidentally through the VSCode status bar.事实证明,在我的设置下。json(Command+Shift+P,键入设置并点击“首选项:打开用户设置(JSON)”,我的 Typescript 默认格式化程序已更改为“vscode.typescript-language-features”而不是“ esbenp.prettier-vscode") 我一定是不小心通过 VSCode 状态栏切换了设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.