🌐 AI搜索 & 代理 主页
Skip to content

Commit 438b1a3

Browse files
authored
Build: ESLint: forbid unused function parameters
This commit requires all function parameters to be used, not just the last one. In cases where that's not possible as we need to match an external API, there's an escape hatch of prefixing an unused argument with `_`. This change makes it easier to catch unused AMD dependencies and unused parameters in internal functions the API of which we may change at will, among other things. Unused AMD dependencies have been removed as part of this commit. Closes gh-4381
1 parent 9ec09c3 commit 438b1a3

File tree

19 files changed

+27
-37
lines changed

19 files changed

+27
-37
lines changed

build/tasks/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ module.exports = function( grunt ) {
372372

373373
// Ask for permission the first time
374374
if ( insight.optOut === undefined ) {
375-
insight.askPermission( null, function( error, result ) {
375+
insight.askPermission( null, function( _error, result ) {
376376
exec( result );
377377
} );
378378
} else {

dist/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
// That is okay for the built version
88
"no-multiple-empty-lines": "off",
99

10-
// Because sizzle is not compatible to jquery code style
10+
// Sizzle is not compatible with jQuery code style
1111
"no-nested-ternary": "off",
1212
"no-unused-expressions": "off",
13+
"no-unused-vars": "off",
1314
"lines-around-comment": "off",
1415
"space-in-parens": "off",
1516
"camelcase": "off",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@babel/plugin-transform-for-of": "7.4.3",
3030
"commitplease": "3.2.0",
3131
"core-js-bundle": "3.0.0",
32-
"eslint-config-jquery": "1.0.1",
32+
"eslint-config-jquery": "2.0.0",
3333
"grunt": "1.0.4",
3434
"grunt-babel": "8.0.0",
3535
"grunt-cli": "1.3.2",

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ jQuery.extend( {
838838
}
839839
} );
840840

841-
jQuery.each( [ "get", "post" ], function( i, method ) {
841+
jQuery.each( [ "get", "post" ], function( _i, method ) {
842842
jQuery[ method ] = function( url, data, callback, type ) {
843843

844844
// Shift arguments if data argument was omitted

src/attributes/attr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ boolHook = {
119119
}
120120
};
121121

122-
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
122+
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
123123
var getter = attrHandle[ name ] || jQuery.find.attr;
124124

125125
attrHandle[ name ] = function( elem, name, isXML ) {

src/core.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
define( [
66
"./var/arr",
7-
"./var/document",
87
"./var/getProto",
98
"./var/slice",
109
"./var/concat",
@@ -20,7 +19,7 @@ define( [
2019
"./var/isWindow",
2120
"./core/DOMEval",
2221
"./core/toType"
23-
], function( arr, document, getProto, slice, concat, push, indexOf,
22+
], function( arr, getProto, slice, concat, push, indexOf,
2423
class2type, toString, hasOwn, fnToString, ObjectFunctionString,
2524
trim, support, isWindow, DOMEval, toType ) {
2625

@@ -365,7 +364,7 @@ if ( typeof Symbol === "function" ) {
365364

366365
// Populate the class2type map
367366
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
368-
function( i, name ) {
367+
function( _i, name ) {
369368
class2type[ "[object " + name + "]" ] = name.toLowerCase();
370369
} );
371370

src/core/access.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3737
// ...except when executing function values
3838
} else {
3939
bulk = fn;
40-
fn = function( elem, key, value ) {
40+
fn = function( elem, _key, value ) {
4141
return bulk.call( jQuery( elem ), value );
4242
};
4343
}

src/core/camelCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define( [], function() {
66
var rdashAlpha = /-([a-z])/g;
77

88
// Used by camelCase as callback to replace()
9-
function fcamelCase( all, letter ) {
9+
function fcamelCase( _all, letter ) {
1010
return letter.toUpperCase();
1111
}
1212

src/css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var
3434
fontWeight: "400"
3535
};
3636

37-
function setPositiveNumber( elem, value, subtract ) {
37+
function setPositiveNumber( _elem, value, subtract ) {
3838

3939
// Any relative (+/-) values have already been
4040
// normalized at this point
@@ -311,7 +311,7 @@ jQuery.extend( {
311311
}
312312
} );
313313

314-
jQuery.each( [ "height", "width" ], function( i, dimension ) {
314+
jQuery.each( [ "height", "width" ], function( _i, dimension ) {
315315
jQuery.cssHooks[ dimension ] = {
316316
get: function( elem, computed, extra ) {
317317
if ( computed ) {

src/css/var/swap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ define( function() {
33
"use strict";
44

55
// A method for quickly swapping in/out CSS properties to get correct calculations.
6-
return function( elem, options, callback, args ) {
6+
return function( elem, options, callback ) {
77
var ret, name,
88
old = {};
99

@@ -13,7 +13,7 @@ return function( elem, options, callback, args ) {
1313
elem.style[ name ] = options[ name ];
1414
}
1515

16-
ret = callback.apply( elem, args || [] );
16+
ret = callback.call( elem );
1717

1818
// Revert the old values
1919
for ( name in options ) {

0 commit comments

Comments
 (0)