ESLint should treat global `this` as the global scope

RESOLVED FIXED in Firefox 46

Status

defect
RESOLVED FIXED
4 years ago
3 years ago

People

(Reporter: kmag, Assigned: tromey)

Tracking

(Blocks 1 bug)

unspecified
mozilla46
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox46 fixed)

Details

Attachments

(1 attachment)

Reporter

Description

4 years ago
ESLint doesn't treat `this` at the top level as a reference to the global scope. This causes problems for many JSMs, which have to define globals as properties of `this` for the sake of the b2g loader.

I'm not sure if this should be fixed in ESLint or implemented as a plugin, but either way, it affects a lot of our code.
Assignee

Comment 1

4 years ago
This also affects some code in devtools.
Assignee

Updated

4 years ago
Blocks: 1240183
Assignee

Updated

4 years ago
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
Assignee

Updated

4 years ago
Attachment #8709534 - Flags: review?(mratcliffe)
Comment on attachment 8709534 [details] [diff] [review]
handle top-level "this.mumble" assignments in eslint

Review of attachment 8709534 [details] [diff] [review]:
-----------------------------------------------------------------

Couldn't be simpler, r+.
Attachment #8709534 - Flags: review?(mratcliffe) → review+
Assignee

Updated

4 years ago
Blocks: 1241544

Comment 6

4 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/cf165d1764d6
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
Nice one Tom!
I think this (and other rules like import-globals-from, etc.) should be mentioned to a wider audience in an email to dev-platform. Many teams are in the process of getting rid of eslint errors, and these rules come in very handy. Would you like to do that?
Flags: needinfo?(ttromey)
Assignee

Comment 8

3 years ago
Actually this rule got unified with some others in bug 1245916,
and enabled by default.  Also from grepping a bit it seems the other
groups are already using some of the other mozilla rules.
So, I think maybe an email isn't needed.
Flags: needinfo?(ttromey)
You need to log in before you can comment on or make changes to this bug.