![github-actions[bot]](/assets/img/avatar_default.png)
* 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>
40 lines
806 B
Plaintext
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[]
|