alecxe/eslint-plugin-protractor

View on GitHub
lib/rules/no-compound-classes.js

Summary

Maintainability
A
1 hr
Test Coverage
'use strict'
 
/**
* @fileoverview Do not allow compound class names in the by.className locator
* @author Alexander Afanasyev
*/
var isLocator = require('../find-locator')
 
module.exports = {
meta: {
schema: []
},
 
Function `create` has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
create: function (context) {
return {
'CallExpression': function (node) {
if (node.arguments && node.arguments.length && node.arguments[0].hasOwnProperty('value')) {
if (isLocator(node, 'className')) {
var locatorValue = node.arguments[0].value.trim()
 
Similar blocks of code found in 3 locations. Consider refactoring.
if (locatorValue.indexOf(' ') >= 0) {
context.report({
node: node.arguments[0],
message: 'No compound class names allowed.'
})
}
}
}
}
}
}
}