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

Commit d7e13f1

Browse files
committed
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 (cherry-picked from 438b1a3)
1 parent 36b59c9 commit d7e13f1

File tree

17 files changed

+25
-26
lines changed

17 files changed

+25
-26
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.2.0",
3030
"commitplease": "3.2.0",
3131
"core-js": "2.6.5",
32-
"eslint-config-jquery": "1.0.1",
32+
"eslint-config-jquery": "2.0.0",
3333
"grunt": "1.0.3",
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
@@ -833,7 +833,7 @@ jQuery.extend( {
833833
}
834834
} );
835835

836-
jQuery.each( [ "get", "post" ], function( i, method ) {
836+
jQuery.each( [ "get", "post" ], function( _i, method ) {
837837
jQuery[ method ] = function( url, data, callback, type ) {
838838

839839
// 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
@@ -117,7 +117,7 @@ boolHook = {
117117
}
118118
};
119119

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

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

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ if ( typeof Symbol === "function" ) {
374374

375375
// Populate the class2type map
376376
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
377-
function( i, name ) {
377+
function( _i, name ) {
378378
class2type[ "[object " + name + "]" ] = name.toLowerCase();
379379
} );
380380

src/core/access.js

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

src/core/camelCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var rmsPrefix = /^-ms-/,
77
rdashAlpha = /-([a-z])/g;
88

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

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
@@ -344,7 +344,7 @@ jQuery.extend( {
344344
}
345345
} );
346346

347-
jQuery.each( [ "height", "width" ], function( i, dimension ) {
347+
jQuery.each( [ "height", "width" ], function( _i, dimension ) {
348348
jQuery.cssHooks[ dimension ] = {
349349
get: function( elem, computed, extra ) {
350350
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)