![github-actions[bot]](/assets/img/avatar_default.png)
Co-authored-by: ericmorand-sonarsource <ericmorand-sonarsource@users.noreply.github.com> Co-authored-by: Ilia Kebets <104737176+ilia-kebets-sonarsource@users.noreply.github.com>
31 lines
669 B
Plaintext
31 lines
669 B
Plaintext
include::../common/rule.adoc[tag=header]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,javascript,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
const MyComponent = () => {
|
|
return <>
|
|
<a href="javascript:void(0)" onClick={foo}>Perform action</a>
|
|
<a href="#" onClick={foo}>Perform action</a>
|
|
<a onClick={foo}>Perform action</a>
|
|
</>;
|
|
};
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
----
|
|
const MyComponent = () => {
|
|
return <>
|
|
<button onClick={foo}>Perform action</button>
|
|
<a href="#section" onClick={foo}>Perform action</a>
|
|
</>;
|
|
};
|
|
----
|
|
|
|
include::../common/rule.adoc[tag=footer]
|