Unclosed strings generate both a warning and an error with the same message #909

Open
jamesallardice opened this Issue Mar 11, 2013 · 1 comment

3 participants

@jamesallardice

A simple unclosed string will generate an "Unclosed string" warning (W112) and an error (E029) with the same message:

var x = "unclosed string

Is this the intended behaviour? Could you please clarify the situations in which an unclosed string should not be an error if that's the case?

  • Does not generate any warnings or errors:
/*jshint -W112 */
test = "hallo world
          this is a faulty multiline string in javascript";
  • Generates W112:
test = "hallo world
          this is a faulty multiline string in javascript";
  • Generates W112 and E029:
test = "hallo world;
  • Generates E029:
/*jshint -W112 */
test = "hallo world;
@guyzmo

Well as your examples show off, and from reading the source code, the error E029 is triggered when an empty string reaches the EOF, whereas the W112 error is triggered when a string reaches end of line, but lacks the continuation character, \.

Have a look at where W112 is triggered and where E029 is triggered, the comments are pretty clear ;-)

Maybe as a patch, E029 shall have its text changed to "unclosed string reached EOF" or something like that. @antonkovalyov, any suggestions ?

@lukeapage lukeapage added P4 Bug labels Jun 15, 2015
@lukeapage lukeapage removed the rule Issue label Jun 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment