Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyze): noSvgWithoutTitle #4220

Merged
merged 1 commit into from
Feb 25, 2023
Merged

feat(rome_js_analyze): noSvgWithoutTitle #4220

merged 1 commit into from
Feb 25, 2023

Conversation

unvalley
Copy link
Contributor

@unvalley unvalley commented Feb 20, 2023

Closes #3940

Summary

This pr adds a new rule noSvgWithoutTitle for a11y.
Below is from description.

It is not possible to specify the alt attribute for the svg as for the img.
To make svg accessible, the following methods are available:

  • provide the title element as the first child to svg
  • provide role="img" and aria-label or aria-labelledby to svg

Test Plan

cargo test -p rome_js_analyze -- no_svg_without_title

Documentation

  • The PR requires documentation
  • I will create a new PR to update the documentation

@netlify
Copy link

netlify bot commented Feb 20, 2023

Deploy Preview for docs-rometools canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 37acac1
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63fa04348cbedc0008895cf2

Comment on lines 75 to 76
match node {
AnyJsxElement::JsxOpeningElement(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: considering we want to match against only one type, maybe if let AnyJsxElement::JsxOpeningElement(_) = node {} works better

feat: check title tag

test: add test cases

wip

feat: update impl to show diagnostics correctly

refactor: logic for detecting a valid title

test: update snapshot

fix: check attribute usage

fix: doc test, comment, diagnostics

chore: update description and codegen

test: simplify texts

chore: restore waste change

refactor

refactor: naming
@unvalley
Copy link
Contributor Author

unvalley commented Feb 25, 2023

@ematipico Thanks for the review. Could you review this pr again?

@unvalley unvalley marked this pull request as ready for review February 25, 2023 12:55
Copy link
Contributor

@ematipico ematipico 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!

@ematipico ematipico merged commit d6e6a7e into rome:main Feb 25, 2023
@unvalley unvalley deleted the no-svg-without-title branch February 26, 2023 03:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

noSvgWithoutTitle
2 participants