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:
parent
04b1bdb263
commit
a422950ed5
26
rules/S6793/javascript/metadata.json
Normal file
26
rules/S6793/javascript/metadata.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
31
rules/S6793/javascript/rule.adoc
Normal file
31
rules/S6793/javascript/rule.adoc
Normal 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]
|
2
rules/S6793/metadata.json
Normal file
2
rules/S6793/metadata.json
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
== Why is this an issue?
|
== 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".
|
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).
|
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
|
== How to fix it in JSX
|
||||||
|
|
||||||
|
1
shared_content/jsts/aria-intro-1.adoc
Normal file
1
shared_content/jsts/aria-intro-1.adoc
Normal 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.
|
Loading…
x
Reference in New Issue
Block a user