-
Notifications
You must be signed in to change notification settings - Fork 129
Closed
Description
If you lint this code:
angular.module('MyModule').value('emptyArray', []);
certain rules will break the linter with this:
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
at findFunctionByNode (eslint-plugin-angular/rules/utils/angular-rule.js:202:17)
at checkCallee (eslint-plugin-angular/rules/utils/angular-rule.js:150:25)
I believe the issue is the assumption that the array always has elements:
/**
* Find the function expression or function declaration by an Angular component callee.
*/
function findFunctionByNode(callExpressionNode, scope) {
// ...
if (node.type === 'ArrayExpression') {
node = node.elements[node.elements.length - 1];
}
// ...
}