我在VS Code中使用扩展Prettier。我想要在代码中使用双引号。 “ jsxSingleQuote”和“ singleQuote”设置为false。
当我在此行代码上运行格式
var hello = "\"hello\"";
漂亮的将其格式化为:
var hello = '"hello"';
我想保留双引号,并且不应格式化代码行!
以下是设置:
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"filepath": "..../app.js",
"parser": "babel"
}
答案 0 :(得分:1)
这是预期的。来自https://github.com/prettier/prettier/tree/21733e441dc01f7d85b483edee92b7e7507bfd9a#quotes:
答案 1 :(得分:0)
尝试在根级别创建文件.prettierrc
,即同级package.json,并将属性singleQuote
设置为true,如下所示:
{
"singleQuote": true
}