Closed Bug 1469384 Opened Last year Closed Last year

"Cannot read property 'type' of undefined" in eslint-plugin-mozilla no-useless-removeEventListener rule

Categories

(Firefox Build System :: Lint and Formatting, defect, P3)

3 Branch
defect

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: pdehaan, Assigned: standard8)

Details

Attachments

(1 file)

Using eslint-plugin-mozilla@0.14.0 and I'm getting the following error when trying to lint https://github.com/mozilla/blurts-addon/tree/popup_variants

> blurts-addon@1.0.0 lint /Users/pdehaan/dev/github/mozilla/blurts-addon
> eslint src --ext=js,json,jsm

Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at CallExpression (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js:33:20)
    at listeners.(anonymous function).forEach.listener (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at Traverser.enter [as _enter] (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/linter.js:865:28)
    at Traverser._traverse (/Users/pdehaan/dev/github/mozilla/blurts-addon/node_modules/eslint/lib/util/traverser.js:132:14)


Error seems to be coming from https://dxr.mozilla.org/mozilla-central/rev/75a32b57132f8cba42779555662a057a0416a313/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js#33 where we aren't checking if `listener` is a thing before trying to access the `type` or `body` parameters.
Component: General → Lint and Formatting
Product: Testing → Firefox Build System
Assignee: nobody → standard8
Status: NEW → ASSIGNED
Priority: -- → P3
Comment on attachment 9009169 [details]
Bug 1469384 - Allow no-useless-removeEventListener to not throw if only one argument is given to an addEventListener call.

Florian Quèze [:florian] has approved the revision.
Attachment #9009169 - Flags: review+
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0d816433a453
Allow no-useless-removeEventListener to not throw if only one argument is given to an addEventListener call. r=florian
https://hg.mozilla.org/mozilla-central/rev/0d816433a453
Status: ASSIGNED → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.