74 lines
1.2 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
This rule checks that all string literals use the same kind of quotes.
=== Noncompliant code example
Using the parameter default (forcing single quotes):
2022-02-04 17:28:24 +01:00
[source,javascript]
----
var firstParameter = "something"; // Noncompliant
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,javascript]
----
var firstParameter = 'something';
----
=== Exceptions
Strings that contain quotes are ignored.
[source,javascript]
----
let heSaid = "Then he said 'What?'." // ignored
let sheSaid = '"Whatever!" she replied.' // ignored
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use string literals quotes consistently
=== Parameters
.singleQuotes
****
----
true
----
Set to true to require single quotes, false for double quotes.
****
'''
== Comments And Links
(visible only on this page)
=== on 1 Nov 2016, 17:04:09 Elena Vilchik wrote:
\[~ann.campbell.2] Could you please add exceptions to this rule (they are both implemented already)?
* if string literal contains ``++'++`` (SONARJS-796)
* if string literal is part of JSX (SONARJS-681)
Thanks!
=== on 1 Nov 2016, 18:21:18 Ann Campbell wrote:
Done [~elena.vilchik]
endif::env-github,rspecator-view[]