[英]How to get eslint in Visual Studio Code to allow double quotes?
Check your .eslintrc.js
file, you can either set the value of the quotes
rule to double
or set the error level to warning
or disable it altogether.检查您的
.eslintrc.js
文件,您可以将quotes
规则的值设置为double
或将错误级别设置为warning
或完全禁用它。 Have a look at the docs .看看文档。 This would be an example:
这将是一个例子:
"rules": {
"quotes": ["error", "double"]
}
quotes: [0, "double"]
对我有用
Sometimes it is cumbersome to find a specific syntax to disallow a specific eslint rule.有时要找到一个特定的语法来禁止特定的 eslint 规则是很麻烦的。 In this situations you can use "global" disabling for a code block as the following:
在这种情况下,您可以对代码块使用“全局”禁用,如下所示:
/*eslint-disable */
//suppress all warnings between comments
console.info("foo");
/*eslint-enable */
If you use the ESLint extension https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint .如果您使用 ESLint 扩展https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint 。
It comes with a command to initialize the .eslintrc file :它带有一个初始化 .eslintrc 文件的命令:
Run Ctrl+Maj+P
then ESLint : Create ESLint configuration
运行
Ctrl+Maj+P
然后ESLint : Create ESLint configuration
In the resulting .eslintrc.js file that has been generated at the root of your Workspace add the quotes: [0, "double"]
line as stated by others.在工作区根目录生成的结果 .eslintrc.js 文件中,添加
quotes: [0, "double"]
行,如其他人所述。
File should look something like this文件应该是这样的
module.exports = {
quotes: [0, "double"]
}
另一种更简单的方法是进入 .eslintignore 文件并在文件末尾添加 * 将为您带来魔力
The following rule will get rid of the double quotes error however then you will start getting single quotes error:以下规则将消除双引号错误,但是您将开始收到单引号错误:
"rules": {
"quotes": ["error", "double"]
}
And if you want to disable the quotes rule then add this:如果您想禁用引号规则,请添加以下内容:
rules: {
quotes: "off"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.