📦代码检查(ESLint)没通过,构建失败
Error: 'user' is assigned a value but never used. @typescript-eslint/no-unused-vars
代码能运行,但代码检查工具(ESLint)发现了“需要修改的地方”,把构建停下来了。
🤔 为什么会出现?
- 还留着没用到的变量或 import
- React Hook 的依赖数组漏写了
- 规则设置得很严格
🔧 试试这样做
- 按照报错里写的文件和行号,把没用到的代码删掉
- 比起关掉检查,修好代码更安全
🤖 这样问 AI
构建时因为 ESLint 报错而失败。请不要关闭规则,把报错的代码一个一个正确地修好。 [在这里粘贴构建日志]
把 [ ] 部分换成你的实际情况,报错前后的几行也尽量一起复制粘贴。
相关术语
同一分类的其他报错
- 找不到模块
Module not found: Can't resolve - 找不到命令
command not found - 包版本冲突(ERESOLVE)
npm ERR! ERESOLVE unable to resolve dependency tree - 端口已被占用
EADDRINUSE: address already in use - 类型不匹配(TypeScript)
Type 'X' is not assignable to type 'Y' - 没有权限,安装不了(EACCES)
EACCES: permission denied - Node 版本不匹配
The engine "node" is incompatible with this module - 内存不足(heap out of memory)
JavaScript heap out of memory - 不能使用 import 语句(模块设置)
SyntaxError: Cannot use import statement outside a module - 找不到文件或文件夹(ENOENT)
ENOENT: no such file or directory