Skip to content

Commit b5d5ca5

Browse files
jdforresteredg2s
authored andcommitted
Add 'recommended' status to each rule as a starter
Fixes #249.
1 parent 77fefab commit b5d5ca5

21 files changed

+56
-23
lines changed

docs/rules/no-is-function.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ Disallows the [`$.isFunction`](https://api.jquery.com/jQuery.isFunction/) utilit
1515
❌ Examples of **incorrect** code:
1616
```js
1717
$.isFunction( expression( arg ) );
18-
if ( $.isFunction( fn ) ) { g(); }
18+
19+
if ( $.isFunction( fn ) ) {
20+
g();
21+
}
1922
```
2023

2124
✔️ Examples of **correct** code:
@@ -28,7 +31,10 @@ $div.isFunction();
2831
🔧 Examples of code **fixed** by this rule:
2932
```js
3033
$.isFunction( expression( arg ) ); /**/ typeof expression( arg ) === 'function';
31-
if ( $.isFunction( fn ) ) { g(); } /**/ if ( typeof fn === 'function' ) { g(); }
34+
35+
if ( $.isFunction( fn ) ) { /**/ if ( typeof fn === 'function' ) {
36+
g(); /**/ g();
37+
} /**/ }
3238
```
3339

3440
## Resources

docs/rules/variable-pattern.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ div = $div.attr( { name: fn } );
2525
div = $div.outerWidth( 30 );
2626
number = $div.outerWidth( 30, true );
2727
number = $div.outerWidth( mustBeNumber, true );
28-
div = $div.outerWidth( function () { return 30; } );
28+
29+
div = $div.outerWidth( function () {
30+
return 30;
31+
} );
32+
2933
div = $div.outerHeight( 30 );
3034
number = $div.outerHeight( 30, true );
3135
number = $div.outerHeight( mustBeNumber, true );
32-
div = $div.outerHeight( function () { return 30; } );
36+
37+
div = $div.outerHeight( function () {
38+
return 30;
39+
} );
40+
3341
list = $div.queue( newQueueOrCallBack );
3442
list = $div.queue( [] );
3543
div = $div.queue( 'fx', newQueueOrCallBack );

src/rules/no-ajax-events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module.exports = {
1515
meta: {
1616
type: 'suggestion',
1717
docs: {
18-
description: 'Disallows global ajax events handlers: ' + disallowedEvents.map( utils.jQueryCollectionLink ).join( '/' ) + '. Prefer local events.'
18+
description: 'Disallows global ajax events handlers: ' + disallowedEvents.map( utils.jQueryCollectionLink ).join( '/' ) + '. Prefer local events.',
19+
recommended: false
1920
},
2021
schema: []
2122
},

src/rules/no-animate-toggle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = {
99
description:
1010
'Disallows the duration argument when using the ' + utils.jQueryCollectionLink( 'show' ) +
1111
', ' + utils.jQueryCollectionLink( 'hide' ) + ' & ' + utils.jQueryCollectionLink( 'toggle' ) +
12-
' methods. Prefer CSS transitions.'
12+
' methods. Prefer CSS transitions.',
13+
recommended: true
1314
},
1415
schema: []
1516
},

src/rules/no-animate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = {
88
docs: {
99
description:
1010
'Disallows the ' + utils.jQueryCollectionLink( 'animate' ) +
11-
' method. Use the `allowScroll` option to allow animations which are just used for scrolling. Prefer CSS transitions.'
11+
' method. Use the `allowScroll` option to allow animations which are just used for scrolling. Prefer CSS transitions.',
12+
recommended: true
1213
},
1314
schema: [
1415
{

src/rules/no-append-html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module.exports = {
2323
type: 'suggestion',
2424
docs: {
2525
description: 'Disallows using ' + methods.map( utils.jQueryCollectionLink ).join( '/' ) +
26-
' to inject HTML, in order to prevent possible XSS bugs.'
26+
' to inject HTML, in order to prevent possible XSS bugs.',
27+
recommended: false
2728
},
2829
schema: []
2930
},

src/rules/no-class-state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = {
1010
' and ' + utils.jQueryCollectionLink( 'toggleClass' ) +
1111
' to discourage querying the DOM for state information. ' +
1212
utils.jQueryCollectionLink( 'toggleClass' ) + ' may be used with a boolean argument as then it behaves like ' +
13-
utils.jQueryCollectionLink( 'addClass' ) + '/' + utils.jQueryCollectionLink( 'removeClass' ) + '.'
13+
utils.jQueryCollectionLink( 'addClass' ) + '/' + utils.jQueryCollectionLink( 'removeClass' ) + '.',
14+
recommended: true
1415
},
1516
schema: []
1617
},

src/rules/no-constructor-attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
meta: {
77
type: 'suggestion',
88
docs: {
9-
description: 'Disallows passing attributes to the jQuery constructor. Prefer `.attr`.'
9+
description: 'Disallows passing attributes to the jQuery constructor. Prefer `.attr`.',
10+
recommended: true
1011
},
1112
schema: []
1213
},

src/rules/no-deferred.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
meta: {
77
type: 'suggestion',
88
docs: {
9-
description: 'Disallows ' + utils.jQueryGlobalLink( 'Deferred' ) + ' constructor. Prefer `Promise`.'
9+
description: 'Disallows ' + utils.jQueryGlobalLink( 'Deferred' ) + ' constructor. Prefer `Promise`.',
10+
recommended: true
1011
},
1112
schema: []
1213
},

src/rules/no-extend.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
meta: {
77
type: 'suggestion',
88
docs: {
9-
description: 'Disallows the ' + utils.jQueryGlobalLink( 'extend' ) + ' utility. Prefer `Object.assign` or the spread operator.'
9+
description: 'Disallows the ' + utils.jQueryGlobalLink( 'extend' ) + ' utility. Prefer `Object.assign` or the spread operator.',
10+
recommended: true
1011
},
1112
fixable: 'code',
1213
schema: [

0 commit comments

Comments
 (0)