diff --git a/rules/S6793/javascript/metadata.json b/rules/S6793/javascript/metadata.json new file mode 100644 index 0000000000..f4120fc4d4 --- /dev/null +++ b/rules/S6793/javascript/metadata.json @@ -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" + } +} diff --git a/rules/S6793/javascript/rule.adoc b/rules/S6793/javascript/rule.adoc new file mode 100644 index 0000000000..cd335deb06 --- /dev/null +++ b/rules/S6793/javascript/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 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 + +* 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] diff --git a/rules/S6793/metadata.json b/rules/S6793/metadata.json new file mode 100644 index 0000000000..2c63c08510 --- /dev/null +++ b/rules/S6793/metadata.json @@ -0,0 +1,2 @@ +{ +} diff --git a/rules/S6807/javascript/rule.adoc b/rules/S6807/javascript/rule.adoc index f3fc245919..a8a5246aed 100644 --- a/rules/S6807/javascript/rule.adoc +++ b/rules/S6807/javascript/rule.adoc @@ -1,12 +1,12 @@ == 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". 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 diff --git a/shared_content/jsts/aria-intro-1.adoc b/shared_content/jsts/aria-intro-1.adoc new file mode 100644 index 0000000000..ff638b9cd8 --- /dev/null +++ b/shared_content/jsts/aria-intro-1.adoc @@ -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.