简体   繁体   English

在 Eslint 配置文件中禁用报价规则

[英]Disable quote rule in Eslint config file

I could only find rules to show errors for a double quote, single quote, or backticks.我只能找到规则来显示双引号、单引号或反引号的错误。 Couldn't find a rule to fully disable this quote error.找不到完全禁用此引用错误的规则。 I don't want to see an error no matter what quote is being used in a project.无论项目中使用什么报价,我都不想看到错误。

Hi You can use this rule in the .eslintrc.json file嗨,您可以在.eslintrc.json文件中使用此规则

{
...
   "rules": {
      ...
      "avoidEscape": true,
      "allowTemplateLiterals": true
   }
...
}

There are two options.有两种选择。 You can add these rules inside eslintrc.json您可以在eslintrc.json中添加这些规则

"avoidEscape": true allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise "avoidEscape": true允许字符串使用单引号或双引号,只要字符串包含必须以其他方式转义的引号

"allowTemplateLiterals": true allows strings to use backticks "allowTemplateLiterals": true允许字符串使用反引号

the reference here: https://eslint.org/docs/rules/quotes这里的参考: https://eslint.org/docs/rules/quotes

To completely disable the quotes rule, set it to either 0 or off in your eslint configuration file (see the different configuration formats here ).要完全禁用quotes规则,请在您的 eslint 配置文件中将其设置为0off (请参阅此处的不同配置格式)。
Example for disabling in json configuration file:在 json 配置文件中禁用示例:

{
  "rules": {
    "quotes": "off",
     ...
  }
}

More on disabling rules can be found here .更多关于禁用规则的信息可以在这里找到。

If anyone is coming from react with typescript background you have to use it like below如果有人来自 typescript 背景反应,你必须像下面这样使用它

"rules": {
        "@typescript-eslint/quotes": "off"
}

instead of only using而不是只使用

"rules": {
      "quotes": "off"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM