From d6ce70cb9ee2ae66473c0226c43a52c5e6e11d27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:15:11 +0000 Subject: [PATCH] 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 Co-authored-by: yassin-kammoun-sonarsource --- rules/S6793/common/rule.adoc | 31 +++++++++++++++++++++++++++ rules/S6793/html/metadata.json | 2 ++ rules/S6793/html/rule.adoc | 1 + rules/S6793/javascript/metadata.json | 28 ++++-------------------- rules/S6793/javascript/rule.adoc | 32 +--------------------------- rules/S6793/metadata.json | 23 ++++++++++++++++++++ 6 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 rules/S6793/common/rule.adoc create mode 100644 rules/S6793/html/metadata.json create mode 100644 rules/S6793/html/rule.adoc diff --git a/rules/S6793/common/rule.adoc b/rules/S6793/common/rule.adoc new file mode 100644 index 00000000000..99a631069f1 --- /dev/null +++ b/rules/S6793/common/rule.adoc @@ -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] +---- +foo +---- + +To fix the code use a valid value for the aria-* attribute. + +[source,html,diff-id=1,diff-type=compliant] +---- + +---- + +== 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] diff --git a/rules/S6793/html/metadata.json b/rules/S6793/html/metadata.json new file mode 100644 index 00000000000..7a73a41bfdf --- /dev/null +++ b/rules/S6793/html/metadata.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/rules/S6793/html/rule.adoc b/rules/S6793/html/rule.adoc new file mode 100644 index 00000000000..5f710f9ed83 --- /dev/null +++ b/rules/S6793/html/rule.adoc @@ -0,0 +1 @@ +include::../common/rule.adoc[] diff --git a/rules/S6793/javascript/metadata.json b/rules/S6793/javascript/metadata.json index 383f731122e..44fbcbe538f 100644 --- a/rules/S6793/javascript/metadata.json +++ b/rules/S6793/javascript/metadata.json @@ -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" + ] } diff --git a/rules/S6793/javascript/rule.adoc b/rules/S6793/javascript/rule.adoc index 675acb6be1a..5f710f9ed83 100644 --- a/rules/S6793/javascript/rule.adoc +++ b/rules/S6793/javascript/rule.adoc @@ -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] ----- -foo ----- - -To fix the code use a valid value for the aria-* attribute. - -[source,javascript,diff-id=1,diff-type=compliant] ----- - ----- - -== 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[] diff --git a/rules/S6793/metadata.json b/rules/S6793/metadata.json index 2c63c085104..98904a4f75c 100644 --- a/rules/S6793/metadata.json +++ b/rules/S6793/metadata.json @@ -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" + } }