Skip to content

Commit

Permalink
fix(rules): fix empty CSS selector input for 'no-bootstrap-classes' a…
Browse files Browse the repository at this point in the history
…nd 'no-angular-classes' rules
  • Loading branch information
alecxe committed Jul 17, 2016
1 parent 4bf1ae6 commit b4e3cbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/extract-class-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion test/rules/no-bootstrap-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit b4e3cbf

Please sign in to comment.