From 7acdb4278eba6d42831251ca631e1a4dc696a40d Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sun, 29 Sep 2019 21:25:17 -0400 Subject: [PATCH] Include the `$.css` utility in the `no-css` rule See #112 --- docs/no-css.md | 3 ++- rules/no-css.js | 2 +- tests/no-css.js | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/no-css.md b/docs/no-css.md index 0f693846..ada50ab6 100644 --- a/docs/no-css.md +++ b/docs/no-css.md @@ -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(); diff --git a/rules/no-css.js b/rules/no-css.js index 998933f0..96ef921c 100644 --- a/rules/no-css.js +++ b/rules/no-css.js @@ -2,7 +2,7 @@ const utils = require( './utils.js' ); -module.exports = utils.createCollectionMethodRule( +module.exports = utils.createCollectionOrUtilMethodRule( 'css', 'Prefer Window#getComputedStyle to $.css' ); diff --git a/tests/no-css.js b/tests/no-css.js index 09f53a2a..51ab8846 100644 --- a/tests/no-css.js +++ b/tests/no-css.js @@ -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' } ]