github-actions[bot] e4fce14620
Create rule S6841: "tabIndex" values should be 0 or -1 (#3650)
* Add html to rule S6841

* Share JS description with HTML

---------

Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com>
Co-authored-by: yassin-kammoun-sonarsource <yassin.kammoun@sonarsource.com>
2024-02-19 14:45:03 +01:00

40 lines
806 B
Plaintext

include::../why.adoc[]
include::../how.adoc[]
=== Code examples
==== Noncompliant code example
[source,javascript,diff-id=1,diff-type=noncompliant]
----
function MyDiv() {
return (
<div>
<span tabIndex="5">foo</span> // Noncompliant
<span tabIndex="3">bar</span> // Noncompliant
<span tabIndex="1">baz</span> // Noncompliant
<span tabIndex="2">qux</span> // Noncompliant
</div>
);
}
----
==== Compliant solution
[source,javascript,diff-id=1,diff-type=compliant]
----
function MyDiv() {
return (
<div>
<span tabIndex="0">foo</span>
<span tabIndex="-1">bar</span>
<span tabIndex={0}>baz</span>
<span>qux</span>
</div>
);
}
----
include::../resources.adoc[]