2
votes

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

3

3 Answers

2
votes

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

enter image description here

0
votes

If you change the rule declaration from "jsx-a11y/img-has-alt": [0], to "jsx-a11y/alt-text": [0], it will work.

https://cnpmjs.org/package/eslint-plugin-jsx-a11y

-1
votes

You apparently need to update your node version for the problem to go away.