douglascrockford/JSLint — Issue #95: different results depend on the position of "use strict"; and other comments
Author: OlegKi
Created: 2012-01-10 11:11:50+00:00
State: open

The following code produces no error

/*global jQuery */
/*jslint unparam: true */
(function ($) {
/*any comment*/
//one more comment
"use strict";
/*global alert */
}(jQuery));

but the same code where the comment `/*global alert */` inserted on the other place

/*global jQuery */
/*jslint unparam: true */
(function ($) {
/*any comment*/
//one more comment
/*global alert */
"use strict";
}(jQuery));

produces the errors

>Error:
>Problem at line 6 character 5: Missing 'use strict' statement.
>
>/*global alert */
>
>Problem at line 7 character 5: Use the function form of 'use strict'.
>
>"use strict";
>
>Problem at line 8 character 1: Expected '}' at column 5, not column 1.
>
>}(jQuery));
>
>Problem at line 8 character 1: Expected an identifier and instead saw '}'.
>
>}(jQuery));
>
>Problem at line 8 character 1: Stopping. (88% scanned).

From the point of view of the JavaScript language the second code is correct like the first one.

Best regards
Oleg