【问题标题】:Trying to disable no-template-curly-in-string ESlint rule on my project尝试在我的项目中禁用 no-template-curly-in-string ESlint 规则
【发布时间】:2020-08-26 18:18:52
【问题描述】:

收到此错误

./src/locale/translations.js
  Line 4:5:   Unexpected template string expression  no-template-curly-in-string
  Line 6:13:  Unexpected template string expression  no-template-curly-in-string

并试图为整个项目禁用:

// .eslintrc
{
    "rules": {
        "no-template-curly-in-string": "off",
        "template-curly-in-string": "off"
        // "no-template-curly-in-string": 0,
        // "template-curly-in-string": 0
        // "no-template-curly-in-string": false,
        // "template-curly-in-string": false
    }
}

这些都不起作用。

【问题讨论】:

  • "no-template-curly-in-string": "off", 应该可以工作,您确定正在加载配置文件吗?如果您将其命名为 .eslintrc.json per the docs,会怎样?
  • 我正在使用 create-react-app,老实说,我不确定 eslintrc 文件是否正在加载。尝试使用 .eslintrc.json 但仍然无法正常工作。
  • 更多上下文:stackoverflow.com/questions/60290876/… 我认为更多是 CRA 的问题而不是 ESLint。谢谢你们的cmets。

标签: eslint


【解决方案1】:

尝试更新到 react-scripts@4.0.0,因为我在之前的 3.X.X 版本中发现了一个 issue,其中忽略了 eslint。

更新:

npm install --save --save-exact react-scripts@4.0.0

yarn add --exact react-scripts@4.0.0

这适用于我的情况;)

【讨论】:

    【解决方案2】:

    我可以通过以下方式禁用它:

    // package.json

      "eslintConfig": {
        "extends": "react-app",
        "rules": {
          "no-template-curly-in-string": "off"
        }
    

    诀窍是在更新 package.json 后将EXTEND_ESLINT=true 添加到我的环境文件中,然后重新启动我的服务器。

    【讨论】:

      猜你喜欢
      • 2021-08-26
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 2021-12-10
      • 2018-11-01
      • 2021-10-16
      • 2021-07-13
      • 2023-02-02
      相关资源
      最近更新 更多