All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rules.jshint.W108.html Maven / Gradle / Ivy

Go to download

Consume reports generated by jshint for code quality. Also consume reports for code duplication (either simian or cpd). Consumes the unit/integration tests reports (generated by Jasmin) coverage report (lcov generated by Istanbul). The information generated by reports are added in Sonar

There is a newer version: 2.1.0
Show newest version

    

When do I get this error?

The "Strings must use singlequote" and "Strings must use doublequote" errors are thrown when JSHint or ESLint encounters string literal delimited by double quote characters when the quotmark option is set to single or a string literal delimited by single quote characters when the quotmark option is set to double. In the following example we attempt to assign a string literal to the variable x:

x
 
1
/*jshint quotmark: double */
2
var x = 'My String';
3
JSHint found 1 errorVersion 2.9.0
Line 2:Strings must use doublequote.

Why do I get this error?

This error is raised to highlight a deviation from a specific coding style. Your code will run fine if you do not fix this error, but it demonstrates a lack of care. There is no difference in JavaScript between single and double quotes. This is made clear by the grammar for string literals (ES5 §7.8.4):

StringLiteral ::
    " DoubleStringCharactersopt "
    ' SingleStringCharactersopt '

The only difference is that DoubleStringCharacters cannot contain another double quote, and SingleStringCharacters cannot contain a single quote (as that would terminate the string literal). If this option is set to either double or single then it is likely your codebase requires you to conform to a specific style in which one type of quote is preferred. To fix the error, simply use the correct type of quote:

3
 
1
/*jshint quotmark: double */
2
var x = "My String";
3
JSHint found no errorsVersion 2.9.0

In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W108 (for double quotes) or W109 (for single quotes). This means you can tell JSHint to not issue this warning with the /*jshint -W108 */ or /*jshint -W109 */ directive.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy