Skip to content

Commit

Permalink
fix(rules): fix the empty argument 'valid-locator-type' rule problem (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alecxe committed Nov 14, 2016
1 parent 1bb1139 commit 65a6b5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rules/valid-locator-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function is$$ (node) {
* @returns {boolean}
*/
function isArgumentLiteral (node) {
return node.arguments && node.arguments[0].type === 'Literal'
return node.arguments && node.arguments.length && node.arguments[0].type === 'Literal'
}

/**
Expand All @@ -67,7 +67,7 @@ function isArgumentLiteral (node) {
* @returns {boolean}
*/
function isArgumentByLocator (node) {
if (node.arguments && node.arguments[0].type === 'CallExpression') {
if (node.arguments && node.arguments.length && node.arguments[0].type === 'CallExpression') {
var argument = node.arguments[0]
if (argument.callee && argument.callee.object && argument.callee.object.name === 'by') {
return true
Expand Down
10 changes: 9 additions & 1 deletion test/rules/valid-locator-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ eslintTester.run('valid-locator-type', rule, {
'$$(".class1").all(by.css(".class2"));',
'$(".class1").$(".class2");',
'$(".class1").$$(".class2");',
'$$(".class1").$$(".class2");'
'$$(".class1").$$(".class2");',
'element();',
'element(somevariable);',
'element.all();',
'element.all(somevariable);',
'$$(".class1").$$();',
'$$(".class1").$$(somevariable);',
'$();',
'$(somevariable);'
],

invalid: [
Expand Down

0 comments on commit 65a6b5c

Please sign in to comment.