importScripts(var) can cause ESLint's import globals for workers to error (Cannot read property 'match' of undefined)

RESOLVED FIXED in Firefox 55

Status

Firefox Build System
Lint and Formatting
RESOLVED FIXED
a year ago
4 months ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

Version 3
mozilla55

Firefox Tracking Flags

(firefox55 fixed)

Details

MozReview Requests

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

a year ago
We've just hit this on an imported minified file, I think there may be a few other instances in the tree, so its probably worth fixing this.

The issue:

./mach eslint --no-ignore mobile/android/tests/browser/chrome/tp5/bbc.co.uk/static.bbc.co.uk/frameworks/requirejs/

Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
    at Object.convertWorkerExpressionToGlobals (/Users/mark/dev/gecko/node_modules/eslint-plugin-mozilla/lib/helpers.js:207:30)
    at GlobalsForNode.ExpressionStatement (/Users/mark/dev/gecko/node_modules/eslint-plugin-mozilla/lib/globals.js:111:35)
    at EventEmitter.parser.(anonymous function) (/Users/mark/dev/gecko/node_modules/eslint-plugin-mozilla/lib/globals.js:218:36)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:191:7)
    at NodeEventGenerator.applySelector (/Users/mark/dev/gecko/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/Users/mark/dev/gecko/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (/Users/mark/dev/gecko/node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (/Users/mark/dev/gecko/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
    at CommentEventGenerator.enterNode (/Users/mark/dev/gecko/node_modules/eslint/lib/util/comment-event-generator.js:98:23)

There's an `importScripts(url)` statement in the file that causes this to fail.

We can simply work around that by ensuring arg.value exists. Although this will cause us not to detect import of any globals, that would be fixed up by the no-undef script, and we could consider how to fix this properly when we hit a real instance.
Comment hidden (mozreview-request)

Comment 2

a year ago
mozreview-review
Comment on attachment 8861827 [details]
Bug 1359739 - Fix eslint-plugin-mozilla's globals import function to correctly handle 'importScripts(url)' cases.

https://reviewboard.mozilla.org/r/133836/#review136840
Attachment #8861827 - Flags: review?(jaws) → review+

Comment 3

a year ago
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b9a9e58ddd3f
Fix eslint-plugin-mozilla's globals import function to correctly handle 'importScripts(url)' cases. r=jaws

Comment 4

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/b9a9e58ddd3f
Status: NEW → RESOLVED
Last Resolved: a year ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55

Updated

4 months ago
Product: Testing → Firefox Build System
You need to log in before you can comment on or make changes to this bug.