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

rules.jshint.W110.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 "Mixed double and single quotes" error is thrown when JSHint encounters string literal delimited by double or single quote characters when a string literal delimited by the other has already been found. It will only raise this warning if the quotmark option is set to true. In the following example we attempt to assign string literals to the variables x and y:

x
 
1
/*jshint quotmark: true */
2
var x = "My String",
3
    y = 'Another string';
4
JSHint found 1 errorVersion 2.9.0
Line 3:Mixed double and single quotes.

Why do I get this error?

This error is raised to highlight a lack of consistency. 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). However, it would usually be frowned upon to mix both types of quote within one program (there are obvious exceptions, such as nested quotes). You can easily resolve this issue by sticking to one type, and you should consider setting the quotmark option to either double or single to enforce your preference:

4
 
1
/*jshint quotmark: double */
2
var x = "My String",
3
    y = "Another string";
4
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 W110. This means you can tell JSHint to not issue this warning with the /*jshint -W110 */ directive. You can also set the quotmark option to false.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy