我在 VS Code 中使用 Prettier 扩展。我想在代码中使用双引号。 “jsxSingleQuote”和“singleQuote”设置为 false。
当我在这行代码上运行 format 时
var hello = "\"hello\"";
Prettier 将其格式化为:
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"
}
这正如预期的那样。从https://github.com/prettier/prettier/tree/21733e441dc01f7d85b483edee92b7e7507bfd9a#quotes https://github.com/prettier/prettier/tree/21733e441dc01f7d85b483edee92b7e7507bfd9a#quotes:
- 如果报价数量超过其他报价,则该报价为
lessused 将用于格式化字符串 - 示例:“I'm double
引用”导致“我被双引号引用”和“这个“例子”是
单引号”导致“此“示例”是单引号”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)