Add jscs "disallowUnusedVariables" rule.

This commit is contained in:
John-David Dalton
2016-04-14 12:45:18 -07:00
parent da7f413f6f
commit f6c14ec31f
5 changed files with 23 additions and 46 deletions

View File

@@ -84,6 +84,7 @@
"disallowSpacesInsideArrayBrackets": true, "disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true, "disallowSpacesInsideParentheses": true,
"disallowTrailingWhitespace": true, "disallowTrailingWhitespace": true,
"disallowUnusedVariables": true,
"jsDoc": { "jsDoc": {
"checkRedundantAccess": true, "checkRedundantAccess": true,

View File

@@ -1,7 +1,6 @@
'use strict'; 'use strict';
var _ = require('lodash'), var async = require('async'),
async = require('async'),
path = require('path'); path = require('path');
var file = require('../common/file'); var file = require('../common/file');

View File

@@ -82,12 +82,6 @@
/** Used to queue benchmark suites. */ /** Used to queue benchmark suites. */
var suites = []; var suites = [];
/** Used to resolve a value's internal [[Class]]. */
var toString = Object.prototype.toString;
/** Detect if in a browser environment. */
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
/** Use a single "load" function. */ /** Use a single "load" function. */
var load = (typeof require == 'function' && !amd) var load = (typeof require == 'function' && !amd)
? require ? require

View File

@@ -833,21 +833,17 @@
QUnit.module('set methods'); QUnit.module('set methods');
(function() { (function() {
var array = [1, 2, 3],
object = { 'a': 1 },
deepObject = { 'a': { 'b': 2, 'c': 3 } };
QUnit.test('should only clone objects in `path`', function(assert) { QUnit.test('should only clone objects in `path`', function(assert) {
assert.expect(11); assert.expect(11);
var object = { 'a': { 'b': { 'c': 1 }, 'd': { 'e': 1 } } }, var object = { 'a': { 'b': 2, 'c': 3 }, 'd': { 'e': 4 } },
value = _.cloneDeep(object), value = _.cloneDeep(object),
actual = fp.set('a.b.c.d.e', 3, value); actual = fp.set('a.b.c.d', 5, value);
assert.ok(_.isObject(actual.a.b.c), 'fp.set'); assert.ok(_.isObject(actual.a.b), 'fp.set');
assert.ok(_.isNumber(actual.a.b.c), 'fp.set'); assert.ok(_.isNumber(actual.a.b), 'fp.set');
assert.strictEqual(actual.a.b.c.d.e, 3, 'fp.set'); assert.strictEqual(actual.a.b.c.d, 5, 'fp.set');
assert.strictEqual(actual.d, value.d, 'fp.set'); assert.strictEqual(actual.d, value.d, 'fp.set');
value = _.cloneDeep(object); value = _.cloneDeep(object);
@@ -858,16 +854,16 @@
value = _.cloneDeep(object); value = _.cloneDeep(object);
actual = fp.unset('a.b')(value); actual = fp.unset('a.b')(value);
assert.notOk('b' in actual, 'fp.unset'); assert.notOk('b' in actual.a, 'fp.unset');
assert.strictEqual(actual.d, value.d, 'fp.unset'); assert.strictEqual(actual.a.c, value.a.c, 'fp.unset');
value = _.cloneDeep(deepObject); value = _.cloneDeep(object);
actual = fp.update('a.b')(function(n) { return n * n; })(value); actual = fp.update('a.b')(function(n) { return n * n; })(value);
assert.strictEqual(actual.a.b, 4, 'fp.update'); assert.strictEqual(actual.a.b, 4, 'fp.update');
assert.strictEqual(actual.d, value.d, 'fp.update'); assert.strictEqual(actual.d, value.d, 'fp.update');
value = _.cloneDeep(deepObject); value = _.cloneDeep(object);
actual = fp.updateWith(Object)('[0][1]')(_.constant('a'))(value); actual = fp.updateWith(Object)('[0][1]')(_.constant('a'))(value);
assert.deepEqual(actual[0], { '1': 'a' }, 'fp.updateWith'); assert.deepEqual(actual[0], { '1': 'a' }, 'fp.updateWith');
@@ -880,8 +876,7 @@
QUnit.module('with methods'); QUnit.module('with methods');
(function() { (function() {
var array = [1, 2, 3], var object = { 'a': 1 };
object = { 'a': 1 };
QUnit.test('should provide the correct `customizer` arguments', function(assert) { QUnit.test('should provide the correct `customizer` arguments', function(assert) {
assert.expect(7); assert.expect(7);
@@ -1316,7 +1311,7 @@
var args, var args,
object = { 'a': 1 }; object = { 'a': 1 };
var actual = fp.mapKeys(function() { fp.mapKeys(function() {
args || (args = slice.call(arguments)); args || (args = slice.call(arguments));
}, object); }, object);

View File

@@ -33,7 +33,6 @@
/** Used for native method references. */ /** Used for native method references. */
var arrayProto = Array.prototype, var arrayProto = Array.prototype,
errorProto = Error.prototype,
funcProto = Function.prototype, funcProto = Function.prototype,
objectProto = Object.prototype, objectProto = Object.prototype,
numberProto = Number.prototype, numberProto = Number.prototype,
@@ -62,7 +61,6 @@
var ArrayBuffer = root.ArrayBuffer, var ArrayBuffer = root.ArrayBuffer,
Buffer = root.Buffer, Buffer = root.Buffer,
DataView = root.DataView,
Promise = root.Promise, Promise = root.Promise,
Map = root.Map, Map = root.Map,
Set = root.Set, Set = root.Set,
@@ -5643,8 +5641,7 @@
lodashStable.each(['find', 'findLast', 'findIndex', 'findLastIndex', 'findKey', 'findLastKey'], function(methodName) { lodashStable.each(['find', 'findLast', 'findIndex', 'findLastIndex', 'findKey', 'findLastKey'], function(methodName) {
QUnit.module('lodash.' + methodName); QUnit.module('lodash.' + methodName);
var func = _[methodName], var func = _[methodName];
isFindKey = /Key$/.test(methodName);
(function() { (function() {
var objects = [ var objects = [
@@ -5888,7 +5885,6 @@
lodashStable.each(['flatMap', 'flatMapDeep', 'flatMapDepth'], function(methodName) { lodashStable.each(['flatMap', 'flatMapDeep', 'flatMapDepth'], function(methodName) {
var func = _[methodName], var func = _[methodName],
isDeep = methodName == 'flatMapDeep',
array = [1, 2, 3, 4]; array = [1, 2, 3, 4];
function duplicate(n) { function duplicate(n) {
@@ -6510,7 +6506,6 @@
lodashStable.each(lodashStable.difference(methods, unwrappedMethods), function(methodName) { lodashStable.each(lodashStable.difference(methods, unwrappedMethods), function(methodName) {
var array = [1, 2, 3], var array = [1, 2, 3],
func = _[methodName],
isBaseEach = methodName == '_baseEach'; isBaseEach = methodName == '_baseEach';
QUnit.test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', function(assert) { QUnit.test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', function(assert) {
@@ -6527,8 +6522,7 @@
}); });
lodashStable.each(unwrappedMethods, function(methodName) { lodashStable.each(unwrappedMethods, function(methodName) {
var array = [1, 2, 3], var array = [1, 2, 3];
func = _[methodName];
QUnit.test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function(assert) { QUnit.test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function(assert) {
assert.expect(1); assert.expect(1);
@@ -6559,8 +6553,7 @@
}); });
lodashStable.each(lodashStable.difference(methods, arrayMethods, forInMethods), function(methodName) { lodashStable.each(lodashStable.difference(methods, arrayMethods, forInMethods), function(methodName) {
var array = [1, 2, 3], var func = _[methodName];
func = _[methodName];
QUnit.test('`_.' + methodName + '` iterates over own string keyed properties of objects', function(assert) { QUnit.test('`_.' + methodName + '` iterates over own string keyed properties of objects', function(assert) {
assert.expect(1); assert.expect(1);
@@ -6631,8 +6624,7 @@
}); });
lodashStable.each(methods, function(methodName) { lodashStable.each(methods, function(methodName) {
var array = [1, 2, 3], var func = _[methodName],
func = _[methodName],
isFind = /^find/.test(methodName), isFind = /^find/.test(methodName),
isSome = methodName == 'some', isSome = methodName == 'some',
isReduce = /^reduce/.test(methodName); isReduce = /^reduce/.test(methodName);
@@ -8254,7 +8246,7 @@
var actual = _.invokeMap(array, 'toUpperCase'); var actual = _.invokeMap(array, 'toUpperCase');
} catch (e) {} } catch (e) {}
assert.deepEqual(_.invokeMap(array, 'toUpperCase'), ['A', undefined, undefined, 'D']); assert.deepEqual(actual, ['A', undefined, undefined, 'D']);
}); });
QUnit.test('should not error on elements with missing properties', function(assert) { QUnit.test('should not error on elements with missing properties', function(assert) {
@@ -13316,8 +13308,7 @@
QUnit.module('lodash.mapKeys and lodash.mapValues'); QUnit.module('lodash.mapKeys and lodash.mapValues');
lodashStable.each(['mapKeys', 'mapValues'], function(methodName) { lodashStable.each(['mapKeys', 'mapValues'], function(methodName) {
var array = [1, 2], var func = _[methodName],
func = _[methodName],
object = { 'a': 1, 'b': 2 }; object = { 'a': 1, 'b': 2 };
QUnit.test('`_.' + methodName + '` should iterate over own string keyed properties of objects', function(assert) { QUnit.test('`_.' + methodName + '` should iterate over own string keyed properties of objects', function(assert) {
@@ -14865,9 +14856,9 @@
assert.expect(1); assert.expect(1);
var source1 = { 'a': { 'b': { 'c': 1 } } }, var source1 = { 'a': { 'b': { 'c': 1 } } },
source2 = { 'a': { 'b': { 'd': 2 } } }, source2 = { 'a': { 'b': { 'd': 2 } } };
actual = _.mergeWith({}, source1, source2, noop);
_.mergeWith({}, source1, source2, noop);
assert.deepEqual(source1.a.b, { 'c': 1 }); assert.deepEqual(source1.a.b, { 'c': 1 });
}); });
@@ -15233,8 +15224,7 @@
QUnit.module('extremum methods'); QUnit.module('extremum methods');
lodashStable.each(['max', 'maxBy', 'min', 'minBy'], function(methodName) { lodashStable.each(['max', 'maxBy', 'min', 'minBy'], function(methodName) {
var array = [1, 2, 3], var func = _[methodName],
func = _[methodName],
isMax = /^max/.test(methodName); isMax = /^max/.test(methodName);
QUnit.test('`_.' + methodName + '` should work with Date objects', function(assert) { QUnit.test('`_.' + methodName + '` should work with Date objects', function(assert) {
@@ -24223,8 +24213,7 @@
lodashStable.each(['update', 'updateWith'], function(methodName) { lodashStable.each(['update', 'updateWith'], function(methodName) {
var func = _[methodName], var func = _[methodName],
oldValue = 1, oldValue = 1;
value = 2;
QUnit.test('`_.' + methodName + '` should invoke `updater` with the value on `path` of `object`', function(assert) { QUnit.test('`_.' + methodName + '` should invoke `updater` with the value on `path` of `object`', function(assert) {
assert.expect(4); assert.expect(4);
@@ -24610,7 +24599,6 @@
lodashStable.each(['zipObject', 'zipObjectDeep'], function(methodName) { lodashStable.each(['zipObject', 'zipObjectDeep'], function(methodName) {
var func = _[methodName], var func = _[methodName],
array = [['barney', 36], ['fred', 40]],
object = { 'barney': 36, 'fred': 40 }, object = { 'barney': 36, 'fred': 40 },
isDeep = methodName == 'zipObjectDeep'; isDeep = methodName == 'zipObjectDeep';