Closed Bug 1231963 Opened 7 years ago Closed 7 years ago

ESLint should treat global `this` as the global scope

Categories

(Testing :: General, defect)

defect
Not set
normal

Tracking

(firefox46 fixed)

RESOLVED FIXED
mozilla46
Tracking Status
firefox46 --- fixed

People

(Reporter: kmag, Assigned: tromey)

References

Details

Attachments

(1 file)

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.
This also affects some code in devtools.
Blocks: 1240183
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
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+
Blocks: 1241544
https://hg.mozilla.org/mozilla-central/rev/cf165d1764d6
Status: ASSIGNED → RESOLVED
Closed: 7 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)
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.