From fc35190d385d6b079586bd7e016a8a0679dc19ba Mon Sep 17 00:00:00 2001 From: Luke Page Date: Sat, 20 Jul 2013 22:44:13 +0100 Subject: [PATCH] unused variable cleanup --- .jshintrc | 4 +++- lib/less/index.js | 7 +------ lib/less/parser.js | 32 +++++++++++++------------------- lib/less/rhino.js | 4 ++-- lib/less/tree/dimension.js | 2 +- lib/less/tree/import.js | 2 -- lib/less/tree/mixin.js | 4 ++-- lib/less/tree/ruleset.js | 2 +- lib/less/visitor.js | 3 +-- test/browser-test-prepare.js | 3 +-- test/less-test.js | 2 +- 11 files changed, 26 insertions(+), 39 deletions(-) diff --git a/.jshintrc b/.jshintrc index 2265f328..2f830954 100644 --- a/.jshintrc +++ b/.jshintrc @@ -3,5 +3,7 @@ "boss": true, "expr": true, "laxbreak": true, - "node": true + "node": true, + "unused": "vars", + "noarg": true } diff --git a/lib/less/index.js b/lib/less/index.js index 30738d3c..cb95ca88 100644 --- a/lib/less/index.js +++ b/lib/less/index.js @@ -146,12 +146,7 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) { } var urlStr = isUrl ? file : url.resolve(currentFileInfo.currentDirectory, file), - urlObj = url.parse(urlStr), - req = { - host: urlObj.hostname, - port: urlObj.port || 80, - path: urlObj.pathname + (urlObj.search||'') - }; + urlObj = url.parse(urlStr); request.get(urlStr, function (error, res, body) { if (res.statusCode === 404) { diff --git a/lib/less/parser.js b/lib/less/parser.js index 249a10ed..de37ec34 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -1,6 +1,5 @@ var less, tree; -/*global environment */ // Node.js does not have a header file added which defines less if (less === undefined) { less = exports; @@ -51,8 +50,6 @@ less.Parser = function Parser(env) { current, // index of current chunk, in `input` parser; - var that = this; - // Top parser on an import tree must be sure there is one "env" // which will then be passed around by reference. if (!(env instanceof tree.parseEnv)) { @@ -128,7 +125,7 @@ less.Parser = function Parser(env) { // Parse from a token, regexp or string, and move forward if match // function $(tok) { - var match, args, length, index, k; + var match, length; // // Non-terminal @@ -300,7 +297,7 @@ less.Parser = function Parser(env) { // call `callback` when done. // parse: function (str, callback) { - var root, start, end, zone, line, lines, buff = [], c, error = null; + var root, line, lines, error = null; i = j = current = furthest = 0; input = str.replace(/\r\n/g, '\n'); @@ -418,12 +415,9 @@ less.Parser = function Parser(env) { } root.toCSS = (function (evaluate) { - var line, lines, column; - return function (options, variables) { options = options || {}; - var importError, - evaldRoot, + var evaldRoot, css, evalEnv = new tree.evalEnv(options); @@ -779,7 +773,7 @@ less.Parser = function Parser(env) { // A variable entity useing the protective {} e.g. @{var} variableCurly: function () { - var name, curly, index = i; + var curly, index = i; if (input.charAt(i) === '@' && (curly = $(/^@\{([\w-]+)\}/))) { return new(tree.Variable)("@" + curly[1], index, env.currentFileInfo); @@ -921,7 +915,7 @@ less.Parser = function Parser(env) { // selector for now. // call: function () { - var elements = [], e, c, args, delim, arg, index = i, s = input.charAt(i), important = false; + var elements = [], e, c, args, index = i, s = input.charAt(i), important = false; if (s !== '.' && s !== '#') { return; } @@ -1065,7 +1059,7 @@ less.Parser = function Parser(env) { // the `{...}` block. // definition: function () { - var name, params = [], match, ruleset, param, value, cond, variadic = false; + var name, params = [], match, ruleset, cond, variadic = false; if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') || peek(/^[^{]*\}/)) { return; @@ -1151,7 +1145,7 @@ less.Parser = function Parser(env) { // and an element name, such as a tag a class, or `*`. // element: function () { - var e, t, c, v; + var e, c, v; c = $(this.combinator); @@ -1208,7 +1202,7 @@ less.Parser = function Parser(env) { // Selectors are made out of one or more Elements, see above. // selector: function (isLess) { - var sel, e, elements = [], c, extend, extendList = [], when, condition; + var e, elements = [], c, extend, extendList = [], when, condition; while ((isLess && (extend = $(this.extend))) || (isLess && (when = $(/^when/))) || (e = $(this.element))) { if (when) { @@ -1234,7 +1228,7 @@ less.Parser = function Parser(env) { if (extendList.length) { error("Extend must be used to extend a selector, it cannot be used on its own"); } }, attribute: function () { - var attr = '', key, val, op; + var key, val, op; if (! $('[')) { return; } @@ -1467,7 +1461,7 @@ less.Parser = function Parser(env) { // @charset "utf-8"; // directive: function () { - var name, value, rules, identifier, e, nodes, nonVendorSpecificName, + var name, value, rules, nonVendorSpecificName, hasBlock, hasIdentifier, hasExpression; if (input.charAt(i) !== '@') { return; } @@ -1553,7 +1547,7 @@ less.Parser = function Parser(env) { // and before the `;`. // value: function () { - var e, expressions = [], important; + var e, expressions = []; while (e = $(this.expression)) { expressions.push(e); @@ -1582,7 +1576,7 @@ less.Parser = function Parser(env) { } }, multiplication: function () { - var m, a, op, operation, isSpaced, expression = []; + var m, a, op, operation, isSpaced; if (m = $(this.operand)) { isSpaced = isWhitespace(input.charAt(i - 1)); while (!peek(/^\/[*\/]/) && (op = ($('/') || $('*')))) { @@ -1670,7 +1664,7 @@ less.Parser = function Parser(env) { // @var * 2 // expression: function () { - var e, delim, entities = [], d; + var e, delim, entities = []; while (e = $(this.addition) || $(this.entity)) { entities.push(e); diff --git a/lib/less/rhino.js b/lib/less/rhino.js index 08eba88a..5feb2e74 100644 --- a/lib/less/rhino.js +++ b/lib/less/rhino.js @@ -1,5 +1,5 @@ -/*jshint rhino:true */ -/*global name:true, less */ +/*jshint rhino:true, unused: false */ +/*global name:true, less, loadStyleSheet */ var name; function loadStyleSheet(sheet, callback, reload, remaining) { diff --git a/lib/less/tree/dimension.js b/lib/less/tree/dimension.js index 2097e128..7d5044d9 100644 --- a/lib/less/tree/dimension.js +++ b/lib/less/tree/dimension.js @@ -113,7 +113,7 @@ tree.Dimension.prototype = { convertTo: function (conversions) { var value = this.value, unit = this.unit.clone(), - i, groupName, group, conversion, targetUnit, derivedConversions = {}, applyUnit; + i, groupName, group, targetUnit, derivedConversions = {}, applyUnit; if (typeof conversions === 'string') { for(i in tree.UnitConversions) { diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index b917d6c0..8a8326f6 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -12,8 +12,6 @@ // the file has been fetched, and parsed. // tree.Import = function (path, features, options, index, currentFileInfo) { - var that = this; - this.options = options; this.index = index; this.path = path; diff --git a/lib/less/tree/mixin.js b/lib/less/tree/mixin.js index 470bce34..cd8bf173 100644 --- a/lib/less/tree/mixin.js +++ b/lib/less/tree/mixin.js @@ -193,7 +193,7 @@ tree.mixin.Definition.prototype = { var _arguments = [], mixinFrames = this.frames.concat(env.frames), frame = this.evalParams(env, new(tree.evalEnv)(env, mixinFrames), args, _arguments), - context, rules, start, ruleset; + rules, ruleset; frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env))); @@ -216,7 +216,7 @@ tree.mixin.Definition.prototype = { return true; }, matchArgs: function (args, env) { - var argsLength = (args && args.length) || 0, len, frame; + var argsLength = (args && args.length) || 0, len; if (! this.variadic) { if (argsLength < this.required) { return false; } diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index e6034c3a..25a92e38 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -435,7 +435,7 @@ tree.Ruleset.prototype = { }, mergeElementsOnToSelectors: function(elements, selectors) { - var i, sel, extendList; + var i, sel; if (selectors.length === 0) { selectors.push([ new(tree.Selector)(elements) ]); diff --git a/lib/less/visitor.js b/lib/less/visitor.js index 5a4cd402..52f734f1 100644 --- a/lib/less/visitor.js +++ b/lib/less/visitor.js @@ -35,12 +35,11 @@ return node; }, visitArray: function(nodes) { - var i, newNodes = [], visitor = this; + var i, newNodes = []; for(i = 0; i < nodes.length; i++) { var evald = this.visit(nodes[i]); if (evald instanceof Array) { evald = this.flatten(evald); - //evald.forEach(this.doAccept, this); newNodes = newNodes.concat(evald); } else { newNodes.push(evald); diff --git a/test/browser-test-prepare.js b/test/browser-test-prepare.js index 644ac6ff..95a99703 100644 --- a/test/browser-test-prepare.js +++ b/test/browser-test-prepare.js @@ -1,6 +1,5 @@ var path = require('path'), - fs = require('fs'), - sys = require('util'); + fs = require('fs'); var readDirFilesSync = function(dir, regex, callback) { fs.readdirSync(dir).forEach(function (file) { diff --git a/test/less-test.js b/test/less-test.js index bb787131..a1e10be8 100644 --- a/test/less-test.js +++ b/test/less-test.js @@ -220,7 +220,7 @@ function endTest() { } function toCSS(options, path, callback) { - var tree, css; + var css; options = options || {}; fs.readFile(path, 'utf8', function (e, str) { if (e) { return callback(e); }