🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

eslint-plugin-no-jquery

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-no-jquery - npm Package Compare versions

Comparing version

to
2.6.0

# eslint-plugin-no-jquery release history
## v2.6.0
* New rule: `no-escape-selector` for `$.escapeSelector` util (Ed Sanders)
* New config: `deprecated-3.6` for new jQuery release (Ed Sanders)
* Rule fix: Add fixer for `no-on-ready` (Ed Sanders)
* Rule fix: Add fixer for `no-ready-shorthand` (Ed Sanders)
* Rule fix: Add fixer for `no-error` (Ed Sanders)
* Rule fix: Add fixer for `no-parse-xml` (Ed Sanders)
* Rule fix: Add fixer for `no-parse-html-literal` tag style (Ed Sanders)
* Rule fix: `no-now`; recommend `Date.now` rather than `(new Date).getTime()` (Ed Sanders)
* Code: Add real arguments to `no-parse-html` tests (Ed Sanders)
* Code: codecov.yaml: Remove extra linebreak (Ed Sanders)
* Release: Update devDependencies (#266) (Ed Sanders)
## v2.5.0

@@ -4,0 +22,0 @@

{
"name": "eslint-plugin-no-jquery",
"version": "2.5.0",
"version": "2.6.0",
"description": "Disallow jQuery functions with native equivalents.",

@@ -33,10 +33,10 @@ "repository": {

"devDependencies": {
"codecov": "^3.7.0",
"eslint-config-wikimedia": "^0.16.2",
"eslint-docgen": "^0.4.3",
"codecov": "^3.8.1",
"eslint-config-wikimedia": "^0.19.0",
"eslint-docgen": "^0.4.5",
"eslint-plugin-eslint-plugin": "^2.3.0",
"eslint-plugin-self": "^1.2.1",
"jquery": "3.5.1",
"jsdom": "^16.2.2",
"mocha": "^8.0.1",
"jquery": "3.6.0",
"jsdom": "^16.5.2",
"mocha": "^8.3.2",
"nyc": "^15.1.0"

@@ -50,4 +50,3 @@ },

"test": "tests"
},
"dependencies": {}
}
}

@@ -41,3 +41,3 @@ <!-- This file is built by build-readme.js. Do not edit it directly; edit README.md.template instead. -->

The config **`plugin:no-jquery/deprecated`** includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for all minor versions from 1.0 to 3.5 (`deprecated-1.0`, ..., `deprecated-3.5`). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.
The config **`plugin:no-jquery/deprecated`** includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for all minor versions from 1.0 to 3.6 (`deprecated-1.0`, ..., `deprecated-3.6`). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.

@@ -112,2 +112,3 @@ The config **`plugin:no-jquery/slim`** includes all features excluded from the official "slim" build of jQuery, specifically the [ajax](https://api.jquery.com/category/ajax/) and [effects](https://api.jquery.com/category/effects/) modules.

* [`no-jquery/no-error-shorthand`](docs/rules/no-error-shorthand.md) `1.8`
* [`no-jquery/no-escape-selector`](docs/rules/no-escape-selector.md) `all`
* [`no-jquery/no-event-shorthand`](docs/rules/no-event-shorthand.md) `3.5`, `3.3†`, `all`

@@ -114,0 +115,0 @@ * [`no-jquery/no-extend`](docs/rules/no-extend.md) `all`

@@ -32,2 +32,3 @@ 'use strict';

'no-error-shorthand': require( './rules/no-error-shorthand' ),
'no-escape-selector': require( './rules/no-escape-selector' ),
'no-event-shorthand': require( './rules/no-event-shorthand' ),

@@ -128,5 +129,8 @@ 'no-extend': require( './rules/no-extend' ),

deprecated: {
extends: 'plugin:no-jquery/deprecated-3.6'
},
// Use this config if you're writing code targetting jQuery 3.6.x environments.
'deprecated-3.6': {
extends: 'plugin:no-jquery/deprecated-3.5'
},
// Use this config if you're writing code targetting jQuery 3.5.x environments.
'deprecated-3.5': {

@@ -294,2 +298,3 @@ extends: 'plugin:no-jquery/deprecated-3.4',

'no-jquery/no-error': 'warn',
'no-jquery/no-escape-selector': 'warn',
'no-jquery/no-extend': 'warn',

@@ -296,0 +301,0 @@ 'no-jquery/no-find-util': 'warn',

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee.property, 'addBack' );

@@ -13,0 +13,0 @@ }

@@ -7,3 +7,9 @@ 'use strict';

'error',
'Prefer `throw` to `$.error`'
'Prefer `throw` to `$.error`',
{
fixable: 'code',
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee, 'throw new Error' );
}
}
);

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee, 'Array.isArray' );

@@ -13,0 +13,0 @@ }

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
const calleeRange = node.callee.range;

@@ -13,0 +13,0 @@ return [

@@ -33,3 +33,3 @@ 'use strict';

message: 'Prefer .on or .trigger to .load',
fix: utils.eventShorthandFixer.bind( this, node )
fix: utils.eventShorthandFixer.bind( this, node, context )
} );

@@ -36,0 +36,0 @@ }

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node, '(function(){})' );

@@ -13,0 +13,0 @@ }

@@ -7,6 +7,6 @@ 'use strict';

'now',
'Prefer `(new Date).getTime()` to `$.now`',
'Prefer `Date.now` to `$.now`',
{
fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee, 'Date.now' );

@@ -13,0 +13,0 @@ }

@@ -11,2 +11,3 @@ 'use strict';

},
fixable: 'code',
schema: []

