LearnBoost/stylus — pull request #1017 by mcandre (2013-05-09 02:45:52+00:00)
Title: Linting with JSHint

I applied [JSHint](http://jshint.com/) to look for potential bugs, running `jshint .` against the code base. There were a number of stylistic warnings present, common enough that I treated them as a code style for this project in `.jshintrc`. The rest number just under 200:

$ jshint .
bm.js: line 42, col 6, Don't make functions within a loop.

examples/js-functions.js: line 41, col 28, 'w' used out of scope.
examples/js-functions.js: line 42, col 28, 'h' used out of scope.

lib/convert/css.js: line 123, col 32, ['_importants'] is better written in dot notation.

lib/errors.js: line 19, col 32, The '__proto__' property is deprecated.
lib/errors.js: line 38, col 31, The '__proto__' property is deprecated.
lib/errors.js: line 57, col 32, The '__proto__' property is deprecated.

lib/functions/image.js: line 100, col 7, Unreachable 'break' after 'throw'.

lib/functions/index.js: line 172, col 12, 'name' is already defined.
lib/functions/index.js: line 175, col 12, 'name' is already defined.
lib/functions/index.js: line 319, col 17, 'color' is already defined.
lib/functions/index.js: line 467, col 34, 'unit' is already defined.
lib/functions/index.js: line 567, col 5, Missing semicolon.
lib/functions/index.js: line 752, col 11, 'img' is already defined.

lib/functions/url.js: line 55, col 24, Use '!==' to compare with 'null'.
lib/functions/url.js: line 93, col 4, Unnecessary semicolon.

lib/lexer.js: line 68, col 4, Unnecessary semicolon.
lib/lexer.js: line 76, col 2, Unnecessary semicolon.
lib/lexer.js: line 229, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 241, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 253, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 265, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 279, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 284, col 16, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 304, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 316, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 329, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 345, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 362, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 382, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 430, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 447, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 459, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 471, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 483, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 495, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 519, col 15, 'end' is already defined.
lib/lexer.js: line 541, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 556, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 572, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 653, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 668, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 687, col 18, Missing semicolon.
lib/lexer.js: line 696, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 711, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 726, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 744, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 763, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 781, col 18, Expected a conditional expression and instead saw an assignment.
lib/lexer.js: line 800, col 18, Expected a conditional expression and instead saw an assignment.

lib/middleware.js: line 116, col 7, Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
lib/middleware.js: line 126, col 7, Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
lib/middleware.js: line 183, col 4, Missing semicolon.

lib/nodes/arguments.js: line 31, col 30, The '__proto__' property is deprecated.

lib/nodes/binop.js: line 34, col 26, The '__proto__' property is deprecated.

lib/nodes/block.js: line 33, col 26, The '__proto__' property is deprecated.

lib/nodes/boolean.js: line 22, col 5, Redefinition of 'Boolean'.
lib/nodes/boolean.js: line 27, col 12, Do not use Boolean as a constructor.
lib/nodes/boolean.js: line 35, col 28, The '__proto__' property is deprecated.
lib/nodes/boolean.js: line 78, col 10, Do not use Boolean as a constructor.

lib/nodes/call.js: line 32, col 25, The '__proto__' property is deprecated.

lib/nodes/charset.js: line 31, col 28, The '__proto__' property is deprecated.

lib/nodes/comment.js: line 32, col 28, The '__proto__' property is deprecated.

lib/nodes/each.js: line 38, col 25, The '__proto__' property is deprecated.

lib/nodes/expression.js: line 70, col 31, The '__proto__' property is deprecated.
lib/nodes/expression.js: line 115, col 15, 'val' is already defined.
lib/nodes/expression.js: line 129, col 17, 'range' is already defined.
lib/nodes/expression.js: line 148, col 15, 'len' is already defined.
lib/nodes/expression.js: line 149, col 17, 'right' is already defined.
lib/nodes/expression.js: line 160, col 7, Unreachable 'break' after 'return'.

lib/nodes/extend.js: line 30, col 27, The '__proto__' property is deprecated.

lib/nodes/fontface.js: line 30, col 29, The '__proto__' property is deprecated.

lib/nodes/function.js: line 23, col 5, Redefinition of 'Function'.
lib/nodes/function.js: line 46, col 29, The '__proto__' property is deprecated.
lib/nodes/function.js: line 68, col 29, The Function constructor is a form of eval.
lib/nodes/function.js: line 72, col 15, 'clone' is already defined.
lib/nodes/function.js: line 72, col 29, The Function constructor is a form of eval.
lib/nodes/function.js: line 77, col 3, 'clone' used out of scope.
lib/nodes/function.js: line 78, col 3, 'clone' used out of scope.
lib/nodes/function.js: line 79, col 10, 'clone' used out of scope.

lib/nodes/group.js: line 30, col 26, The '__proto__' property is deprecated.

lib/nodes/hsla.js: line 25, col 12, Variable exports was not declared correctly.
lib/nodes/hsla.js: line 38, col 25, The '__proto__' property is deprecated.
lib/nodes/hsla.js: line 182, col 20, A leading decimal point can be confused with a dot: '.5'.

lib/nodes/ident.js: line 38, col 20, Use '===' to compare with 'undefined'.
lib/nodes/ident.js: line 56, col 26, The '__proto__' property is deprecated.
lib/nodes/ident.js: line 122, col 7, Expected a 'break' statement before 'case'.

lib/nodes/if.js: line 37, col 23, The '__proto__' property is deprecated.

lib/nodes/import.js: line 30, col 27, The '__proto__' property is deprecated.

lib/nodes/jsliteral.js: line 32, col 30, The '__proto__' property is deprecated.

lib/nodes/keyframes.js: line 34, col 30, The '__proto__' property is deprecated.

lib/nodes/literal.js: line 32, col 28, The '__proto__' property is deprecated.

lib/nodes/media.js: line 31, col 26, The '__proto__' property is deprecated.

lib/nodes/mozdocument.js: line 9, col 32, The '__proto__' property is deprecated.
lib/nodes/mozdocument.js: line 19, col 2, Missing semicolon.

lib/nodes/node.js: line 78, col 21, eval can be harmful.
lib/nodes/node.js: line 143, col 7, Expected a 'break' statement before 'case'.
lib/nodes/node.js: line 184, col 17, 'msg' is already defined.
lib/nodes/node.js: line 189, col 23, 'msg' used out of scope.
lib/nodes/node.js: line 201, col 30, Missing semicolon.
lib/nodes/node.js: line 202, col 21, Missing semicolon.
lib/nodes/node.js: line 210, col 34, The '__proto__' property is deprecated.

lib/nodes/null.js: line 27, col 25, The '__proto__' property is deprecated.

lib/nodes/page.js: line 32, col 25, The '__proto__' property is deprecated.

lib/nodes/params.js: line 43, col 27, The '__proto__' property is deprecated.

lib/nodes/property.js: line 32, col 29, The '__proto__' property is deprecated.

lib/nodes/return.js: line 30, col 27, The '__proto__' property is deprecated.

lib/nodes/rgba.js: line 28, col 12, Variable exports was not declared correctly.
lib/nodes/rgba.js: line 41, col 25, The '__proto__' property is deprecated.
lib/nodes/rgba.js: line 210, col 11, Expected a 'break' statement before 'case'.
lib/nodes/rgba.js: line 220, col 17, 'n' is already defined.
lib/nodes/rgba.js: line 225, col 11, Expected a 'break' statement before 'case'.
lib/nodes/rgba.js: line 296, col 19, A leading decimal point can be confused with a dot: '.5'.

lib/nodes/root.js: line 28, col 25, The '__proto__' property is deprecated.

lib/nodes/selector.js: line 32, col 29, The '__proto__' property is deprecated.

lib/nodes/string.js: line 25, col 5, Redefinition of 'String'.
lib/nodes/string.js: line 36, col 27, The '__proto__' property is deprecated.
lib/nodes/string.js: line 57, col 15, Do not use String as a constructor.
lib/nodes/string.js: line 87, col 14, Do not use String as a constructor.
lib/nodes/string.js: line 91, col 14, Do not use String as a constructor.
lib/nodes/string.js: line 118, col 14, Do not use String as a constructor.

lib/nodes/ternary.js: line 34, col 28, The '__proto__' property is deprecated.

lib/nodes/unaryop.js: line 32, col 28, The '__proto__' property is deprecated.

lib/nodes/unit.js: line 34, col 25, The '__proto__' property is deprecated.
lib/nodes/unit.js: line 163, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 170, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 177, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 182, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 187, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 192, col 9, Expected a 'break' statement before 'case'.
lib/nodes/unit.js: line 197, col 9, Expected a 'break' statement before 'default'.

lib/parser.js: line 162, col 13, It's not necessary to initialize 'val' to 'undefined'.
lib/parser.js: line 162, col 25, Use '===' to compare with 'undefined'.
lib/parser.js: line 286, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 308, col 19, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 479, col 19, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 648, col 3, Unexpected 'for'.
lib/parser.js: line 665, col 3, Unexpected 'return'.
lib/parser.js: line 690, col 3, Unexpected 'if'.
lib/parser.js: line 834, col 16, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 930, col 9, Expected a 'break' statement before 'case'.
lib/parser.js: line 978, col 9, Expected a 'break' statement before 'default'.
lib/parser.js: line 1018, col 23, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1020, col 23, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1098, col 16, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1142, col 12, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1152, col 96, Missing semicolon.
lib/parser.js: line 1189, col 16, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1277, col 16, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1342, col 17, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1384, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1397, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1413, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1426, col 3, Unexpected 'in'.
lib/parser.js: line 1444, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1465, col 12, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1481, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1496, col 15, Expected a conditional expression and instead saw an assignment.
lib/parser.js: line 1537, col 12, Expected a conditional expression and instead saw an assignment.

lib/renderer.js: line 45, col 2, Unnecessary semicolon.
lib/renderer.js: line 51, col 29, The '__proto__' property is deprecated.
lib/renderer.js: line 168, col 17, Use '!==' to compare with 'undefined'.

lib/stack/frame.js: line 50, col 33, Missing semicolon.

lib/stack/index.js: line 28, col 26, The '__proto__' property is deprecated.
lib/stack/index.js: line 98, col 18, Expected a conditional expression and instead saw an assignment.
lib/stack/index.js: line 132, col 14, Expected a conditional expression and instead saw an assignment.

lib/token.js: line 22, col 13, Variable exports was not declared correctly.

lib/utils.js: line 91, col 15, 'context' is already defined.
lib/utils.js: line 97, col 15, 'context' is already defined.
lib/utils.js: line 231, col 16, Use '===' to compare with 'null'.
lib/utils.js: line 304, col 2, Missing semicolon.

lib/visitor/compiler.js: line 45, col 29, The '__proto__' property is deprecated.
lib/visitor/compiler.js: line 111, col 11, Expected a 'break' statement before 'default'.
lib/visitor/compiler.js: line 123, col 14, 'i' is already defined.
lib/visitor/compiler.js: line 123, col 23, 'len' is already defined.
lib/visitor/compiler.js: line 324, col 26, Use '===' to compare with '0'.
lib/visitor/compiler.js: line 516, col 20, Bad escaping.
lib/visitor/compiler.js: line 522, col 2, Missing semicolon.

lib/visitor/evaluator.js: line 79, col 30, The '__proto__' property is deprecated.
lib/visitor/evaluator.js: line 100, col 19, Value of 'err' may be overwritten in IE.
lib/visitor/evaluator.js: line 342, col 13, 'ret' is already defined.
lib/visitor/evaluator.js: line 396, col 14, Expected a conditional expression and instead saw an assignment.
lib/visitor/evaluator.js: line 670, col 14, Variable path was not declared correctly.
lib/visitor/evaluator.js: line 864, col 20, eval can be harmful.
lib/visitor/evaluator.js: line 927, col 26, eval can be harmful.
lib/visitor/evaluator.js: line 940, col 11, Expected a 'break' statement before 'case'.
lib/visitor/evaluator.js: line 944, col 43, eval can be harmful.
lib/visitor/evaluator.js: line 1055, col 11, Expected a conditional expression and instead saw an assignment.

lib/visitor/normalizer.js: line 43, col 31, The '__proto__' property is deprecated.
lib/visitor/normalizer.js: line 108, col 14, 'i' is already defined.
lib/visitor/normalizer.js: line 108, col 23, 'len' is already defined.
lib/visitor/normalizer.js: line 198, col 2, Missing semicolon.
lib/visitor/normalizer.js: line 220, col 68, Missing semicolon.

test/run.js: line 38, col 7, Missing semicolon.
test/run.js: line 40, col 3, Missing semicolon.

195 errors

I'm not familiar with the code base enough to resolve these yet, so I just thought I'd present the findings first. For example, `eval()` is probably okay in `lib/visitor/evaluator.js`. Feel free to write `{ "-W061": true }` in a new file, `lib/visitor/.jshintrc`, per the [docs](http://jslinterrors.com/eval-can-be-harmful/).