EmmanuelDemey/eslint-plugin-angular

avoid-scope-typos, module-getter, module-setter are buggy

Opened this issue · 1 comments

I enabled this (and all other rules) and tested the plugin with jquery3.1.1.
jquery-3.1.1.js.zip

for avoid-scope-typos i get:
Cannot read property 'name' of undefined TypeError: Cannot read property 'name' of undefined at check (XXX\node_modules\eslint-plugin-angular\rules\avoid-scope-typos.js:24:75) at Linter.Identifier (XXX\linter\node_modules\eslint-plugin-angular\rules\avoid-scope-typos.js:31:17) at emitOne (events.js:82:20) at Linter.emit (events.js:169:7) at NodeEventGenerator.applySelector (XXX\node_modules\eslint\lib\util\node-event-generator.js:265:26) at NodeEventGenerator.applySelectors (XXX\node_modules\eslint\lib\util\node-event-generator.js:294:22) at NodeEventGenerator.enterNode (XXX\node_modules\eslint\lib\util\node-event-generator.js:308:14) at CodePathAnalyzer.enterNode (XXX\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:60 2:23) at Traverser.enter (XXX\node_modules\eslint\lib\linter.js:925:36) at Traverser.__execute (XXX\node_modules\eslint\node_modules\estraverse\estraverse.js:397:31) at Traverser.traverse (XXX\node_modules\eslint\node_modules\estraverse\estraverse.js:501:28)

The other both rules i cannot check again at the moment due to the typos-rules-error, but i had similar problems with it.

I get the same error:

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at check (XXX/node_modules/eslint-plugin-angular/rules/avoid-scope-typos.js:24:75)
    at EventEmitter.Identifier (XXX/node_modules/eslint-plugin-angular/rules/avoid-scope-typos.js:31:17)
    at emitOne (events.js:120:20)
    at EventEmitter.emit (events.js:210:7)
    at NodeEventGenerator.applySelector (XXX/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (XXX/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (XXX/node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (XXX/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:606:23)
    at Traverser.enter (XXX/node_modules/eslint/lib/linter.js:1035:32)
    at Traverser.__execute (XXX/node_modules/estraverse/estraverse.js:397:31)
    at Traverser.traverse (XXX/node_modules/estraverse/estraverse.js:501:28)

I put a try/catch around the conditional block starting on line 24:

if (bad.indexOf(name) >= 0 && scope.indexOf(node.parent.object.name) >= 0)

And logged node to find the problematic node. I see node.name but no node.parent.object.name

Node {
  type: 'Identifier',
  start: 1096,
  end: 1101,
  loc: 
   SourceLocation {
     start: Position { line: 35, column: 4 },
     end: Position { line: 35, column: 9 } },
  range: [ 1096, 1101 ],
  name: 'watch',
  parent: 
   Node {
     type: 'Property',
     start: 1096,
     end: 1248,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 1096, 1248 ],
     method: false,
     shorthand: false,
     computed: false,
     key: [Circular],
     value: 
      Node {
        type: 'ObjectExpression',
        start: 1103,
        end: 1248,
        loc: [Object],
        range: [Array],
        properties: [Array] },
     kind: 'init',
     parent: 
      Node {
        type: 'ObjectExpression',
        start: 929,
        end: 5616,
        loc: [Object],
        range: [Array],
        properties: [Array],
        parent: [Object] } } }