VSCode Prettier Extension 与 Prettier CI(Svelte)
VSCode Prettier Extension vs Prettier CI (Svelte)
出于某种原因,我的保存格式给出的结果与我 运行 以下命令时不同:
prettier --write src/pages/file.svelte`
格式之间的区别在于使用 --write
命令插入新行。无论如何要检查为什么会这样?
.vscode/settings.json
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
.prettierrc
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"singleQuote": false,
"useTabs": true,
"tabWidth": 2,
"printWidth": 120,
"semi": true,
"trailingComma": "all",
"svelteSortOrder": "styles-scripts-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": true,
"svelteAllowShorthand": false,
"plugins": ["./node_modules/prettier-plugin-svelte"]
}
感谢@dummdidumm 的回答
Prettier did a breaking change to the library and prettier-plugin-svelte had to work around that in a newer version.
将 prettier-plugin-svelte
更新为 ^2.4.0
解决了该问题。
出于某种原因,我的保存格式给出的结果与我 运行 以下命令时不同:
prettier --write src/pages/file.svelte`
格式之间的区别在于使用 --write
命令插入新行。无论如何要检查为什么会这样?
.vscode/settings.json
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
.prettierrc
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"singleQuote": false,
"useTabs": true,
"tabWidth": 2,
"printWidth": 120,
"semi": true,
"trailingComma": "all",
"svelteSortOrder": "styles-scripts-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": true,
"svelteAllowShorthand": false,
"plugins": ["./node_modules/prettier-plugin-svelte"]
}
感谢@dummdidumm 的回答
Prettier did a breaking change to the library and prettier-plugin-svelte had to work around that in a newer version.
将 prettier-plugin-svelte
更新为 ^2.4.0
解决了该问题。