eyea / afu-eslint-rule

eslint rule 配置
0 stars 0 forks source link

【note】taro plugin:react/jsx-runtime eslint-plugin-react-hooks #12

Open eyea opened 9 months ago

eyea commented 9 months ago

环境:


"@afuteam/eslint-plugin-fe": "^1.0.0",

pnpm 8.6.12

"volta": {
  "node": "18.17.1"
}

"@tarojs/components": "3.6.20",
"@tarojs/helper": "3.6.20",
"@tarojs/plugin-framework-react": "3.6.20",
"@tarojs/plugin-platform-alipay": "3.6.20",
"@tarojs/plugin-platform-h5": "3.6.20",
"@tarojs/plugin-platform-jd": "3.6.20",
"@tarojs/plugin-platform-qq": "3.6.20",
"@tarojs/plugin-platform-swan": "3.6.20",
"@tarojs/plugin-platform-tt": "3.6.20",
"@tarojs/plugin-platform-weapp": "3.6.20",
"@tarojs/react": "3.6.20",
"@tarojs/runtime": "3.6.20",
"@tarojs/shared": "3.6.20",
"@tarojs/taro": "3.6.20",

.eslintrc文件内容

{
  // 省略其他配置
  "plugins": [
    "@afuteam/fe"
  ],
  "extends": [
    "taro/react",
    "plugin:@afuteam/fe/js",
    "plugin:@afuteam/fe/react",
    "plugin:@afuteam/fe/ts5"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "rules": {
    "react/jsx-uses-react": "off",
    "react/react-in-jsx-scope": "off"
  }
}

报错: ESLint couldn't find the config "plugin:react/jsx-runtime" to extend from. Please check that the name of the config is correct.

首先,根据 npm包说明 打开备注,把对应的依赖看下是不是建议的;

在本机可以成功运行lint,但在同事机器仍然报上述错误,怀疑可能是依赖问题

rm -rf node_modules
rm -rf pnpm-lock.yaml
pnpm store prune
pnpm install

仍然报错,那么参考下面: 其次:根据 https://github.com/nrwl/nx/issues/8660#issuecomment-1024834690 提到「I checkhed that "eslint-plugin-react-hooks": "4.3.0" is installed which might fix the issue, in my project I used v 4.2 which I then upgraded to 4.2.1-rc and the issue gone」

得到解决。


上面匆忙处理,感觉整体下来怪怪的。