58 lines
1.4 KiB
Plaintext
58 lines
1.4 KiB
Plaintext
:identifier_capital_plural: Variables, properties, and parameters
|
|
:identifier: variable, property, and parameter
|
|
:identifier_plural: variables, properties, and parameters
|
|
:identifier_or: variable, property, or parameter
|
|
:regex: ^[_$A-Za-z][$A-Za-z0-9]*$|^[_$A-Z][_$A-Z0-9]+$
|
|
|
|
include::../rule.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
With the default regular expression ``{regex}``:
|
|
|
|
[source,javascript,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
const foo_bar = 1; // Noncompliant
|
|
const baz_ = 2; // Noncompliant
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
----
|
|
const fooBar = 1;
|
|
const _baz = 2;
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Documentation
|
|
|
|
* MDN web docs - https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/JavaScript#variable_names[Guidelines for writing JavaScript code: Variable names]
|
|
* Wikipedia - https://en.wikipedia.org/wiki/Naming_convention_(programming)[Naming Convention (programming)]
|
|
|
|
=== Related rules
|
|
|
|
* S100 - Function and method names should comply with a naming convention
|
|
* S101 - Class names should comply with a naming convention
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../parameters.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|