eslint-plugin-no-jquery 3.1.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +17 -7
- package/src/index.js +1 -0
- package/src/rules/no-animate.js +5 -1
- package/src/rules/no-class.js +80 -6
- package/src/rules/no-extend.js +8 -2
- package/src/rules/no-global-selector.js +5 -1
- package/src/rules/no-other-methods.js +2 -0
- package/src/rules/no-parse-html-literal.js +5 -1
- package/src/rules/no-proxy.js +9 -1
- package/src/rules/no-sizzle.js +7 -2
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ Where rules are included in the configs `recommended`, `slim`, `all` or `depreca
|
|
|
96
96
|
* [`no-jquery/no-box-model`](docs/rules/no-box-model.md) `1.3`
|
|
97
97
|
* [`no-jquery/no-browser`](docs/rules/no-browser.md) `1.3`
|
|
98
98
|
* [`no-jquery/no-camel-case`](docs/rules/no-camel-case.md) `3.3`, `all`
|
|
99
|
-
* [`no-jquery/no-class`](docs/rules/no-class.md) `all`
|
|
99
|
+
* [`no-jquery/no-class`](docs/rules/no-class.md) ⚙️ `3.0†`, `all`
|
|
100
100
|
* [`no-jquery/no-class-state`](docs/rules/no-class-state.md)
|
|
101
101
|
* [`no-jquery/no-clone`](docs/rules/no-clone.md) `all`
|
|
102
102
|
* [`no-jquery/no-closest`](docs/rules/no-closest.md) `all`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-no-jquery",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Disallow jQuery functions with native equivalents.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,20 +27,30 @@
|
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
29
|
"engine": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=24"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"eslint": ">=8.0.0"
|
|
33
|
+
"eslint": ">=8.0.0",
|
|
34
|
+
"oxlint": ">=1.52.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"eslint": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"oxlint": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
34
43
|
},
|
|
35
44
|
"devDependencies": {
|
|
36
45
|
"codecov": "^3.8.3",
|
|
37
|
-
"eslint
|
|
46
|
+
"eslint": "^8.57.1",
|
|
47
|
+
"eslint-config-wikimedia": "^0.32.3",
|
|
38
48
|
"eslint-docgen": "^0.7.1",
|
|
39
|
-
"eslint-plugin-eslint-plugin": "^6.
|
|
49
|
+
"eslint-plugin-eslint-plugin": "^6.5.0",
|
|
40
50
|
"eslint-plugin-self": "^1.2.1",
|
|
41
51
|
"jquery": "3.7.1",
|
|
42
|
-
"jsdom": "^
|
|
43
|
-
"mocha": "^11.
|
|
52
|
+
"jsdom": "^27.0.0",
|
|
53
|
+
"mocha": "^11.7.4",
|
|
44
54
|
"nyc": "^17.1.0"
|
|
45
55
|
},
|
|
46
56
|
"bugs": {
|
package/src/index.js
CHANGED
|
@@ -180,6 +180,7 @@ module.exports = {
|
|
|
180
180
|
extends: 'plugin:no-jquery/deprecated-2.2',
|
|
181
181
|
rules: {
|
|
182
182
|
'no-jquery/no-bind': 'warn',
|
|
183
|
+
'no-jquery/no-class': [ 'warn', { onlyDeprecated: true } ],
|
|
183
184
|
'no-jquery/no-delegate': 'warn',
|
|
184
185
|
'no-jquery/no-fx-interval': 'warn',
|
|
185
186
|
'no-jquery/no-parse-json': 'warn',
|
package/src/rules/no-animate.js
CHANGED
|
@@ -17,11 +17,15 @@ module.exports = {
|
|
|
17
17
|
type: 'object',
|
|
18
18
|
properties: {
|
|
19
19
|
allowScroll: {
|
|
20
|
-
type: 'boolean'
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
description: 'Allow animations which are just used for scrolling'
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
additionalProperties: false
|
|
24
25
|
}
|
|
26
|
+
],
|
|
27
|
+
defaultOptions: [
|
|
28
|
+
{ allowScroll: false }
|
|
25
29
|
]
|
|
26
30
|
},
|
|
27
31
|
|
package/src/rules/no-class.js
CHANGED
|
@@ -2,9 +2,83 @@
|
|
|
2
2
|
|
|
3
3
|
const utils = require( '../utils.js' );
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const methods = [ 'addClass', 'hasClass', 'removeClass', 'toggleClass' ];
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Disallows the ' + methods.map( utils.jQueryCollectionLink ).join( '/' ) +
|
|
12
|
+
' methods. User the `onlyDeprecated` option to only report deprecated usages. Prefer `Element#classList`.'
|
|
13
|
+
},
|
|
14
|
+
schema: [
|
|
15
|
+
{
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
onlyDeprecated: {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
description: 'Only report deprecated usages of the methods.'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
additionalProperties: false
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
defaultOptions: [
|
|
27
|
+
{ onlyDeprecated: false }
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
create: ( context ) => ( {
|
|
32
|
+
'CallExpression:exit': ( node ) => {
|
|
33
|
+
if (
|
|
34
|
+
node.callee.type !== 'MemberExpression' ||
|
|
35
|
+
!methods.includes( node.callee.property.name )
|
|
36
|
+
) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const name = node.callee.property.name;
|
|
40
|
+
const onlyDeprecated = context.options[ 0 ] && context.options[ 0 ].onlyDeprecated;
|
|
41
|
+
|
|
42
|
+
if ( !onlyDeprecated ) {
|
|
43
|
+
if ( utils.isjQuery( context, node.callee ) ) {
|
|
44
|
+
const message = node === true ?
|
|
45
|
+
'Prefer `Element#classList`' :
|
|
46
|
+
`Prefer Element#classList to .${ name }`;
|
|
47
|
+
context.report( {
|
|
48
|
+
node,
|
|
49
|
+
message
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if ( name !== 'toggleClass' || utils.isjQueryConstructor( context, node.callee.object.name ) ) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if ( node.arguments.length >= 2 ) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if ( node.arguments.length === 1 ) {
|
|
61
|
+
const arg = node.arguments[ 0 ];
|
|
62
|
+
if (
|
|
63
|
+
!(
|
|
64
|
+
arg.type === 'Literal' &&
|
|
65
|
+
( arg.value === true || arg.value === false )
|
|
66
|
+
) &&
|
|
67
|
+
!(
|
|
68
|
+
arg.type === 'Identifier' && arg.name === 'undefined'
|
|
69
|
+
)
|
|
70
|
+
) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if ( utils.isjQuery( context, node.callee ) ) {
|
|
76
|
+
context.report( {
|
|
77
|
+
node,
|
|
78
|
+
message: '.toggleClass(boolean|undefined) is deprecated'
|
|
79
|
+
} );
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} )
|
|
84
|
+
};
|
package/src/rules/no-extend.js
CHANGED
|
@@ -6,7 +6,9 @@ module.exports = {
|
|
|
6
6
|
meta: {
|
|
7
7
|
type: 'suggestion',
|
|
8
8
|
docs: {
|
|
9
|
-
description:
|
|
9
|
+
description:
|
|
10
|
+
'Disallows the ' + utils.jQueryGlobalLink( 'extend' ) + ' utility. Prefer `Object.assign` or the spread operator. ' +
|
|
11
|
+
'Use the `allowDeep` option to allow using the method with the `deep` argument.'
|
|
10
12
|
},
|
|
11
13
|
fixable: 'code',
|
|
12
14
|
schema: [
|
|
@@ -14,11 +16,15 @@ module.exports = {
|
|
|
14
16
|
type: 'object',
|
|
15
17
|
properties: {
|
|
16
18
|
allowDeep: {
|
|
17
|
-
type: 'boolean'
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
description: 'Allow when used with the `deep` argument'
|
|
18
21
|
}
|
|
19
22
|
},
|
|
20
23
|
additionalProperties: false
|
|
21
24
|
}
|
|
25
|
+
],
|
|
26
|
+
defaultOptions: [
|
|
27
|
+
{ allowDeep: false }
|
|
22
28
|
]
|
|
23
29
|
},
|
|
24
30
|
|
|
@@ -20,11 +20,15 @@ module.exports = {
|
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
22
22
|
allowIds: {
|
|
23
|
-
type: 'boolean'
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'Allow single ID selectors'
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
additionalProperties: false
|
|
27
28
|
}
|
|
29
|
+
],
|
|
30
|
+
defaultOptions: [
|
|
31
|
+
{ allowIds: false }
|
|
28
32
|
]
|
|
29
33
|
},
|
|
30
34
|
|
|
@@ -31,6 +31,7 @@ const methodsWithRules = [
|
|
|
31
31
|
'fadeToggle',
|
|
32
32
|
'filter',
|
|
33
33
|
'find',
|
|
34
|
+
'finish',
|
|
34
35
|
'focus',
|
|
35
36
|
'focusin',
|
|
36
37
|
'focusout',
|
|
@@ -71,6 +72,7 @@ const methodsWithRules = [
|
|
|
71
72
|
'slideDown',
|
|
72
73
|
'slideToggle',
|
|
73
74
|
'slideUp',
|
|
75
|
+
'stop',
|
|
74
76
|
'submit',
|
|
75
77
|
'text',
|
|
76
78
|
'toggle',
|
|
@@ -26,11 +26,15 @@ module.exports = {
|
|
|
26
26
|
type: 'object',
|
|
27
27
|
properties: {
|
|
28
28
|
singleTagStyle: {
|
|
29
|
-
enum: [ 'minimal', 'self-closing', 'any' ]
|
|
29
|
+
enum: [ 'minimal', 'self-closing', 'any' ],
|
|
30
|
+
description: 'Format of single tags'
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
additionalProperties: false
|
|
33
34
|
}
|
|
35
|
+
],
|
|
36
|
+
defaultOptions: [
|
|
37
|
+
{ singleTagStyle: 'minimal' }
|
|
34
38
|
]
|
|
35
39
|
},
|
|
36
40
|
|
package/src/rules/no-proxy.js
CHANGED
|
@@ -12,7 +12,15 @@ module.exports = utils.createUtilMethodRule(
|
|
|
12
12
|
node.arguments.length >= 2 &&
|
|
13
13
|
node.arguments[ 1 ].type !== 'Literal'
|
|
14
14
|
) {
|
|
15
|
-
|
|
15
|
+
// check can be removed when ESLint v8 support is dropped,
|
|
16
|
+
// as `context.sourceCode` will always be defined.
|
|
17
|
+
// `getSourceCode` is deprecated in ESLint v9, and removed in ESLint v10,
|
|
18
|
+
// so we need to support both APIs for now.
|
|
19
|
+
// istanbul ignore next
|
|
20
|
+
const sourceCode = context.sourceCode !== undefined ?
|
|
21
|
+
context.sourceCode :
|
|
22
|
+
context.getSourceCode();
|
|
23
|
+
const fnText = sourceCode.getText( node.arguments[ 0 ] );
|
|
16
24
|
return [
|
|
17
25
|
fixer.replaceText( node.callee, fnText + '.bind' ),
|
|
18
26
|
fixer.removeRange( [
|
package/src/rules/no-sizzle.js
CHANGED
|
@@ -15,14 +15,19 @@ module.exports = {
|
|
|
15
15
|
type: 'object',
|
|
16
16
|
properties: {
|
|
17
17
|
allowPositional: {
|
|
18
|
-
type: 'boolean'
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
description: 'Allow positional selectors'
|
|
19
20
|
},
|
|
20
21
|
allowOther: {
|
|
21
|
-
type: 'boolean'
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
description: 'Allow all other selectors'
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
additionalProperties: false
|
|
25
27
|
}
|
|
28
|
+
],
|
|
29
|
+
defaultOptions: [
|
|
30
|
+
{ allowPositional: false, allowOther: false }
|
|
26
31
|
]
|
|
27
32
|
},
|
|
28
33
|
|