
rules.jshint.W106.html Maven / Gradle / Ivy
Show all versions of sonar-web-frontend-js Show documentation
What does this option do?
The JSHint camelcase
option is used to force all identifiers (function,
variable and property) to either be written in camel case or in uppercase with
underscores. It's common convention in JavaScript to use camel case for normal
identifiers and uppercase for identifiers that represent constants. In the
following example we have a couple of identifiers that break the camel case
rule:
x 1/*jshint camelcase: true */
2var camel_case = 1;
3var fake_constant = 2;
4var obj = {
5 not_good: 3
6};
7
In the next example we've changed the identifiers so they conform to the rules:
7 1/*jshint camelcase: true */
2var camelCase = 1;
3var FAKE_CONSTANT = 2;
4var obj = {
5 notGood: 3
6};
7
When should I use this option?
The use of the camelcase
JSHint option will cause an "Identifier '{a}' is not
in camel case" error, where "{a}" is the identifier in question, any time it
encounters an identifier that doesn't match the rules discussed above. You
should only enable this option when you want to enforce a coding style
throughout your program. This is generally a good idea when you're working on a
project with multiple developers to help keep things consistent.
Note that this is an enforcing option which means JSHint does not apply it by
default. If you do not explicitly set this option to true
JSHint will allow
the use of bitwise operators anywhere in your code.
Recommendation
Set this option to true
(enforces the use of camel case and constant case).