Skip to content

[New] anchor-ambiguous-text: ignore punctuation #886

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

Merged
merged 1 commit into from
Aug 24, 2022
Merged

[New] anchor-ambiguous-text: ignore punctuation #886

merged 1 commit into from
Aug 24, 2022

Conversation

mattxwang
Copy link
Contributor

@mattxwang mattxwang commented Aug 24, 2022

I had a chance to test anchor-ambiguous-text in our internal repos @chanzuckerberg, and a coworker flagged a false negative:

<a>learn more.</a>

The above should be flagged (it's ambiguous anchor text!), but because the rule doesn't ignore punctuation, it doesn't hit the existing dictionary.

So, this is a bite-sized PR that:

  • adds failing test cases
  • adjusts getAccessibleChildText to strip out punctuation
  • documents the new behavioural change

@mattxwang mattxwang marked this pull request as ready for review August 24, 2022 20:26
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like one of those bug fixes that might also be a breaking change :-/ i'd hate to put it behind an option, but that might be the safest approach?

@codecov
Copy link

codecov bot commented Aug 24, 2022

Codecov Report

Merging #886 (bbae2c4) into main (8b889bf) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #886   +/-   ##
=======================================
  Coverage   99.29%   99.29%           
=======================================
  Files         101      101           
  Lines        1555     1555           
  Branches      511      511           
=======================================
  Hits         1544     1544           
  Misses         11       11           
Impacted Files Coverage Δ
src/util/getAccessibleChildText.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mattxwang
Copy link
Contributor Author

mattxwang commented Aug 24, 2022

Thanks for the very quick review!

This seems like one of those bug fixes that might also be a breaking change

We haven't released this rule, so I'm thinking that there wouldn't be a breaking change? Or do you mean that we should add a toggle for user convenience?

edit: sorry for the confusion, commented in the wrong thread

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@ljharb ljharb merged commit bbae2c4 into jsx-eslint:main Aug 24, 2022
@mattxwang mattxwang deleted the mwang/ignore-punctuation branch August 24, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants