Skip to content

Commit

Permalink
Update RSPEC (#4672)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez authored Apr 23, 2024
1 parent a4aa6b5 commit 89f1049
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react"
],
"defaultSeverity": "Minor",
"ruleSpecification": "RSPEC-6854",
"ruleSpecification": "RSPEC-1090",
"sqKey": "S1090",
"scope": "All",
"quickfix": "infeasible",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ <h2>Why is this an issue?</h2>
<p>Without assertions, a unit test doesn’t actually verify anything, making it ineffective in catching potential bugs or regressions. It will always
pass, regardless of the implementation of the unit. This can lead to a false sense of security, as you may believe that your code is working correctly
when it might not be.</p>
<p>This rule raises an issue when the assertion library <code>chai</code>,<code>sinon</code> or <code>vitest</code> is imported but no assertion is
used in a test.</p>
<p>This rule raises an issue when one of the following assertion libraries is imported but no assertion is used in a test:</p>
<ul>
<li> <code>chai</code> </li>
<li> <code>sinon</code> </li>
<li> <code>vitest</code> </li>
<li> <code>supertest</code> </li>
</ul>
<pre data-diff-id="1" data-diff-type="noncompliant">
const expect = require("chai").expect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react"
],
"defaultSeverity": "Minor",
"ruleSpecification": "RSPEC-6855",
"ruleSpecification": "RSPEC-4084",
"sqKey": "S4084",
"scope": "All",
"quickfix": "infeasible",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react"
],
"defaultSeverity": "Minor",
"ruleSpecification": "RSPEC-6849",
"ruleSpecification": "RSPEC-5254",
"sqKey": "S5254",
"scope": "All",
"quickfix": "targeted",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Why is this an issue?</h2>
<p>JavaScript regular expressions provide Unicode character classses and Unicode property escapes for matching characters based on their Unicode
values and Unicode properties respectively. When using Unicode property escapes like <code>\p{Alpha}</code> without the <code>u</code> flag, the
regular expression will not match alphabetic characters but rather the <code>+'\p{Alpha}+'</code> string literal, which is likely a mistake.</p>
regular expression will not match alphabetic characters but rather the <code>'\p{Alpha}'</code> string literal, which is likely a mistake.</p>
<p>This rules raises an issue when Unicode character classses and Unicode property escapes are used without the <code>u</code> flag.</p>
<h3>Noncompliant code example</h3>
<pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>Why is this an issue?</h2>
<p>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).</p>
<p>This rule checks that each element with a defined ARIA role also has all required attributes.</p>
<h2>How to fix it in JSX</h2>
<h2>How to fix it</h2>
<p>Check that each element with a defined ARIA role also has all required attributes.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;div role="checkbox"&gt;Unchecked&lt;/div&gt; {/* Noncompliant: aria-checked is missing */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ <h2>Why is this an issue?</h2>
<p>This rule ensures that the ARIA properties used on an element are ones that are supported by the role of that element. For instance, the ARIA
property <code>aria-required</code> is not supported by the role <code>link</code>. Therefore, using <code>aria-required</code> on an anchor tag would
violate this rule.</p>
<h2>How to fix it in JSX</h2>
<p>Check the spelling of the aria-* attributes and verify that they are actually supported by the element role.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;div role="checkbox" aria-chekd={isChecked}&gt;Unchecked&lt;/div&gt; {/* Noncompliant: aria-chekd is not supported */}
</pre>
<p>To fix the code remove non-compatible attributes or replace them with the correct ones.</p>
<h2>How to fix it</h2>
<p>Check the spelling of the aria-* attributes and verify that they are actually supported by the element role. Remove non-compatible attributes or
replace them with the correct ones.</p>
<pre data-diff-id="1" data-diff-type="compliant">
&lt;div role="checkbox" aria-checked={isChecked}&gt;Unchecked&lt;/div&gt;
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ <h2>Why is this an issue?</h2>
assistive technologies, simplicity, and maintainability. They come with inherent behaviors and keyboard interactions, reducing the need for additional
JavaScript. Semantic HTML also enhances SEO by helping search engines better understand the content and structure of web pages. While ARIA roles are
useful, they should be considered a last resort when no suitable HTML element can provide the required behavior or semantics.</p>
<h2>How to fix it in JSX</h2>
<p>Replace the ARIA role with an appropriate HTML tag.</p>
<h3>Code examples</h3>
<h4>Noncompliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;div role="button" onClick={handleClick}&gt;Click me&lt;/div&gt;
&lt;div role="button" onClick={handleClick} /* Noncompliant */&gt;Click me&lt;/div&gt;
</pre>
<h4>Compliant solution</h4>
<p>Replace the ARIA role with an appropriate HTML tag.</p>
<pre data-diff-id="1" data-diff-type="compliant">
&lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h2>Why is this an issue?</h2>
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.</p>
<p>This rule checks that when using the <code>role</code> property in DOM elements, its value is a valid non-abstract ARIA role.</p>
<p>This rule does not cover non-DOM elements, such as custom components.</p>
<h2>How to fix it in JSX</h2>
<h2>How to fix it</h2>
<p>Check that each element with a defined ARIA role has a valid non-abstract value.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;div role="meth" aria-label="a^{2} + b^{2} = c^{2}"&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ <h2>Why is this an issue?</h2>
technologies like screen readers.</p>
<p>For example, a <code>&lt;button&gt;</code> element has a default role of <code>button</code>. If you explicitly define the role of a
<code>&lt;button&gt;</code> element as <code>button</code>, it’s considered redundant because it’s the default role of that element.</p>
<h2>How to fix it in JSX</h2>
<p>Remove redundant ARIA role attribute.</p>
<h3>Code examples</h3>
<h4>Noncompliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;button role="button" onClick={handleClick}&gt;OK&lt;/button&gt;
</pre>
<h4>Compliant solution</h4>
<p>Remove ARIA role attributes when they are redundant.</p>
<pre data-diff-id="1" data-diff-type="compliant">
&lt;button onClick={handleClick}&gt;OK&lt;/button&gt;
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h2>Why is this an issue?</h2>
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.</p>
<p>This rule checks that ARIA roles or <code>aria-*</code> attributes are not used in unsupported DOM elements, which are mostly invisible such as
<code>meta</code>, <code>html</code> or <code>head</code>.</p>
<h2>How to fix it in JSX</h2>
<h2>How to fix it</h2>
<p>Check if you are using ARIA roles or <code>aria-*</code> attributes in unsupported DOM elements.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
&lt;title aria-hidden="false"&gt;My beautiful web page&lt;/title&gt;
Expand Down
2 changes: 1 addition & 1 deletion sonarpedia.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"languages": [
"JS"
],
"latest-update": "2024-03-28T12:38:08.293231Z",
"latest-update": "2024-04-23T12:50:58.369617900Z",
"options": {
"no-language-in-filenames": true,
"preserve-filenames": true
Expand Down

0 comments on commit 89f1049

Please sign in to comment.