我正在做一个Angular项目,最近开始使用VSCode。我用的是更漂亮的扩展(版本:1.19.1 ),它工作得很好,唯一的问题是它不允许写需要的正则表达式。保存后,漂亮地将单引号改为双引号并删除反斜杠。
例如:
>
'^[a-zA-Z\-\']'
变为“^[a-zA-Z-']”
/^\-?\d ((\.|\,)\
d )?$/ 变为 /^-?d ((.|,)d )?$/
已安装 VSCode 扩展
我遵循了许多指示,例如添加.feightrrc
文件,更改settings.json
中的配置,但这些都没有帮助。
这是我的< code>.prettierrc.json文件:
{
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
这是< code>settings.json文件:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true,
"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"razor": "html",
"plaintext": "jade"
},
"emmet.preferences": {
"css.webkitProperties": "border-right,animation",
"css.mozProperties": "",
"css.oProperties": null,
"css.msProperties": null
},
"[javascript]": {
"editor.formatOnSave": true
},
"workbench.iconTheme": "seti"
}
这是tslint.json
文件:
rules : {
...
"quotemark": [true, "single"],
...
}
. editorconfig
文件
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
我做错了什么?
你可以查看https://stackoverflow.com/search?q=double引用视觉工作室有vs截图和解释。我强调这个问题已经问过了。
你必须写\\让编辑留下一个,根据这个答案,4换2:https://github.com/prettier/prettier/issues/2789
我希望它有帮助!