怪异的:Eslint为使用的变量增加了no-unused-var

时间:2019-09-12 03:40:11

标签: reactjs create-react-app eslint

我有这段代码:

for(const physicalEffect of deleteSolution.physicalEffects) {
        const { solutions } = cache.readQueryNoThrow({
          query: solutionsQuery,
          variables: {
            projectId: project.id,
            physicalEffect: physicalEffect.id,
            engineeringArticle: null,
            biologyArticle: null
          }
        })
        solutions && cache.writeQuery({
          query: solutionsQuery,
          variables: {
            projectId: project.id,
            physicalEffect: physicalEffect.id,
            engineeringArticle: null,
            biologyArticle: null
          },
          data: {
            solutions: solutions.filter(({ id }) => id !== deleteSolution.id)
          }
        })
      }

使用create-react-app,react-app-rewired和custom-cra,我有以下.eslintrc

{
  "extends": "react-app",
  "rules": {
    "jsx-a11y/anchor-is-valid": 0,
    "react-hooks/exhaustive-deps": 0
  }
}

我收到此警告:

Compiled with warnings.

./src/pages/project/solution/Editor.js
  Line 60:   'physicalEffect' is defined but never used      no-unused-vars

第60行指的是我上面的代码示例的第一行。该警告由physicalEffect循环中的for ... of声明引起。

到底发生了什么?

0 个答案:

没有答案