jsx-eslint / eslint-plugin-jsx-a11y

Static AST checker for a11y rules on JSX elements.
MIT License
3.43k stars 636 forks source link

Every file errors with `'jsx-a11y/href-no-hash' was not found` #397

Closed jasonrhodes closed 6 years ago

jasonrhodes commented 6 years ago

May be related to #396 but not sure. Greenkeeper just updated a bunch of our dependencies in this PR: https://github.com/SparkPost/2web2ui/pull/264/files, and this plugin went from 5.1.1 to 6.0.3 ... as far as I can tell we don't even use this plugin, it's there because we ejected from CRA a while back and it came "for free".

However, in this PR we have 615 errors because what seems like every single file in our repo errors with this:

  1:1  warning  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash

The package-lock file only shows one instance of this plugin installed:

$ cat package-lock.json | grep jsx-a11y
    "eslint-plugin-jsx-a11y": {
      "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.3.tgz",

My plan is to just remove this plugin from our repo so we can move on, but I wanted to log this here in case it was helpful to anyone else in a similar situation.

jasonrhodes commented 6 years ago

Update: downgrading this back to 5.1.1 also solved the problem. Still not totally sure why.

ljharb commented 6 years ago

Because the rule in question was removed in v6. Do you have any reference to that rule in your eslint config? If you ejected from CRA, you may.

jasonrhodes commented 6 years ago

Anyone who is using CRA and also keeps their deps up to date (via something like Greenkeeper) is gonna hit this, because ~CRA~ the CRA-packaged eslint config (eslint-config-react-app) current references the rule and hasn't yet released a version that removes it.

More here: https://github.com/facebook/create-react-app/issues/3418#issuecomment-362839726

ljharb commented 6 years ago

Sounds like the incompatibility is that the CRA eslint config doesn’t support v6 of this plugin.

jasonrhodes commented 6 years ago

Correct, and peer dependencies are pain and suffering. :)

ljharb commented 6 years ago

Peer deps work fine; but tools like greenkeeper sadly don’t yet handle them properly. I’d suggest adding an npm ls to your tests, which will make greenkeeper’s builds fail when peer dep are invalid.

crobinson42 commented 6 years ago

Work-around

If you're like me and you found this post because you're experiencing "jsx-a11y/href-no-hash" was not found due to eslint-config-airbnb or some other eslint config and you want to update to the latest versions of those eslint configs, you can circumvent the error at the top by placing this in your CRA's .eslintrc file:

{
  "extends": [
    "react-app",
    "airbnb"
  ],
  "rules": {
    "jsx-a11y/href-no-hash": [0], 
  }
}
iFlameing commented 6 years ago

work Around

You have to just make some change in .eslintrc file { "rules": { "jsx-a11y/href-no-hash": [0] } } and save if you are using the create react app to build your app and facing this problem.