-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create rule S6793: ARIA properties in DOM elements should have valid …
…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
1 parent
5c68374
commit d6ce70c
Showing
6 changed files
with
62 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include::../common/rule.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |