Skip to content

Commit

Permalink
Create rule S6793: ARIA properties in DOM elements should have valid …
Browse files Browse the repository at this point in the history
…values (#3654)

* Add html to rule S6793

* Share description with HTML

* Fix after review

---------

Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com>
Co-authored-by: yassin-kammoun-sonarsource <yassin.kammoun@sonarsource.com>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent 5c68374 commit d6ce70c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 55 deletions.
31 changes: 31 additions & 0 deletions rules/S6793/common/rule.adoc
Original file line number Diff line number Diff line change
@@ -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
Check that each element with a defined ARIA attribute has a valid value.
[source,html,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,html,diff-id=1,diff-type=compliant]
----
<span aria-hidden="true">foo</span>
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques[Using ARIA: Roles, states, and properties]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes[ARIA states and properties (Reference)]

=== Standards

* W3C - https://www.w3.org/TR/wai-aria-1.2/[Accessible Rich Internet Applications (WAI-ARIA) 1.2]
2 changes: 2 additions & 0 deletions rules/S6793/html/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
1 change: 1 addition & 0 deletions rules/S6793/html/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include::../common/rule.adoc[]
28 changes: 4 additions & 24 deletions rules/S6793/javascript/metadata.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
{
"title": "ARIA properties in DOM elements should have valid values",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"react",
"accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6793",
"sqKey": "S6793",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "MEDIUM"
},
"attribute": "LOGICAL"
}
"tags": [
"react",
"accessibility"
]
}
32 changes: 1 addition & 31 deletions rules/S6793/javascript/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
== 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

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques[Using ARIA: Roles, states, and properties]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes[ARIA states and properties (Reference)]

=== Standards

* W3C - https://www.w3.org/TR/wai-aria-1.2/[Accessible Rich Internet Applications (WAI-ARIA) 1.2]
include::../common/rule.adoc[]
23 changes: 23 additions & 0 deletions rules/S6793/metadata.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
{
"title": "ARIA properties in DOM elements should have valid values",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6793",
"sqKey": "S6793",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "MEDIUM"
},
"attribute": "LOGICAL"
}
}

0 comments on commit d6ce70c

Please sign in to comment.