mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Add jscs "disallowUnusedVariables" rule.
This commit is contained in:
1
.jscsrc
1
.jscsrc
@@ -84,6 +84,7 @@
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowUnusedVariables": true,
|
||||
|
||||
"jsDoc": {
|
||||
"checkRedundantAccess": true,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
var async = require('async'),
|
||||
path = require('path');
|
||||
|
||||
var file = require('../common/file');
|
||||
|
||||
@@ -82,12 +82,6 @@
|
||||
/** Used to queue benchmark 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. */
|
||||
var load = (typeof require == 'function' && !amd)
|
||||
? require
|
||||
|
||||
@@ -833,21 +833,17 @@
|
||||
QUnit.module('set methods');
|
||||
|
||||
(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) {
|
||||
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),
|
||||
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(_.isNumber(actual.a.b.c), 'fp.set');
|
||||
assert.ok(_.isObject(actual.a.b), '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');
|
||||
|
||||
value = _.cloneDeep(object);
|
||||
@@ -858,16 +854,16 @@
|
||||
value = _.cloneDeep(object);
|
||||
actual = fp.unset('a.b')(value);
|
||||
|
||||
assert.notOk('b' in actual, 'fp.unset');
|
||||
assert.strictEqual(actual.d, value.d, 'fp.unset');
|
||||
assert.notOk('b' in actual.a, '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);
|
||||
|
||||
assert.strictEqual(actual.a.b, 4, '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);
|
||||
|
||||
assert.deepEqual(actual[0], { '1': 'a' }, 'fp.updateWith');
|
||||
@@ -880,8 +876,7 @@
|
||||
QUnit.module('with methods');
|
||||
|
||||
(function() {
|
||||
var array = [1, 2, 3],
|
||||
object = { 'a': 1 };
|
||||
var object = { 'a': 1 };
|
||||
|
||||
QUnit.test('should provide the correct `customizer` arguments', function(assert) {
|
||||
assert.expect(7);
|
||||
@@ -1316,7 +1311,7 @@
|
||||
var args,
|
||||
object = { 'a': 1 };
|
||||
|
||||
var actual = fp.mapKeys(function() {
|
||||
fp.mapKeys(function() {
|
||||
args || (args = slice.call(arguments));
|
||||
}, object);
|
||||
|
||||
|
||||
32
test/test.js
32
test/test.js
@@ -33,7 +33,6 @@
|
||||
|
||||
/** Used for native method references. */
|
||||
var arrayProto = Array.prototype,
|
||||
errorProto = Error.prototype,
|
||||
funcProto = Function.prototype,
|
||||
objectProto = Object.prototype,
|
||||
numberProto = Number.prototype,
|
||||
@@ -62,7 +61,6 @@
|
||||
|
||||
var ArrayBuffer = root.ArrayBuffer,
|
||||
Buffer = root.Buffer,
|
||||
DataView = root.DataView,
|
||||
Promise = root.Promise,
|
||||
Map = root.Map,
|
||||
Set = root.Set,
|
||||
@@ -5643,8 +5641,7 @@
|
||||
lodashStable.each(['find', 'findLast', 'findIndex', 'findLastIndex', 'findKey', 'findLastKey'], function(methodName) {
|
||||
QUnit.module('lodash.' + methodName);
|
||||
|
||||
var func = _[methodName],
|
||||
isFindKey = /Key$/.test(methodName);
|
||||
var func = _[methodName];
|
||||
|
||||
(function() {
|
||||
var objects = [
|
||||
@@ -5888,7 +5885,6 @@
|
||||
|
||||
lodashStable.each(['flatMap', 'flatMapDeep', 'flatMapDepth'], function(methodName) {
|
||||
var func = _[methodName],
|
||||
isDeep = methodName == 'flatMapDeep',
|
||||
array = [1, 2, 3, 4];
|
||||
|
||||
function duplicate(n) {
|
||||
@@ -6510,7 +6506,6 @@
|
||||
|
||||
lodashStable.each(lodashStable.difference(methods, unwrappedMethods), function(methodName) {
|
||||
var array = [1, 2, 3],
|
||||
func = _[methodName],
|
||||
isBaseEach = methodName == '_baseEach';
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', function(assert) {
|
||||
@@ -6527,8 +6522,7 @@
|
||||
});
|
||||
|
||||
lodashStable.each(unwrappedMethods, function(methodName) {
|
||||
var array = [1, 2, 3],
|
||||
func = _[methodName];
|
||||
var array = [1, 2, 3];
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function(assert) {
|
||||
assert.expect(1);
|
||||
@@ -6559,8 +6553,7 @@
|
||||
});
|
||||
|
||||
lodashStable.each(lodashStable.difference(methods, arrayMethods, forInMethods), function(methodName) {
|
||||
var array = [1, 2, 3],
|
||||
func = _[methodName];
|
||||
var func = _[methodName];
|
||||
|
||||
QUnit.test('`_.' + methodName + '` iterates over own string keyed properties of objects', function(assert) {
|
||||
assert.expect(1);
|
||||
@@ -6631,8 +6624,7 @@
|
||||
});
|
||||
|
||||
lodashStable.each(methods, function(methodName) {
|
||||
var array = [1, 2, 3],
|
||||
func = _[methodName],
|
||||
var func = _[methodName],
|
||||
isFind = /^find/.test(methodName),
|
||||
isSome = methodName == 'some',
|
||||
isReduce = /^reduce/.test(methodName);
|
||||
@@ -8254,7 +8246,7 @@
|
||||
var actual = _.invokeMap(array, 'toUpperCase');
|
||||
} 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) {
|
||||
@@ -13316,8 +13308,7 @@
|
||||
QUnit.module('lodash.mapKeys and lodash.mapValues');
|
||||
|
||||
lodashStable.each(['mapKeys', 'mapValues'], function(methodName) {
|
||||
var array = [1, 2],
|
||||
func = _[methodName],
|
||||
var func = _[methodName],
|
||||
object = { 'a': 1, 'b': 2 };
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should iterate over own string keyed properties of objects', function(assert) {
|
||||
@@ -14865,9 +14856,9 @@
|
||||
assert.expect(1);
|
||||
|
||||
var source1 = { 'a': { 'b': { 'c': 1 } } },
|
||||
source2 = { 'a': { 'b': { 'd': 2 } } },
|
||||
actual = _.mergeWith({}, source1, source2, noop);
|
||||
source2 = { 'a': { 'b': { 'd': 2 } } };
|
||||
|
||||
_.mergeWith({}, source1, source2, noop);
|
||||
assert.deepEqual(source1.a.b, { 'c': 1 });
|
||||
});
|
||||
|
||||
@@ -15233,8 +15224,7 @@
|
||||
QUnit.module('extremum methods');
|
||||
|
||||
lodashStable.each(['max', 'maxBy', 'min', 'minBy'], function(methodName) {
|
||||
var array = [1, 2, 3],
|
||||
func = _[methodName],
|
||||
var func = _[methodName],
|
||||
isMax = /^max/.test(methodName);
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with Date objects', function(assert) {
|
||||
@@ -24223,8 +24213,7 @@
|
||||
|
||||
lodashStable.each(['update', 'updateWith'], function(methodName) {
|
||||
var func = _[methodName],
|
||||
oldValue = 1,
|
||||
value = 2;
|
||||
oldValue = 1;
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should invoke `updater` with the value on `path` of `object`', function(assert) {
|
||||
assert.expect(4);
|
||||
@@ -24610,7 +24599,6 @@
|
||||
|
||||
lodashStable.each(['zipObject', 'zipObjectDeep'], function(methodName) {
|
||||
var func = _[methodName],
|
||||
array = [['barney', 36], ['fred', 40]],
|
||||
object = { 'barney': 36, 'fred': 40 },
|
||||
isDeep = methodName == 'zipObjectDeep';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user