Closed
Bug 1328565
Opened 9 years ago
Closed 9 years ago
[eslint] Figure out how/if to handle importing globals from "var foo = Cu.import("...", this);"
Categories
(Developer Infrastructure :: Lint and Formatting, defect)
Tracking
(firefox53 fixed)
RESOLVED
FIXED
mozilla53
Tracking | Status | |
---|---|---|
firefox53 | --- | fixed |
People
(Reporter: standard8, Assigned: standard8)
References
Details
Attachments
(2 files)
Bug 1328565 - Prevent cases of Cu.import importing into variables and global scope at the same time.
59 bytes,
text/x-review-board-request
|
mossop
:
review+
|
Details |
845 bytes,
patch
|
standard8
:
review+
|
Details | Diff | Splinter Review |
Currently, when the import-globals plugin runs, it doesn't detect globals imported via:
```
var foo = Cu.import("bar.jsm", this);
```
The expected result is that `foo` and `bar` should both be globals here. However, currently only `foo` is a global.
The plugin doesn't detect this case, as it expects the `Cu.import` to be at the beginning of the line.
I'd also argue that this is a non-obvious case: we're importing into a specific variable *and* the global scope. To me, that feel unexpected, and I think we should consider banning this case.
Assignee | ||
Comment 1•9 years ago
|
||
As far as I can tell, there's only four instances of this in the tree:
https://dxr.mozilla.org/mozilla-central/search?q=regexp%3A%5Evar.*%3D.*Components.utils.import%5C(%5B%27%22%5D.*%5C.js.*%2C+this)%3B&redirect=false
-> toolkit/modules/tests/browser/browser_Battery.js
https://dxr.mozilla.org/mozilla-central/search?q=regexp%3A%5Evar.*%3D.*Cu.import%5C(%5B%27%22%5D.*%5C.js.*%2C+this)%3B&redirect=false
-> toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
-> toolkit/components/crashes/tests/xpcshell/test_crash_service.js
-> toolkit/components/crashes/tests/xpcshell/test_crash_store.js
Comment 2•9 years ago
|
||
Due to the low occurrences, awkwardness of the behavior, as well as where this practice is used (tests only) I'm fine with removing these and banning them.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → standard8
Comment hidden (mozreview-request) |
Comment 4•9 years ago
|
||
mozreview-review |
Comment on attachment 8823781 [details]
Bug 1328565 - Prevent cases of Cu.import importing into variables and global scope at the same time.
https://reviewboard.mozilla.org/r/102300/#review102686
Attachment #8823781 -
Flags: review?(dtownsend) → review+
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b6d798426ca0
Prevent cases of Cu.import importing into variables and global scope at the same time. r=mossop
Assignee | ||
Comment 6•9 years ago
|
||
I just realised that I forgot to bump the eslint-plugin-mozilla version, hence developers won't automatically pick up the new files.
Going to get this landed as a bustage fix for developers.
Attachment #8823981 -
Flags: review+
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/01d4695721e1
bump the eslint-plugin-mozilla version to ensure developers get the changes installed properly. r=bustage-fix
Comment 8•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b6d798426ca0
https://hg.mozilla.org/mozilla-central/rev/01d4695721e1
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox53:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Updated•7 years ago
|
Product: Testing → Firefox Build System
Updated•7 years ago
|
Version: Version 3 → 3 Branch
Updated•3 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•