【发布时间】:2022-01-26 20:15:06
【问题描述】:
我有一个使用 create-react-app 创建的 react 应用程序,并且正在使用 react-scripts 版本 3.4.2。该应用程序运行良好,但是当我对它运行 eslint 时,我收到许多无效的 no-unused-vars 错误。无效是指当我转到文件时,实际上正在使用该变量。
基于this answer,问题似乎与@typescript-eslint/parser 和@typescript-eslint/eslint-plugin 有关。所以我继续在我的应用程序上执行npm list @typescript-eslint/parser @typescript-eslint/eslint-plugin,这就是我得到的:
myapp@0.1.0 /Users/diego/myapp/client
└─┬ react-scripts@3.4.2
├─┬ @typescript-eslint/eslint-plugin@2.34.0
│ └── @typescript-eslint/parser@2.34.0 deduped
├── @typescript-eslint/parser@2.34.0
└─┬ eslint-config-react-app@5.2.1
├── @typescript-eslint/eslint-plugin@2.34.0 deduped
└── @typescript-eslint/parser@2.34.0 deduped
正如所见,所有出现的两个潜在冲突库都包含在 react-scripts 应用程序中,这就是我尝试更新它的原因。
我尝试更新到 4.0.3,当我这样做时,eslint 开始正常工作(那些不正确的 no-unused-vars 消失了)但我的应用程序没有响应(我点击不同的按钮和/或链接,但没有任何反应) .更新后我在控制台中看到的唯一错误是这个:
Uncaught ReferenceError: process is not defined
at Object.4043 (<anonymous>:2:13168)
at r (<anonymous>:2:306599)
at Object.8048 (<anonymous>:2:9496)
at r (<anonymous>:2:306599)
at Object.8641 (<anonymous>:2:1379)
我正在搜索这个错误,我找到了this question。错误可能与开发人员所描述的不同,但通读答案后,我看到其中许多人指出反应脚本是根本原因,这与我的情况相符。
我尝试了该问题中的一些解决方案,特别是 this answer 的方法 1(我没有尝试方法 2,因为我不确定添加 craco 是否是我想要的)以及 this other answer 的解决方案,但是它们不起作用。
我也尝试更新到 react-scripts 版本 5,但出现很多错误。
是否有人面临这个问题,或者至少有一些线索可以帮助我?
提前致谢。
【问题讨论】:
标签: eslint create-react-app react-scripts