Closed Bug 1359739 Opened 4 years ago Closed 4 years ago

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

Categories

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

3 Branch
defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: standard8, Assigned: standard8)

Details

Attachments

(1 file)

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 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+
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
https://hg.mozilla.org/mozilla-central/rev/b9a9e58ddd3f
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Product: Testing → Firefox Build System
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.