【发布时间】:2021-10-31 17:48:00
【问题描述】:
我刚刚按照一些开发人员的建议在我的项目中安装了 Prettier,但我在配置它时遇到了一些问题。
当我安装它时,在第一种格式上,VS Code 询问我要使用哪个格式器(在 tslint 和 prettier 之间),所以我选择了 prettier。
但是现在,当我创建 .ts 文件时,我会收到 tslint 的警告,例如:
@Injectable({
providedIn: "root",
})
这是真的,我想在我的项目中使用单引号。然后当我把它改成
@Injectable({
providedIn: 'root',
})
它再次被双引号替换。
我去过设置并尝试将引用的每个引用更改为单引号,在我的设置文件中以这个结尾:
{
"git.autofetch": true,
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",
"git.enableSmartCommit": true,
"workbench.iconTheme": "material-icon-theme",
"git.postCommitCommand": "sync",
"git.pruneOnFetch": true,
"git.confirmSync": false,
"files.autoSaveDelay": 2000,
"workbench.colorTheme": "Atom One Light",
"html.format.wrapAttributes": "force-aligned",
"html.format.wrapAttributesIndentSize": 120,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.singleQuote": true,
"prettier.jsxSingleQuote": true,
}
但是,当我保存时,单引号会被双引号替换。
我错过了什么,为什么 prettier 一直尝试使用双引号?
【问题讨论】:
-
这可能是您的 .editorconfig 文件中的设置。以前发生在我身上
标签: angular visual-studio-code tslint prettier