@@ -32,3 +33,17 @@ },

node: node,
message: '.on("ready") is not allowed'
message: '.on("ready") is not allowed',
fix: function ( fixer ) {
if ( node.arguments.length > 1 ) {
return [
fixer.replaceText( node.callee.property, 'ready' ),
fixer.replaceTextRange(
[
node.arguments[ 0 ].range[ 0 ],
node.arguments[ 1 ].range[ 0 ]
],
''
)
];
}
}
} );

@@ -35,0 +50,0 @@ }

@@ -16,2 +16,3 @@ 'use strict';

'error',
'escapeSelector',
'extend',

@@ -18,0 +19,0 @@ 'filter',

@@ -45,2 +45,3 @@ 'use strict';

},
fixable: 'code',
schema: [

@@ -95,2 +96,3 @@ {

let expectedTag;
const arg = node.arguments[ 0 ];

@@ -103,3 +105,4 @@ if ( allowSingle ) {

}
if ( rsingleTag.exec( value ) ) {
let match;
if ( ( match = rsingleTag.exec( value ) ) ) {
// Single tag

@@ -109,3 +112,4 @@ const singleTagStyle = ( context.options[ 0 ] && context.options[ 0 ].singleTagStyle ) || 'minimal';

if ( !rsingleTagMinimal.exec( value ) ) {
message = 'Single tag must use the format: <tagname>';
expectedTag = '<' + match[ 1 ] + '>';
message = 'Single tag must use the format: ' + expectedTag;
} else {

@@ -116,3 +120,4 @@ return;

if ( !rsingleTagSelfClosing.exec( value ) ) {
message = 'Single tag must use the format: <tagname/>';
expectedTag = '<' + match[ 1 ] + '/>';
message = 'Single tag must use the format: ' + expectedTag;
} else {

@@ -133,3 +138,9 @@ return;

node: node,
message: message
message: message,
fix: function ( fixer ) {
if ( expectedTag ) {
return fixer.replaceText( arg, '"' + expectedTag + '"' );
}
return null;
}
} );

@@ -136,0 +147,0 @@ }

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee, 'JSON.parse' );

@@ -13,0 +13,0 @@ }

@@ -7,3 +7,14 @@ 'use strict';

'parseXML',
'Prefer `DOMParser#parseFromString` to `$.parseXML`'
'Prefer `DOMParser#parseFromString` to `$.parseXML`',
{
fixable: 'code',
fix: function ( node, context, fixer ) {
if ( node.arguments.length ) {
return [
fixer.replaceText( node.callee, '( new window.DOMParser() ).parseFromString' ),
fixer.insertTextAfterRange( node.arguments[ 0 ].range, ', "text/xml"' )
];
}
}
}
);

@@ -7,3 +7,21 @@ 'use strict';

'proxy',
'Prefer `Function#bind` to `$.proxy`'
'Prefer `Function#bind` to `$.proxy`',
{
fixable: 'code',
fix: function ( node, context, fixer ) {
if (
node.arguments.length >= 2 &&
node.arguments[ 1 ].type !== 'Literal'
) {
const fnText = context.getSourceCode().getText( node.arguments[ 0 ] );
return [
fixer.replaceText( node.callee, fnText + '.bind' ),
fixer.removeRange( [
node.arguments[ 0 ].range[ 0 ],
node.arguments[ 1 ].range[ 0 ]
] )
];
}
}
}
);

@@ -7,3 +7,11 @@ 'use strict';

'ready',
'Prefer `$()` to `.ready`'
'Prefer `$()` to `.ready`',
{
fixable: 'code',
fix: function ( node, context, fixer ) {
if ( node.parent.type === 'ExpressionStatement' ) {
return fixer.replaceText( node.callee, '$' );
}
}
}
);

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceTextRange( [ node.callee.property.range[ 0 ], node.range[ 1 ] ], 'length' );

@@ -13,0 +13,0 @@ }

@@ -10,3 +10,3 @@ 'use strict';

fixable: 'code',
fix: function ( node, fixer ) {
fix: function ( node, context, fixer ) {
return fixer.replaceText( node.callee.property, 'uniqueSort' );

@@ -13,0 +13,0 @@ }

@@ -331,3 +331,3 @@ 'use strict';

message: messageToPlainString( message, node, name, options ),
fix: options.fix && options.fix.bind( this, node )
fix: options.fix && options.fix.bind( this, node, context )
} );

@@ -371,3 +371,3 @@ }

message: messageToPlainString( message, node, name, options ),
fix: options.fix && options.fix.bind( this, node )
fix: options.fix && options.fix.bind( this, node, context )
} );

@@ -417,3 +417,3 @@ }

message: messageToPlainString( message, node, name, options ),
fix: options.fix && options.fix.bind( this, node )
fix: options.fix && options.fix.bind( this, node, context )
} );

@@ -456,3 +456,3 @@ }

message: messageToPlainString( message, node, name, options ),
fix: options.fix && options.fix.bind( this, node )
fix: options.fix && options.fix.bind( this, node, context )
} );

@@ -501,3 +501,3 @@ }

message: messageToPlainString( message, node, name, options ),
fix: options.fix && options.fix.bind( this, node )
fix: options.fix && options.fix.bind( this, node, context )
} );

@@ -510,3 +510,3 @@ }

function eventShorthandFixer( node, fixer ) {
function eventShorthandFixer( node, context, fixer ) {
const name = node.callee.property.name;

@@ -513,0 +513,0 @@ if ( node.callee.parent.arguments.length ) {

Sorry, the diff of this file is not supported yet