Skip to content

A value recipe with an empty array breaks the linter #425

@dpatti

Description

@dpatti

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];
    }
    // ...
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions