[英]Enable react-hooks/exhaustive-deps in Gatsby
How can I enable react-hooks/exhaustive-deps warnings in Gatsby?如何在 Gatsby 中启用 react-hooks/exhaustive-deps 警告? My question is about Gatsby projects, I have no problem in React projects
我的问题是关于 Gatsby 项目,我在 React 项目中没有问题
I know that eslint-plugin-react-hooks
is installed.In my .eslintrc
file I added these changes but not working我知道
eslint-plugin-react-hooks
已安装。在我的.eslintrc
文件中,我添加了这些更改但没有工作
rules
I added "react-hooks/exhaustive-deps": "warn",
rules
中我添加了"react-hooks/exhaustive-deps": "warn",
plugins
I added "react-hooks",
plugins
中我添加了"react-hooks",
Here you can find a configuration I'm using with exhaustive-deps
and it's working. 在这里你可以找到我正在使用的
exhaustive-deps
,并且它正在工作。 Summarized it looks like:总结如下:
module.exports = {
globals: {
__PATH_PREFIX__: true
},
root: true,
rules: {
'react-hooks/rules-of-hooks': `warn`,
'react-hooks/exhaustive-deps': `warn`,
'react/react-in-jsx-scope': `off`,
},
env: {
'amd': true,
'browser': true,
'commonjs': true,
'es6': true,
'jest': true,
'node': true
},
extends: [
`react-app`,
`eslint:recommended`,
`plugin:react/recommended`
],
parser: `babel-eslint`,
parserOptions: {
'ecmaVersion': 2020,
'sourceType': `module`,
'ecmaFeatures': {
'jsx': true,
'impliedStrict': true
}
},
plugins: [
`react`,
`react-hooks`,
`babel`,
`promise`
],
settings: {
'react': {
'version': `detect`
}
}
};
Make sure your .eslintignore
is not ignoring your source files and your IDE is using the ESLint configuration by default.确保您的
.eslintignore
没有忽略您的源文件,并且您的 IDE 默认使用 ESLint 配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.