Skip to content
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

Improve the no-default-alt-text rule #40

Merged
merged 5 commits into from
Apr 26, 2023
Merged

Conversation

iansan5653
Copy link
Member

@iansan5653 iansan5653 commented Apr 21, 2023

Contains a few improvements to rough edges around the no-default-alt-text rule that I noticed while working on my Markdown checker browser extension:

  • Made the description more succinct: "Images should have meaningful alternative text (alt text)" instead of "Images should set meaningful alternative text (alt text), and not use the macOS default screenshot filename or Image." This shorter description is consistent with the default Markdownlint rules
  • Removed the detail field from failures, since it was just a copy of the image's alt text. This was distracting and not very helpful - the detail field is only really useful for showing hints on how to resolve the issue. For example, a useful detail for MD001 looks like: "Expected: h2; Actual: h3"
  • Added a range field that only covers the alt text so we don't have to error the entire line. This helps draw attention to the specific issue at hand and helps writers figure out specifically where to put better alt text. This required using regular expressions for all checking (instead of only for HTML), because the default Markdown parser tokens don't have ranges

Note: The use of the d flag in the regular expressions (which is necessary in order to get the range indexes) means we can only now support later versions of Node since this is an ES2022 feature.

@iansan5653 iansan5653 requested a review from a team as a code owner April 21, 2023 16:02
@accessibility-bot
Copy link
Collaborator

👋 Hello and thanks for pinging us! An accessibility first responder will review this soon.

  • 💻 On PRs for our review: please provide a review environment with steps to validate, screenshots (with alt text), or videos (with description following) demonstrating functionality we should be checking. This will help speed up our review and feedback cycle.
  • ⚠️ If this is urgent, please visit us in #accessibility on Slack and tag the first responder(s) listed in the channel topic.

Copy link
Contributor

@lindseywild lindseywild left a comment

Choose a reason for hiding this comment

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

Thank you for this!

src/rules/no-default-alt-text.js Outdated Show resolved Hide resolved
@iansan5653 iansan5653 merged commit 114f037 into main Apr 26, 2023
@iansan5653 iansan5653 deleted the improve-no-default-alt-text branch April 26, 2023 15:34
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.

3 participants