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

rules.jshint.E029.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 "Unclosed string" error is thrown when JSLint or JSHint encounters a a string that is not closed before the next line break or the end of the program. There are numerous situations that could cause this. In this first example, we accidentally forget to close our string:

x
 
1
var myString = "my string,
2
    myNumber = 10;
3
JSLint found 1 errorVersion 2015-09-23
Line 0:Unclosed string.

In the next example, we want our string to include a backslash character. The string appears to be closed but actually isn't, due to the backslash character escaping the closing quote:

3
 
1
var myString = "my string\",
2
    myNumber = 10;
3
JSLint found 1 errorVersion 2015-09-23
Line 0:Unclosed string.

And this final example, which makes use of the multiline strings allowed by ECMAScript 5, features a string that has not closed by the end of the program (the previous two examples failed at the first line break):

3
 
1
var myString = "my multiline \
2
                string
3
JSLint found 1 errorVersion 2015-09-23
Line 0:Unclosed string.

Why do I get this error?

This error is raised to highlight a fatal JavaScript syntax error. Your code will not run unless you fix this issue. The ECMAScript grammar states that any string literal must be closed by the same character (either " or ') that opened it (ES5 §7.8.4):

StringLiteral ::
    " DoubleStringCharactersopt "
    ' SingleStringCharactersopt '

To fix the error, simply close any unclosed strings:

3
 
1
var myString = "my string",
2
    myNumber = 10;
3
JSLint found no errorsVersion 2015-09-23

The second example above failed because the backslash character was escaping the closing quote, turning it into a literal character rather than a syntactic structure. To include a backslash in a string, you need to escape the backslash itself:

3
 
1
var myString = "my string\\",
2
    myNumber = 10;
3
JSLint found no errorsVersion 2015-09-23

In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. Since this message relates to a fatal syntax error you cannot disable it.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy