Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #1464: Correctly fix #1282 (relaxing maxlen for comments)

Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
  • Loading branch information...
commit c7959ffe9f69e0e3eb27732c400d6e4261088d31 1 parent 989da6e
@julienw julienw authored valueof committed
Showing with 10 additions and 1 deletion.
  1. +5 −1 src/lex.js
  2. +5 −0 tests/unit/fixtures/maxlen.js
View
6 src/lex.js
@@ -107,6 +107,7 @@ function Lexer(source) {
this.char = 1;
this.from = 1;
this.input = "";
+ this.inComment = false;
for (var i = 0; i < state.option.indent; i += 1) {
state.tab += " ";
@@ -447,6 +448,7 @@ Lexer.prototype = {
/* Multi-line comment */
if (ch2 === "*") {
+ this.inComment = true;
this.skip(2);
while (this.peek() !== "*" || this.peek(1) !== "/") {
@@ -462,6 +464,7 @@ Lexer.prototype = {
character: startChar
});
+ this.inComment = false;
return commentToken("/*", body, {
isMultiline: true,
isMalformed: true
@@ -474,6 +477,7 @@ Lexer.prototype = {
}
this.skip(2);
+ this.inComment = false;
return commentToken("/*", body, { isMultiline: true });
}
},
@@ -1350,7 +1354,7 @@ Lexer.prototype = {
// long.
if (state.option.maxlen && state.option.maxlen < this.input.length) {
- var inComment = state.tokens.curr.comment ||
+ var inComment = this.inComment ||
startsWith.call(inputTrimmed, "//") ||
startsWith.call(inputTrimmed, "/*");
View
5 tests/unit/fixtures/maxlen.js
@@ -7,6 +7,11 @@ var someCode; // http://jshint.com/docs/
// http://jshint.com/docs/
/* http://jshint.com/docs/
*/
+a = 23;
/*
* http://jshint.com/docs/
*/
+a = 23;
+/*
+ http://jshint.com/docs/
+ */
Please sign in to comment.
Something went wrong with that request. Please try again.