Skip to content

Commit

Permalink
Include the $.css utility in the no-css rule
Browse files Browse the repository at this point in the history
See #112
  • Loading branch information
edg2s committed Sep 30, 2019
1 parent 188b910 commit 7acdb42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/no-css.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# no-css

Disallows the .css method. Prefer Window#getComputedStyle to $.css.
Disallows the .css method and $.css utility. Prefer Window#getComputedStyle to $.css.

## Rule details

✗ The following patterns are considered errors:
```js
$.css();
$( 'div' ).css();
$div.css();
$( 'div' ).first().css();
Expand Down
2 changes: 1 addition & 1 deletion rules/no-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const utils = require( './utils.js' );

module.exports = utils.createCollectionMethodRule(
module.exports = utils.createCollectionOrUtilMethodRule(
'css',
'Prefer Window#getComputedStyle to $.css'
);
4 changes: 4 additions & 0 deletions tests/no-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const ruleTester = new RuleTesterAndDocs();
ruleTester.run( 'no-css', rule, {
valid: [ 'css()', '[].css()', 'div.css()', 'div.css' ],
invalid: [
{
code: '$.css()',
errors: [ { message: error, type: 'CallExpression' } ]
},
{
code: '$("div").css()',
errors: [ { message: error, type: 'CallExpression' } ]
Expand Down

0 comments on commit 7acdb42

Please sign in to comment.