-
Notifications
You must be signed in to change notification settings - Fork 8
Add linter against generic link text #32
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
Conversation
| message ||= klass::MESSAGE | ||
| message += "\nLearn more at https://github.com/github/erblint-github#rules.\n" | ||
| offense = ["#{simple_class_name}:#{message}", source_range.source].join("\n") | ||
| add_offense(source_range, offense, replacement) |
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.
This helper allows the output of the ERB lint message to be something like:
ERBLint::Linters::A11yAvoidGenericLinkTextCounter:Avoid using generic link text such as Read more, Learn more, Click here, More, Link.
<a href="github.com/about">Learn more
In file: app/views/test.html.erb:46
where we can specify a range of the code source to be output. In this case we include the first anchor tag and the text content for ease of identification.
The other helper we commonly use, generate_offense only allows a single tag to be output in the message.
| include ERBLint::Linters::CustomHelpers | ||
| include LinterRegistry | ||
|
|
||
| BANNED_GENERIC_TEXT = [ |
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.
Is there anything to remove from here? Anything else we should add in here?
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.
This is amazing 🤩 Thank you for doing this! What do you think about adding "Here" as well? I've seen text such as `Read more about it here
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 idea!!! <3
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.
Updated in: 80ebd6b ❤️
Add @lindseywild suggestion
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.
Thoughts
- OMG love
- there was a really great slack thread on link texts where a few of our designers chimed in about the complexities here, that I think are worth surfacing. the cognitive ease of a marketing page that repeats "Learn more" links at the end of bullet points was a good example of how sometimes it's not clear what the "most accessible" choice is, and it's worth providing the complicated scenarios in our guidance. "Go to plans", e.g., was the eventual solution that suited all cases, for instance.
- do our listing errors guide people to documentation and slack channels? Joel mentioned it and since I'm never working in dotcom I'm not sure the answer
|
Co-authored-by: Andri Alexandrou <andrialexandrou@github.com>
|
@andrialexandrou I updated the documentation in c077f6d! Would you mind another review? |
andrialexandrou
left a comment
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 great 🚢
Relates to: https://github.com/github/accessibility/issues/1291 (GitHub Staff-only)
We often use generic link text in our ERB files. This PR adds an ERB linter against generic link text in ERB. This linter rule will report any generic text usage within anchor tags as well as in Rails helpers like link_to which generate anchor tags.
I would appreciate extra eyes on the documentation and whether this
BANNED_GENERIC_TEXTis reasonable. Any more to add to this list?