eslint-plugin-no-jquery 2.7.0 → 3.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 +2 -2
- package/README.md.template +1 -1
- package/package.json +12 -9
- package/src/.eslintrc.js +17 -0
- package/src/all-methods.js +2 -1
- package/src/index.js +4 -1
- package/src/rules/no-ajax-events.js +26 -28
- package/src/rules/no-ajax.js +1 -1
- package/src/rules/no-and-self.js +1 -3
- package/src/rules/no-animate-toggle.js +3 -3
- package/src/rules/no-animate.js +28 -30
- package/src/rules/no-append-html.js +18 -20
- package/src/rules/no-class-state.js +16 -18
- package/src/rules/no-class.js +1 -1
- package/src/rules/no-constructor-attributes.js +21 -23
- package/src/rules/no-data.js +1 -1
- package/src/rules/no-deferred.js +2 -2
- package/src/rules/no-error.js +1 -3
- package/src/rules/no-escape-selector.js +1 -3
- package/src/rules/no-event-shorthand.js +3 -3
- package/src/rules/no-extend.js +28 -26
- package/src/rules/no-fade.js +1 -1
- package/src/rules/no-fx-interval.js +13 -15
- package/src/rules/no-global-selector.js +39 -41
- package/src/rules/no-is-array.js +1 -3
- package/src/rules/no-is-function.js +1 -1
- package/src/rules/no-jquery-constructor.js +13 -15
- package/src/rules/no-load-shorthand.js +17 -19
- package/src/rules/no-noop.js +1 -3
- package/src/rules/no-now.js +1 -3
- package/src/rules/no-on-ready.js +29 -34
- package/src/rules/no-other-methods.js +19 -21
- package/src/rules/no-other-utils.js +18 -20
- package/src/rules/no-parse-html-literal.js +60 -67
- package/src/rules/no-parse-json.js +1 -3
- package/src/rules/no-parse-xml.js +1 -1
- package/src/rules/no-prop.js +1 -1
- package/src/rules/no-proxy.js +1 -1
- package/src/rules/no-ready-shorthand.js +1 -1
- package/src/rules/no-ready.js +9 -11
- package/src/rules/no-serialize.js +1 -1
- package/src/rules/no-size.js +1 -3
- package/src/rules/no-sizzle.js +5 -5
- package/src/rules/no-slide.js +1 -1
- package/src/rules/no-unique.js +1 -3
- package/src/rules/no-visibility.js +1 -1
- package/src/rules/no-wrap.js +1 -1
- package/src/rules/variable-pattern.js +4 -4
- package/src/utils.js +107 -117
- package/Changelog.md +0 -359
package/src/rules/no-sizzle.js
CHANGED
|
@@ -39,8 +39,8 @@ module.exports = {
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
|
|
42
|
-
create:
|
|
43
|
-
const forbiddenPositional = /:eq|:even|:first([^-]|$)|:gt|:last([^-]|$)|:lt|:nth|:odd/;
|
|
42
|
+
create: ( context ) => {
|
|
43
|
+
const forbiddenPositional = /:eq|:even|:first([^-]|$)|:gt|:last([^-]|$)|:lt|:nth([^-]|$)|:odd/;
|
|
44
44
|
const forbiddenOther = /:animated|:button|:checkbox|:file|:has|:header|:hidden|:image|:input|:parent|:password|:radio|:reset|:selected|:submit|:text|:visible/;
|
|
45
45
|
const traversals = [
|
|
46
46
|
'children',
|
|
@@ -63,7 +63,7 @@ module.exports = {
|
|
|
63
63
|
];
|
|
64
64
|
|
|
65
65
|
return {
|
|
66
|
-
'CallExpression:exit':
|
|
66
|
+
'CallExpression:exit': ( node ) => {
|
|
67
67
|
if (
|
|
68
68
|
!node.arguments[ 0 ] ||
|
|
69
69
|
!utils.isjQuery( context, node.callee ) ||
|
|
@@ -83,12 +83,12 @@ module.exports = {
|
|
|
83
83
|
|
|
84
84
|
if ( !allowPositional && forbiddenPositional.test( value ) ) {
|
|
85
85
|
context.report( {
|
|
86
|
-
node
|
|
86
|
+
node,
|
|
87
87
|
message: 'Positional selector extensions are not allowed'
|
|
88
88
|
} );
|
|
89
89
|
} else if ( !allowOther && forbiddenOther.test( value ) ) {
|
|
90
90
|
context.report( {
|
|
91
|
-
node
|
|
91
|
+
node,
|
|
92
92
|
message: 'Selector extensions are not allowed'
|
|
93
93
|
} );
|
|
94
94
|
}
|
package/src/rules/no-slide.js
CHANGED
|
@@ -6,5 +6,5 @@ module.exports = utils.createCollectionMethodRule(
|
|
|
6
6
|
[ 'slideDown', 'slideToggle', 'slideUp' ],
|
|
7
7
|
( node ) => node === true ?
|
|
8
8
|
'Prefer CSS transitions' :
|
|
9
|
-
`Prefer CSS transitions to .${node.callee.property.name}`
|
|
9
|
+
`Prefer CSS transitions to .${ node.callee.property.name }`
|
|
10
10
|
);
|
package/src/rules/no-unique.js
CHANGED
|
@@ -7,8 +7,6 @@ module.exports = utils.createUtilMethodRule(
|
|
|
7
7
|
'Prefer `$.uniqueSort` to `$.unique`',
|
|
8
8
|
{
|
|
9
9
|
fixable: 'code',
|
|
10
|
-
fix:
|
|
11
|
-
return fixer.replaceText( node.callee.property, 'uniqueSort' );
|
|
12
|
-
}
|
|
10
|
+
fix: ( node, context, fixer ) => fixer.replaceText( node.callee.property, 'uniqueSort' )
|
|
13
11
|
}
|
|
14
12
|
);
|
package/src/rules/no-wrap.js
CHANGED
|
@@ -5,5 +5,5 @@ const utils = require( '../utils.js' );
|
|
|
5
5
|
module.exports = utils.createCollectionMethodRule(
|
|
6
6
|
[ 'wrap', 'wrapAll', 'wrapInner', 'unwrap' ],
|
|
7
7
|
( node ) => node === true ? '' :
|
|
8
|
-
`.${node.callee.property.name} is not allowed`
|
|
8
|
+
`.${ node.callee.property.name } is not allowed`
|
|
9
9
|
);
|
|
@@ -11,7 +11,7 @@ module.exports = {
|
|
|
11
11
|
schema: []
|
|
12
12
|
},
|
|
13
13
|
|
|
14
|
-
create:
|
|
14
|
+
create: ( context ) => {
|
|
15
15
|
function test( node, left, right ) {
|
|
16
16
|
if (
|
|
17
17
|
!utils.isjQuery( context, left ) &&
|
|
@@ -22,17 +22,17 @@ module.exports = {
|
|
|
22
22
|
right && utils.isjQuery( context, right )
|
|
23
23
|
) {
|
|
24
24
|
context.report( {
|
|
25
|
-
node
|
|
25
|
+
node,
|
|
26
26
|
message: 'jQuery collection names must match the variablePattern'
|
|
27
27
|
} );
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
|
-
'AssignmentExpression:exit':
|
|
32
|
+
'AssignmentExpression:exit': ( node ) => {
|
|
33
33
|
test( node, node.left, node.right );
|
|
34
34
|
},
|
|
35
|
-
'VariableDeclarator:exit':
|
|
35
|
+
'VariableDeclarator:exit': ( node ) => {
|
|
36
36
|
test( node, node.id, node.init );
|
|
37
37
|
}
|
|
38
38
|
};
|
package/src/utils.js
CHANGED
|
@@ -203,14 +203,14 @@ function createRule( create, description, fixable, deprecated, schema ) {
|
|
|
203
203
|
meta: {
|
|
204
204
|
type: 'suggestion',
|
|
205
205
|
docs: {
|
|
206
|
-
description
|
|
206
|
+
description,
|
|
207
207
|
deprecated: !!deprecated,
|
|
208
208
|
replacedBy: Array.isArray( deprecated ) ? deprecated : undefined
|
|
209
209
|
},
|
|
210
|
-
fixable
|
|
210
|
+
fixable,
|
|
211
211
|
schema: schema || []
|
|
212
212
|
},
|
|
213
|
-
create
|
|
213
|
+
create
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -336,38 +336,36 @@ function createCollectionMethodRule( methods, message, options ) {
|
|
|
336
336
|
'* `"set"` the method can only be used as a setter i.e. with arguments';
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
return createRule(
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
!methods.includes( name ) ||
|
|
339
|
+
return createRule( ( context ) => ( {
|
|
340
|
+
'CallExpression:exit': ( node ) => {
|
|
341
|
+
if ( node.callee.type !== 'MemberExpression' ) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const name = node.callee.property.name;
|
|
345
|
+
if (
|
|
346
|
+
!methods.includes( name ) ||
|
|
348
347
|
isjQueryConstructor( context, node.callee.object.name )
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
348
|
+
) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const allowGetOrSet = ( context.options[ 0 ] && context.options[ 0 ].allowGetOrSet ) || 'none';
|
|
352
|
+
// TODO: nonCollectionReturningValueAccessors have 1 argument in getter mode
|
|
353
|
+
if (
|
|
354
|
+
( allowGetOrSet === 'get' && !node.arguments.length ) ||
|
|
356
355
|
( allowGetOrSet === 'set' && node.arguments.length )
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
360
359
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
360
|
+
if ( isjQuery( context, node.callee ) ) {
|
|
361
|
+
context.report( {
|
|
362
|
+
node,
|
|
363
|
+
message: messageToPlainString( message, node, name, options ),
|
|
364
|
+
fix: options.fix && options.fix.bind( this, node, context )
|
|
365
|
+
} );
|
|
368
366
|
}
|
|
369
|
-
}
|
|
370
|
-
}, description, options.fixable, options.deprecated, schema );
|
|
367
|
+
}
|
|
368
|
+
} ), description, options.fixable, options.deprecated, schema );
|
|
371
369
|
}
|
|
372
370
|
|
|
373
371
|
/**
|
|
@@ -387,26 +385,24 @@ function createCollectionPropertyRule( property, message, options ) {
|
|
|
387
385
|
|
|
388
386
|
description += messageSuffix( message );
|
|
389
387
|
|
|
390
|
-
return createRule(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
name !== property ||
|
|
388
|
+
return createRule( ( context ) => ( {
|
|
389
|
+
'MemberExpression:exit': ( node ) => {
|
|
390
|
+
const name = node.property.name;
|
|
391
|
+
if (
|
|
392
|
+
name !== property ||
|
|
396
393
|
node.parent.callee === node
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
394
|
+
) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if ( isjQuery( context, node.object ) ) {
|
|
398
|
+
context.report( {
|
|
399
|
+
node,
|
|
400
|
+
message: messageToPlainString( message, node, name, options ),
|
|
401
|
+
fix: options.fix && options.fix.bind( this, node, context )
|
|
402
|
+
} );
|
|
407
403
|
}
|
|
408
|
-
}
|
|
409
|
-
}, description, options.fixable, options.deprecated );
|
|
404
|
+
}
|
|
405
|
+
} ), description, options.fixable, options.deprecated );
|
|
410
406
|
}
|
|
411
407
|
|
|
412
408
|
/**
|
|
@@ -429,28 +425,26 @@ function createUtilMethodRule( methods, message, options ) {
|
|
|
429
425
|
|
|
430
426
|
description += messageSuffix( message );
|
|
431
427
|
|
|
432
|
-
return createRule(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
!methods.includes( name ) ||
|
|
428
|
+
return createRule( ( context ) => ( {
|
|
429
|
+
'CallExpression:exit': ( node ) => {
|
|
430
|
+
if ( node.callee.type !== 'MemberExpression' ) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const name = node.callee.property.name;
|
|
434
|
+
if (
|
|
435
|
+
!methods.includes( name ) ||
|
|
441
436
|
!isjQueryConstructor( context, node.callee.object.name )
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
context.report( {
|
|
447
|
-
node: node,
|
|
448
|
-
message: messageToPlainString( message, node, name, options ),
|
|
449
|
-
fix: options.fix && options.fix.bind( this, node, context )
|
|
450
|
-
} );
|
|
437
|
+
) {
|
|
438
|
+
return;
|
|
451
439
|
}
|
|
452
|
-
|
|
453
|
-
|
|
440
|
+
|
|
441
|
+
context.report( {
|
|
442
|
+
node,
|
|
443
|
+
message: messageToPlainString( message, node, name, options ),
|
|
444
|
+
fix: options.fix && options.fix.bind( this, node, context )
|
|
445
|
+
} );
|
|
446
|
+
}
|
|
447
|
+
} ), description, options.fixable, options.deprecated );
|
|
454
448
|
}
|
|
455
449
|
|
|
456
450
|
/**
|
|
@@ -470,25 +464,23 @@ function createUtilPropertyRule( property, message, options ) {
|
|
|
470
464
|
|
|
471
465
|
description += messageSuffix( message );
|
|
472
466
|
|
|
473
|
-
return createRule(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
context.report( {
|
|
485
|
-
node: node,
|
|
486
|
-
message: messageToPlainString( message, node, name, options ),
|
|
487
|
-
fix: options.fix && options.fix.bind( this, node, context )
|
|
488
|
-
} );
|
|
467
|
+
return createRule( ( context ) => ( {
|
|
468
|
+
'MemberExpression:exit': ( node ) => {
|
|
469
|
+
if ( !isjQueryConstructor( context, node.object.name ) ) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const name = node.property.name;
|
|
473
|
+
if ( name !== property ) {
|
|
474
|
+
return;
|
|
489
475
|
}
|
|
490
|
-
|
|
491
|
-
|
|
476
|
+
|
|
477
|
+
context.report( {
|
|
478
|
+
node,
|
|
479
|
+
message: messageToPlainString( message, node, name, options ),
|
|
480
|
+
fix: options.fix && options.fix.bind( this, node, context )
|
|
481
|
+
} );
|
|
482
|
+
}
|
|
483
|
+
} ), description, options.fixable, options.deprecated );
|
|
492
484
|
}
|
|
493
485
|
|
|
494
486
|
/**
|
|
@@ -514,26 +506,24 @@ function createCollectionOrUtilMethodRule( methods, message, options ) {
|
|
|
514
506
|
|
|
515
507
|
description += messageSuffix( message );
|
|
516
508
|
|
|
517
|
-
return createRule(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
if ( isjQuery( context, node.callee ) ) {
|
|
528
|
-
context.report( {
|
|
529
|
-
node: node,
|
|
530
|
-
message: messageToPlainString( message, node, name, options ),
|
|
531
|
-
fix: options.fix && options.fix.bind( this, node, context )
|
|
532
|
-
} );
|
|
533
|
-
}
|
|
509
|
+
return createRule( ( context ) => ( {
|
|
510
|
+
'CallExpression:exit': ( node ) => {
|
|
511
|
+
if ( node.callee.type !== 'MemberExpression' ) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const name = node.callee.property.name;
|
|
515
|
+
if ( !methods.includes( name ) ) {
|
|
516
|
+
return;
|
|
534
517
|
}
|
|
535
|
-
|
|
536
|
-
|
|
518
|
+
if ( isjQuery( context, node.callee ) ) {
|
|
519
|
+
context.report( {
|
|
520
|
+
node,
|
|
521
|
+
message: messageToPlainString( message, node, name, options ),
|
|
522
|
+
fix: options.fix && options.fix.bind( this, node, context )
|
|
523
|
+
} );
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
} ), description, options.fixable, options.deprecated );
|
|
537
527
|
}
|
|
538
528
|
|
|
539
529
|
function eventShorthandFixer( node, context, fixer ) {
|
|
@@ -552,15 +542,15 @@ function eventShorthandFixer( node, context, fixer ) {
|
|
|
552
542
|
}
|
|
553
543
|
|
|
554
544
|
module.exports = {
|
|
555
|
-
isjQuery
|
|
556
|
-
isjQueryConstructor
|
|
557
|
-
isFunction
|
|
558
|
-
createCollectionMethodRule
|
|
559
|
-
createCollectionPropertyRule
|
|
560
|
-
createUtilMethodRule
|
|
561
|
-
createUtilPropertyRule
|
|
562
|
-
createCollectionOrUtilMethodRule
|
|
563
|
-
eventShorthandFixer
|
|
564
|
-
jQueryCollectionLink
|
|
565
|
-
jQueryGlobalLink
|
|
545
|
+
isjQuery,
|
|
546
|
+
isjQueryConstructor,
|
|
547
|
+
isFunction,
|
|
548
|
+
createCollectionMethodRule,
|
|
549
|
+
createCollectionPropertyRule,
|
|
550
|
+
createUtilMethodRule,
|
|
551
|
+
createUtilPropertyRule,
|
|
552
|
+
createCollectionOrUtilMethodRule,
|
|
553
|
+
eventShorthandFixer,
|
|
554
|
+
jQueryCollectionLink,
|
|
555
|
+
jQueryGlobalLink
|
|
566
556
|
};
|