73rhodes / Sublime-JSLint

JSLint for Sublime Text 2 and 3.
80 stars 14 forks source link

Nested comment bug in JSLint + fix #16

Closed taoeffect closed 11 years ago

taoeffect commented 11 years ago

As explained here: http://stackoverflow.com/questions/14743275/how-do-i-get-rid-of-nested-comment-error-thrown-by-jslint

This should not cause JSLint to complain:

<!--[if lt IE 9]>
<script src="./js/lib/modernizr.custom.js"></script>
<![endif]-->

Fix:

--- /Users/gslepak/Library/Application Support/Sublime Text 2/Packages/JSLint/jslint.js 
+++ (clipboard) 
@@ -6,7 +6,7 @@
                                 if (i >= 0) {
                                     break;
                                 }
-                                i = source_row.indexOf('<!');
+                                i = source_row.indexOf('<!--');
                                 if (i >= 0) {
                                     stop_at('nested_comment',
                                         line, character + i);
@@ -15,7 +15,7 @@
                                     stop_at('unclosed_comment', length, c);
                                 }
                             }
-                            length = source_row.indexOf('<!');
+                            length = source_row.indexOf('<!--');
                             if (length >= 0 && length < i) {
                                 stop_at('nested_comment',
                                     line, character + length);

Please note, this fix was written without much error checking, it might cause something else to break, so please double-check.

darrenderidder commented 11 years ago

Sorry, but if you want this to change, you're going to have to take it up with the author of JSLint (Douglas Crockford).

taoeffect commented 11 years ago

Sent him an email with a link to this page cause I can't open an issue on his github project page. :-\