From b4e3cbf35e47303ff12f46a307968454df9ea287 Mon Sep 17 00:00:00 2001 From: Alexander Afanasyev Date: Sun, 17 Jul 2016 14:31:45 -0400 Subject: [PATCH] fix(rules): fix empty CSS selector input for 'no-bootstrap-classes' and 'no-angular-classes' rules --- lib/extract-class-names.js | 9 ++++++--- test/rules/no-bootstrap-classes.js | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/extract-class-names.js b/lib/extract-class-names.js index 71e88b6..517be09 100644 --- a/lib/extract-class-names.js +++ b/lib/extract-class-names.js @@ -42,11 +42,14 @@ module.exports = function (cssSelector) { return [] } + // handling empty inputs + if (!result) { + return [] + } + var classNames = [] - if (result.type === 'rule') { - classNames = extractClassNames(result.rule) - } else if (result.type === 'ruleSet') { + if (result.type === 'ruleSet') { var rule = result.rule while (rule) { classNames.push.apply(classNames, extractClassNames(rule)) diff --git a/test/rules/no-bootstrap-classes.js b/test/rules/no-bootstrap-classes.js index f519ba8..3f154e8 100644 --- a/test/rules/no-bootstrap-classes.js +++ b/test/rules/no-bootstrap-classes.js @@ -26,7 +26,9 @@ eslintTester.run('no-bootstrap-classes', rule, { '$("p::first-line");', '$("invalid::selector()");', '$("a[href^=/], .container:has(nav) > a[href]:lt($var)");', - '$$("//somethinginvalid[@attr=\'test\']")' + '$$("//somethinginvalid[@attr=\'test\']")', + 'element(by.css("a[href]"));', + '$("");' ], invalid: [