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

rules.jshint.W043.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

    

History

This warning has existed in various forms across the three main linters. It was introduced in the original version of JSHint and has remained (in a way) in all three tools from some point since.

  • In JSLint the warning given since August 2013 is "Unexpected '\'"

  • In JSLint between May 2011 and August 2013 the message used was the more generic "This is an ES5 feature"

  • Before May 2011 this functionality was not supported in JSLint

  • In JSHint 1.0.0 and above the message is "Bad escaping of EOL. Use option multistr if needed"

  • In JSHint prior to version 1.0.0 the message was "Bad escapement of EOL. Use option multistr if needed"

  • In ESLint the message is "Multiline support is limited to browsers supporting ES5 only"

The situations that produce the warning have not changed despite changes to the text of the warning itself.

When do I get this error?

The "Bad escapement of EOL. Use option multistr if needed" error, and the alternative "Multiline support is limited to browsers supporting ES5 only", is thrown when JSHint or ESLint encounters a multiline string. JSHint will only issue this warning the the multistr option is not set to true. In the following example we attempt to assign a multiline string to the variable myString:

x
 
1
var myString = "Line 1 \
2
                Line 2";
3
JSHint found 1 errorVersion 2.9.0
Line 1:Bad escaping of EOL. Use option multistr if needed.

Why do I get this error?

This error is raised to highlight the use of a newer language feature that might not be supported in all the environments in which your code should run. In particular, various older browsers will be likely to throw syntax errors when parsing your script.

The ECMAScript specification was updated to allow multiline strings in version 5 (ES5 §7.8.4):

A line terminator character cannot appear in a string literal, except as part of a LineContinuation to produce the empty character sequence. The correct way to cause a line terminator character to be part of the String value of a string literal is to use an escape sequence such as \n or \u000A.

If you're receiving this error in JSHint you can listen to the message and set the multistr option to allow the use of multiline strings:

4
 
1
/*jshint multistr: true */
2
var myString = "Line 1 \
3
                Line 2";
4
JSHint found no errorsVersion 2.9.0

If you're using a version of JSLint from between May 2011 and August 2013 you can avoid this warning by setting the es5 option:

4
 
1
/*jslint es5: true */
2
var myString = "Line 1 \
3
                Line 2";
4
JSLint found no errorsVersion 2013-05-31

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 W043. This means you can tell JSHint to not issue this warning with the /*jshint -W043 */ directive.

In ESLint the rule that generates this warning is named no-multi-str. You can disable it by setting it to 0, or enable it by setting it to 1.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy