-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump eslint-plugin-jsx-a11y version #2690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR! I was thinking of submitting the same change tomorrow!
Current change makes the rule too restrictive for CRA environment so that probably needs to be changed. I provided some options.
Its a breaking change if anchor-is-valid
and/or label-has-for
is activated.
Aside from the new anchor-is-valid
rule, there has been a fix to label-has-for
. I did not add it in the previous PR as it would fail on things like:
<label>Name
<input>
</label>
and
<label>
{children}
</label>
Both of which are accessible patterns.
As this rule checks that each form element has a good chance of having an accessible label it would be an incredible rule to add. I do estimate quite a bit of failures in the wild though.
But the fix would be to add htmlFor
to id
links. That is easy enough. But in components it could mean that the id
need to autogenerated if the component is used more than once on any specific page.
Do you think the benefit is large enough to outweight the impact on the users?
@@ -272,13 +272,13 @@ module.exports = { | |||
'jsx-a11y/accessible-emoji': 'warn', | |||
'jsx-a11y/alt-text': 'warn', | |||
'jsx-a11y/anchor-has-content': 'warn', | |||
'jsx-a11y/anchor-is-valid': 'warn', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The anchor-is-valid
rule has quite a bit more reach than the old href-no-hash
rule. It provides three checks:
- Checks if there is an
href
on an<a>
element. - Checks if
href
attributes contain obviously valid content. - Checks if and
<a>
is obviously used as a button.
The third option seems too restrictive for CRA which renders this setup too restrictive.
Options 1 and 2 I think could be usable. The anchors that would fail for the three rules are listed here https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md#fail
The subchecks can be activated as needed.
To activate options 1 and 2 the config is :
"jsx-a11y/anchor-is-valid": [ "warn", {
"aspects": [ "noHref", "invalidHref" ]
}]
Just using the invalidHref
aspect gets closest to what was already in CRA although it will error on anchors with javascript
in the href
.
What do you think? Can we activate both aspects?
@@ -272,13 +272,16 @@ module.exports = { | |||
'jsx-a11y/accessible-emoji': 'warn', | |||
'jsx-a11y/alt-text': 'warn', | |||
'jsx-a11y/anchor-has-content': 'warn', | |||
'jsx-a11y/anchor-is-valid': [ | |||
'warn', | |||
aspects: ['noHref', 'invalidHref'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the wrapping object braces are missing here.
Failing because:
Looking into it. |
Maybe some bad CI cache on our side. |
That's what I'm thinking. The rule is there and represented in the index.js. |
No, it's really failing. I cloned from your repo and checked out your branch, ran
and the errors pop up. Investigating. |
@gaearon |
I believe this PR should fix the Please merge it :) |
Hi guys, is there any ETA on when this will be merged? Thanks 👍 |
Reminder to update our docs (e.g. #3460). |
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
when will release eslint-config-react-app@2.1.1? |
* Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things
This should fix #2663.
Probably a breaking change.
cc @AlmeroSteyn @jessebeach for review (do we need to enable any new rules? disable old ones?)