The rule "react-redux/useSelector-prefer-selectors" isn't being respected when I put it in my .eslintrc.json, but other rules are. However, when I put
/* eslint react-redux/useSelector-prefer-selectors: "off" */
At the top of the offending file, the error goes away.
My .eslintrc.json file (In my root directory):
{
"env": {
"browser": true,
"commonjs": true,
"es2020": true,
"node": false
},
"extends": [
"airbnb",
"react-app",
"airbnb/hooks",
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:react-redux/recommended"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react",
"react-redux"
],
"rules": {
"indent": [
"warn",
"tab"
],
"no-tabs": "off",
"no-unused-vars": "warn",
"consistent-return": "warn",
"no-mixed-spaces-and-tabs": 0,
"react/prop-types": 0,
"unused-imports/no-unused-imports": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react-redux/useSelector-prefer-selectors": "off",
"react/jsx-indent": "off",
"react/jsx-filename-extension": "off",
"react/jsx-no-useless-fragment": "warn"
}
}
Figured it out thanks to a comment by @guiwme5. While I don't use vscode, I do use WebStorm - and it seems they both have the same issue - they don't reload .eslintrc.* files when they change.
So if you stumble across this trying to figure out why your IDE isn't respecting your eslint rules, try restarting the IDE.