Skip to content

Commit

Permalink
Create rule S6824: Add the rule implementation for html (#3852)
Browse files Browse the repository at this point in the history
* Add html to rule S6824

* Update PR with shared message

---------

Co-authored-by: zglicz <[email protected]>
Co-authored-by: Michal Zgliczynski <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2024
1 parent f1aee8c commit 4250db6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 55 deletions.
31 changes: 31 additions & 0 deletions rules/S6824/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 ARIA roles or `aria-*` attributes are not used in unsupported DOM elements, which are mostly invisible such as `meta`, `html` or `head`.

== How to fix it

Check if you are using ARIA roles or `aria-*` attributes in unsupported DOM elements.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
<title aria-hidden="false">My beautiful web page</title>
----

To fix the code, remove the extra ARIA role or `aria-*` attributes from the unsupported DOM elements.

[source,javascript,diff-id=1,diff-type=compliant]
----
<title>My beautiful web page</title>
----

== 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/Roles[ARIA roles (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/S6824/html/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
1 change: 1 addition & 0 deletions rules/S6824/html/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include::../common/rule.adoc[]
24 changes: 0 additions & 24 deletions rules/S6824/javascript/metadata.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
{
"title": "No ARIA role or property for unsupported DOM elements",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"react",
"accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6824",
"sqKey": "S6824",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "targeted",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
}
}
32 changes: 1 addition & 31 deletions rules/S6824/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 ARIA roles or `aria-*` attributes are not used in unsupported DOM elements, which are mostly invisible such as `meta`, `html` or `head`.

== How to fix it in JSX

Check if you are using ARIA roles or `aria-*` attributes in unsupported DOM elements.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
<title aria-hidden="false">My beautiful web page</title>
----

To fix the code, remove the extra ARIA role or `aria-*` attributes from the unsupported DOM elements.

[source,javascript,diff-id=1,diff-type=compliant]
----
<title>My beautiful web page</title>
----

== 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/Roles[ARIA roles (Reference)]

=== Standards

* W3C - https://www.w3.org/TR/wai-aria-1.2/[Accessible Rich Internet Applications (WAI-ARIA) 1.2]
include::../common/rule.adoc[]
24 changes: 24 additions & 0 deletions rules/S6824/metadata.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
{
"title": "No ARIA role or property for unsupported DOM elements",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"react",
"accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6824",
"sqKey": "S6824",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "targeted",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
}
}

0 comments on commit 4250db6

Please sign in to comment.