eslint提示'React' is defined but never used

本文介绍在React项目中遇到的eslint报错'React'isdefinedbutneverused的解决方案。通过在.eslintrc.js文件中配置特定的rule,可以有效避免此问题,确保项目代码符合规范。

使用eslint --init进行基础的设置后,在React项目中发现如下报错提示
'React' is defined but never used
.eslintrc.js文件中配置如下rule即可
"react/jsx-uses-react": 2

E:\gitlab\3dplus\src\init-settings.js 171:10 warning 'generateReflectionMapFromImage' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars 264:43 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 269:40 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 276:39 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 280:43 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 284:42 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 288:42 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 292:41 warning 'value' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars 296:10 warning 'setReflectionIntensity' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars E:\gitlab\3dplus\src\mode-manager.js 50:45 warning 'mode' is defined but never used. Allowed unused args must match /^_/u unused-imports/no-unused-vars E:\gitlab\3dplus\src\save-material.js 148:21 error Empty block statement no-empty 171:11 warning 'emissivePercent' is assigned a value but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars ✖ 17 problems (5 errors, 12 warnings) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 报错原因以及如何解决
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值