From aff06695a2e994242a7c4aa6320630325ebca7b5 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Mon, 3 Jun 2024 16:12:51 -0400 Subject: [PATCH] Add 'recommended' status to each rule as a starter Now-recommended rules: - no-animate-toggle - no-animate - no-class-state - no-constructor-attributes - no-deferred - no-extend - no-fx-interval - no-global-selector - no-jquery-constructor - no-load-shorthand - no-on-ready - no-parse-html-literal - no-ready - no-sizzle - variable-pattern Fixes #249. --- src/rules/no-ajax-events.js | 3 ++- src/rules/no-animate-toggle.js | 3 ++- src/rules/no-animate.js | 3 ++- src/rules/no-append-html.js | 3 ++- src/rules/no-class-state.js | 3 ++- src/rules/no-constructor-attributes.js | 3 ++- src/rules/no-deferred.js | 3 ++- src/rules/no-extend.js | 3 ++- src/rules/no-fx-interval.js | 3 ++- src/rules/no-global-selector.js | 3 ++- src/rules/no-jquery-constructor.js | 3 ++- src/rules/no-load-shorthand.js | 3 ++- src/rules/no-on-ready.js | 3 ++- src/rules/no-other-methods.js | 3 ++- src/rules/no-other-utils.js | 3 ++- src/rules/no-parse-html-literal.js | 3 ++- src/rules/no-ready.js | 3 ++- src/rules/no-sizzle.js | 3 ++- src/rules/variable-pattern.js | 3 ++- 19 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/rules/no-ajax-events.js b/src/rules/no-ajax-events.js index 901632b..afa90b8 100644 --- a/src/rules/no-ajax-events.js +++ b/src/rules/no-ajax-events.js @@ -15,7 +15,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows global ajax events handlers: ' + disallowedEvents.map( utils.jQueryCollectionLink ).join( '/' ) + '. Prefer local events.' + description: 'Disallows global ajax events handlers: ' + disallowedEvents.map( utils.jQueryCollectionLink ).join( '/' ) + '. Prefer local events.', + recommended: false }, schema: [] }, diff --git a/src/rules/no-animate-toggle.js b/src/rules/no-animate-toggle.js index c3024fc..9f75d27 100644 --- a/src/rules/no-animate-toggle.js +++ b/src/rules/no-animate-toggle.js @@ -9,7 +9,8 @@ module.exports = { description: 'Disallows the duration argument when using the ' + utils.jQueryCollectionLink( 'show' ) + ', ' + utils.jQueryCollectionLink( 'hide' ) + ' & ' + utils.jQueryCollectionLink( 'toggle' ) + - ' methods. Prefer CSS transitions.' + ' methods. Prefer CSS transitions.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-animate.js b/src/rules/no-animate.js index 6066b8a..858a389 100644 --- a/src/rules/no-animate.js +++ b/src/rules/no-animate.js @@ -8,7 +8,8 @@ module.exports = { docs: { description: 'Disallows the ' + utils.jQueryCollectionLink( 'animate' ) + - ' method. Use the `allowScroll` option to allow animations which are just used for scrolling. Prefer CSS transitions.' + ' method. Use the `allowScroll` option to allow animations which are just used for scrolling. Prefer CSS transitions.', + recommended: true }, schema: [ { diff --git a/src/rules/no-append-html.js b/src/rules/no-append-html.js index 1942c5f..b95a580 100644 --- a/src/rules/no-append-html.js +++ b/src/rules/no-append-html.js @@ -23,7 +23,8 @@ module.exports = { type: 'suggestion', docs: { description: 'Disallows using ' + methods.map( utils.jQueryCollectionLink ).join( '/' ) + - ' to inject HTML, in order to prevent possible XSS bugs.' + ' to inject HTML, in order to prevent possible XSS bugs.', + recommended: false }, schema: [] }, diff --git a/src/rules/no-class-state.js b/src/rules/no-class-state.js index 7f3fee0..87d1e19 100644 --- a/src/rules/no-class-state.js +++ b/src/rules/no-class-state.js @@ -10,7 +10,8 @@ module.exports = { ' and ' + utils.jQueryCollectionLink( 'toggleClass' ) + ' to discourage querying the DOM for state information. ' + utils.jQueryCollectionLink( 'toggleClass' ) + ' may be used with a boolean argument as then it behaves like ' + - utils.jQueryCollectionLink( 'addClass' ) + '/' + utils.jQueryCollectionLink( 'removeClass' ) + '.' + utils.jQueryCollectionLink( 'addClass' ) + '/' + utils.jQueryCollectionLink( 'removeClass' ) + '.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-constructor-attributes.js b/src/rules/no-constructor-attributes.js index 0fde9a2..ec7700b 100644 --- a/src/rules/no-constructor-attributes.js +++ b/src/rules/no-constructor-attributes.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows passing attributes to the jQuery constructor. Prefer `.attr`.' + description: 'Disallows passing attributes to the jQuery constructor. Prefer `.attr`.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-deferred.js b/src/rules/no-deferred.js index 40cec3d..f88faaf 100644 --- a/src/rules/no-deferred.js +++ b/src/rules/no-deferred.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows ' + utils.jQueryGlobalLink( 'Deferred' ) + ' constructor. Prefer `Promise`.' + description: 'Disallows ' + utils.jQueryGlobalLink( 'Deferred' ) + ' constructor. Prefer `Promise`.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-extend.js b/src/rules/no-extend.js index 73f179c..a7c37c7 100644 --- a/src/rules/no-extend.js +++ b/src/rules/no-extend.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows the ' + utils.jQueryGlobalLink( 'extend' ) + ' utility. Prefer `Object.assign` or the spread operator.' + description: 'Disallows the ' + utils.jQueryGlobalLink( 'extend' ) + ' utility. Prefer `Object.assign` or the spread operator.', + recommended: true }, fixable: 'code', schema: [ diff --git a/src/rules/no-fx-interval.js b/src/rules/no-fx-interval.js index fc5ecca..46d529e 100644 --- a/src/rules/no-fx-interval.js +++ b/src/rules/no-fx-interval.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows ' + utils.jQueryGlobalLink( 'fx.interval' ) + '.' + description: 'Disallows ' + utils.jQueryGlobalLink( 'fx.interval' ) + '.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-global-selector.js b/src/rules/no-global-selector.js index f11432e..6678e66 100644 --- a/src/rules/no-global-selector.js +++ b/src/rules/no-global-selector.js @@ -13,7 +13,8 @@ module.exports = { docs: { description: 'Disallows global selectors which search the whole document. ' + 'Encourages users to keep references to DOM nodes in memory, instead of selecting them from the DOM each time. ' + - 'Use the `allowIds` option to allow single ID selectors.' + 'Use the `allowIds` option to allow single ID selectors.', + recommended: true }, schema: [ { diff --git a/src/rules/no-jquery-constructor.js b/src/rules/no-jquery-constructor.js index bc60e2e..d2597c6 100644 --- a/src/rules/no-jquery-constructor.js +++ b/src/rules/no-jquery-constructor.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows the jQuery constructor `$()`.' + description: 'Disallows the jQuery constructor `$()`.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-load-shorthand.js b/src/rules/no-load-shorthand.js index 2655a6e..6f99aa8 100644 --- a/src/rules/no-load-shorthand.js +++ b/src/rules/no-load-shorthand.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows the [`.load`](https://api.jquery.com/load-event/) method when used as a shorthand for `.on( \'load\', function )` or `.trigger( \'load\' )`. Prefer `.on` or `.trigger`.' + description: 'Disallows the [`.load`](https://api.jquery.com/load-event/) method when used as a shorthand for `.on( \'load\', function )` or `.trigger( \'load\' )`. Prefer `.on` or `.trigger`.', + recommended: true }, fixable: 'code', schema: [] diff --git a/src/rules/no-on-ready.js b/src/rules/no-on-ready.js index 7a81839..a76ed1d 100644 --- a/src/rules/no-on-ready.js +++ b/src/rules/no-on-ready.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows using the ready event on the document.' + description: 'Disallows using the ready event on the document.', + recommended: true }, fixable: 'code', schema: [] diff --git a/src/rules/no-other-methods.js b/src/rules/no-other-methods.js index 4fc2912..56ab71f 100644 --- a/src/rules/no-other-methods.js +++ b/src/rules/no-other-methods.js @@ -89,7 +89,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows all methods not covered by more specific rules.' + description: 'Disallows all methods not covered by more specific rules.', + recommended: false }, schema: [] }, diff --git a/src/rules/no-other-utils.js b/src/rules/no-other-utils.js index a7fce19..1b1ef02 100644 --- a/src/rules/no-other-utils.js +++ b/src/rules/no-other-utils.js @@ -57,7 +57,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows all utilities not covered by more specific rules.' + description: 'Disallows all utilities not covered by more specific rules.', + recommended: false }, schema: [] }, diff --git a/src/rules/no-parse-html-literal.js b/src/rules/no-parse-html-literal.js index 2efb36f..96f21d0 100644 --- a/src/rules/no-parse-html-literal.js +++ b/src/rules/no-parse-html-literal.js @@ -40,7 +40,8 @@ module.exports = { 'The format of single tags can be specified using the `singleTagStyle` option:\n' + '* `"minimal"` (default) no whitespace or self-closing i.e. `
`\n' + '* `"self-closing"` no whitespace and self-closing i.e. `
`\n' + - '* `"any"` no style enforced' + '* `"any"` no style enforced', + recommended: true }, fixable: 'code', schema: [ diff --git a/src/rules/no-ready.js b/src/rules/no-ready.js index 8cb0941..3c08e3f 100644 --- a/src/rules/no-ready.js +++ b/src/rules/no-ready.js @@ -25,7 +25,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows the document ready event, either `$( function() {} )` or `$( document ).ready()`.' + description: 'Disallows the document ready event, either `$( function() {} )` or `$( document ).ready()`.', + recommended: true }, schema: [] }, diff --git a/src/rules/no-sizzle.js b/src/rules/no-sizzle.js index 929aa35..0077116 100644 --- a/src/rules/no-sizzle.js +++ b/src/rules/no-sizzle.js @@ -21,7 +21,8 @@ module.exports = { docs: { description: 'Disallows selector extensions provided by Sizzle. Use the `allowPositional` option to allow positional selectors. ' + 'Use the `allowOther` option to allow all other selectors. These options are used in the `deprecated-3.4` ruleset as only positional ' + - 'selectors were deprecated in that version.' + 'selectors were deprecated in that version.', + recommended: true }, schema: [ { diff --git a/src/rules/variable-pattern.js b/src/rules/variable-pattern.js index b306d31..b541435 100644 --- a/src/rules/variable-pattern.js +++ b/src/rules/variable-pattern.js @@ -6,7 +6,8 @@ module.exports = { meta: { type: 'suggestion', docs: { - description: 'Disallows variable names which don\'t match `variablePattern` in settings (by default a `$`-prefix).' + description: 'Disallows variable names which don\'t match `variablePattern` in settings (by default a `$`-prefix).', + recommended: true }, schema: [] },