From aa7bd9a5fcd6b390953a61f1c23ac3615d82c9bf Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 16 Oct 2019 14:39:09 +0100 Subject: [PATCH] Introduce `no-visibility`, deprecate `no-show`, `no-hide`, `no-toggle` See #163 --- README.md | 9 ++++++--- docs/no-hide.md | 2 ++ docs/no-show.md | 2 ++ docs/no-toggle.md | 2 ++ index.js | 1 + rule-tester-and-docs.js | 10 ++++++++++ rules/no-hide.js | 7 ++++++- rules/no-show.js | 7 ++++++- rules/no-toggle.js | 7 ++++++- 9 files changed, 41 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6c710825..5b2d6a6f 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,6 @@ The following global settings can be used under the "no-jquery" property to conf * [no-jquery/no-global-eval](docs/no-global-eval.md) * [no-jquery/no-grep](docs/no-grep.md) * [no-jquery/no-has](docs/no-has.md) -* [no-jquery/no-hide](docs/no-hide.md) * [no-jquery/no-hold-ready](docs/no-hold-ready.md) * [no-jquery/no-html](docs/no-html.md) * [no-jquery/no-in-array](docs/no-in-array.md) @@ -132,7 +131,6 @@ The following global settings can be used under the "no-jquery" property to conf * [no-jquery/no-global-selector](docs/no-global-selector.md) * [no-jquery/no-selector-prop](docs/no-selector-prop.md) * [no-jquery/no-serialize](docs/no-serialize.md) -* [no-jquery/no-show](docs/no-show.md) * [no-jquery/no-size](docs/no-size.md) * [no-jquery/no-sizzle](docs/no-sizzle.md) * [no-jquery/no-slide](docs/no-slide.md) @@ -140,7 +138,6 @@ The following global settings can be used under the "no-jquery" property to conf * [no-jquery/no-submit](docs/no-submit.md) * [no-jquery/no-support](docs/no-support.md) * [no-jquery/no-text](docs/no-text.md) -* [no-jquery/no-toggle](docs/no-toggle.md) * [no-jquery/no-trigger](docs/no-trigger.md) * [no-jquery/no-trim](docs/no-trim.md) * [no-jquery/no-type](docs/no-type.md) @@ -149,9 +146,15 @@ The following global settings can be used under the "no-jquery" property to conf * [no-jquery/no-unique](docs/no-unique.md) * [no-jquery/no-unload-shorthand](docs/no-unload-shorthand.md) * [no-jquery/no-val](docs/no-val.md) +* [no-jquery/no-visibility](docs/no-visibility.md) * [no-jquery/no-when](docs/no-when.md) * [no-jquery/no-wrap](docs/no-wrap.md) +### Deprecated +* [no-jquery/no-hide](docs/no-hide.md) +* [no-jquery/no-show](docs/no-show.md) +* [no-jquery/no-toggle](docs/no-toggle.md) + ## Development ```sh diff --git a/docs/no-hide.md b/docs/no-hide.md index 26ae8b07..37c112bf 100644 --- a/docs/no-hide.md +++ b/docs/no-hide.md @@ -2,6 +2,8 @@ Disallows the .hide method. +⚠️ This rule is deprecated. Use [no-visibility](no-visibility.md) instead. + ## Rule details ❌ The following patterns are considered errors: diff --git a/docs/no-show.md b/docs/no-show.md index 6fa8576e..ed7b3082 100644 --- a/docs/no-show.md +++ b/docs/no-show.md @@ -2,6 +2,8 @@ Disallows the .show method. +⚠️ This rule is deprecated. Use [no-visibility](no-visibility.md) instead. + ## Rule details ❌ The following patterns are considered errors: diff --git a/docs/no-toggle.md b/docs/no-toggle.md index ce6bd723..6c3448b2 100644 --- a/docs/no-toggle.md +++ b/docs/no-toggle.md @@ -2,6 +2,8 @@ Disallows the .toggle method. +⚠️ This rule is deprecated. Use [no-visibility](no-visibility.md) instead. + ## Rule details ❌ The following patterns are considered errors: diff --git a/index.js b/index.js index 7e0d5e66..c81e4044 100644 --- a/index.js +++ b/index.js @@ -91,6 +91,7 @@ module.exports = { 'no-unique': require( './rules/no-unique' ), 'no-unload-shorthand': require( './rules/no-unload-shorthand' ), 'no-val': require( './rules/no-val' ), + 'no-visibility': require( './rules/no-visibility' ), 'no-when': require( './rules/no-when' ), 'no-wrap': require( './rules/no-wrap' ) }, diff --git a/rule-tester-and-docs.js b/rule-tester-and-docs.js index 5baab550..e3d5e55c 100644 --- a/rule-tester-and-docs.js +++ b/rule-tester-and-docs.js @@ -101,6 +101,16 @@ class RuleTesterAndDocs extends RuleTester { console.warn( 'Rule ' + name + ' has no description.' ); } + if ( rule.meta.docs.deprecated ) { + output += '⚠️ This rule is deprecated.'; + if ( rule.meta.docs.replacedBy ) { + output += ' Use ' + + rule.meta.docs.replacedBy.map( ( name ) => '[' + name + '](' + name + '.md)' ).join( ', ' ) + + ' instead.'; + } + output += '\n\n'; + } + if ( name in rulesData ) { const data = rulesData[ name ]; output += 'This rule is enabled in `plugin:no-jquery/' + data.ruleset + '`'; diff --git a/rules/no-hide.js b/rules/no-hide.js index fbc4009f..b0577392 100644 --- a/rules/no-hide.js +++ b/rules/no-hide.js @@ -2,4 +2,9 @@ const utils = require( './utils.js' ); -module.exports = utils.createCollectionMethodRule( 'hide' ); +const rule = utils.createCollectionMethodRule( 'hide' ); + +rule.meta.docs.deprecated = true; +rule.meta.docs.replacedBy = [ 'no-visibility' ]; + +module.exports = rule; diff --git a/rules/no-show.js b/rules/no-show.js index 339f7aba..18a6a88b 100644 --- a/rules/no-show.js +++ b/rules/no-show.js @@ -2,4 +2,9 @@ const utils = require( './utils.js' ); -module.exports = utils.createCollectionMethodRule( 'show' ); +const rule = utils.createCollectionMethodRule( 'show' ); + +rule.meta.docs.deprecated = true; +rule.meta.docs.replacedBy = [ 'no-visibility' ]; + +module.exports = rule; diff --git a/rules/no-toggle.js b/rules/no-toggle.js index fe38a544..fe308b5f 100644 --- a/rules/no-toggle.js +++ b/rules/no-toggle.js @@ -2,4 +2,9 @@ const utils = require( './utils.js' ); -module.exports = utils.createCollectionMethodRule( 'toggle' ); +const rule = utils.createCollectionMethodRule( 'toggle' ); + +rule.meta.docs.deprecated = true; +rule.meta.docs.replacedBy = [ 'no-visibility' ]; + +module.exports = rule;