Create rule S6793: ARIA properties in DOM elements should have valid values (#3200)

You can preview this rule
[here](https://sonarsource.github.io/rspec/#/rspec/S6793/javascript)
(updated a few minutes after each push).
This commit is contained in:
github-actions[bot] 2023-10-12 14:12:47 +02:00 committed by GitHub
parent 04b1bdb263
commit a422950ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 2 deletions

View File

@ -0,0 +1,26 @@
{
"title": "ARIA properties in DOM elements should have valid values",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"react",
"a11y"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6793",
"sqKey": "S6793",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "MEDIUM"
},
"attribute": "LOGICAL"
}
}

View File

@ -0,0 +1,31 @@
== Why is this an issue?
include::../../../shared_content/jsts/aria-intro-1.adoc[]
This rule checks that the values of ARIA attributes "aria-*" in DOM elements are valid.
== How to fix it in JSX
Check that each element with a defined ARIA attribute has a valid value.
[source,javascript,diff-id=1,diff-type=noncompliant]
----
<span aria-hidden="ok">foo</span>
----
To fix the code use a valid value for the aria-* attribute.
[source,javascript,diff-id=1,diff-type=compliant]
----
<span aria-hidden="true">foo</span>
----
== Resources
=== Documentation
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques[MDN - Using ARIA: Roles, states, and properties]
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes[MDN - ARIA states and properties (Reference)]
=== Standards
* https://www.w3.org/TR/wai-aria-1.2/[W3C - Accessible Rich Internet Applications (WAI-ARIA) 1.2]

View File

@ -0,0 +1,2 @@
{
}

View File

@ -1,12 +1,12 @@
== Why is this an issue?
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes provide additional information about an element's role, state, properties, and values to assistive technologies like screen readers.
include::../../../shared_content/jsts/aria-intro-1.adoc[]
Each role in ARIA has a set of required attributes that must be included for the role to be properly understood by assistive technologies. These attributes are known as "required aria-* properties".
For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox is checked (true), unchecked (false), or in a mixed state (mixed).
This rules checks that each element with a defined ARIA role also has all required attributes.
This rule checks that each element with a defined ARIA role also has all required attributes.
== How to fix it in JSX

View File

@ -0,0 +1 @@
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes provide additional information about an element's role, state, properties, and values to assistive technologies like screen readers.