【问题标题】:ESLint configuration in package.json » eslint-config-react-app is invalid:package.json » eslint-config-react-app 中的 ESLint 配置无效:
【发布时间】:2022-01-07 10:29:55
【问题描述】:
  • “覆盖”属性的类型错误(预期为数组,但得到了{"files":["**/*.ts","**/*.tsx"],"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":2018,"sourceType":"module","ecmaFeatures":{"jsx":true},"warnOnUnsupportedTypeScriptVersion":true},"plugins":["@typescript-eslint"],"rules":{"default-case":"off","no-dupe-class-members":"off","@typescript-eslint/no-angle-bracket-type-assertion":"warn","no-array-constructor":"off","@typescript-eslint/no-array-constructor":"warn","@typescript-eslint/no-namespace":"error","no-unused-vars":"off","@typescript-eslint/no-unused-vars":["warn",{"args":"none","ignoreRestSiblings":true}],"no-useless-constructor":"off","@typescript-eslint/no-useless-constructor":"warn"}})。

引用自:D:{app folder}{app name}\package.json

【问题讨论】:

  • 错误信息中有什么不清楚的地方? "overrides" 需要一个数组 [...] 但得到一个对象 {...}
  • 我克隆了这个 repo,当我执行 npm start 时,我遇到了这个问题,你能帮帮我吗
  • 你克隆了 what repo,你为什么不把它和维护它的人一起提出来呢?如果您在这里问我们需要minimal reproducible example - 我建议使用tour 并阅读How to Ask

标签: typescript eslint


【解决方案1】:

在我的 Create React App 项目中更新 react-scripts 时,我实际上遇到了同样的问题。我要解决的步骤是。

  • 删除package-lock.json
  • 删除node_modules
  • devDependencies 中的package.json 中删除eslint 依赖项
  • 运行npm cache clear --force
  • npm install
  • npm install 最新版本的 eslint 软件包您删除回您的 devDependencies
  • 重新启动您的项目,看看它是否已修复。

这对我有用。

更新:我实际上在安装 React Scripts 5 时删除它们后不需要安装 eslint。它似乎在引擎盖下使用它。

【讨论】:

    猜你喜欢
    • 2020-02-28
    • 1970-01-01
    • 2021-05-04
    • 2019-10-24
    • 2017-12-01
    • 1970-01-01
    • 2022-01-19
    • 2022-08-10
    • 2022-01-20
    相关资源
    最近更新 更多