I have CRA and i want install custom eslint (airbnb), but after installing it triggers an error
warning Definition for rule 'jsx-a11y/img-has-alt' was not found jsx-a11y/img-has-alt
package.json
...
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
create-app-react - 3.10.10
.eslintrc
"extends": [
"airbnb"
],
"plugins": [
"import",
"react",
"jsx-a11y"
],
"env": {
"browser": true,
"node": true,
"jest": true
},
"rules": {
"comma-dangle": ["error", "never"],
"jsx-a11y/img-has-alt": [0],
"jsx-quotes": ["error", "prefer-single"],
"no-confusing-arrow": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/jsx-no-bind": [0],
"react/prop-types": [1],
"react/require-default-props": [0]
}
edit: npm said that eslint-config-airbnb needs jsx-a11y v5.0.1
I use CRA eslint plugin and when I installed jsx-a11y plugin 5.0.3 I get console warning:
"[email protected]" has incorrect peer dependency "eslint-plugin-jsx-a11y@^2.0.0 || ^3.0.0 || ^4.0.0".
as well with the same warning you get.
I believe you need to downgrade to version 4.0.0. which is still "wanted" version
Since this question and answers are old, i would like to update as to what solved for me.
(As of Aug 2023) The below line worked for me in .eslintrc.json
"jsx-a11y/img-redundant-alt": [0],
I'm using below versions in package.json,
"eslint": "~8.28.0",
"eslint-config-next": "13.4.1",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "7.32.2",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With