Closed Bug 1758474 Opened 3 years ago Closed 3 years ago

Implement an ESLint rule to disallow passing {} as the target parameter for `ChromeUtils.import`

Categories

(Developer Infrastructure :: Lint and Formatting, task, P3)

Tracking

(firefox100 fixed)

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

We have lots of cases in the code where we're doing something like:

let { PermissionUI } = ChromeUtils.import(
  "resource:///modules/PermissionUI.jsm",
  {}
);

However, the {} parameter is now redundant - it used to stop import into the global environment, but how that works has now changed.

I have a patch to do this, it also tidies up some instances to use object destructuring.

Blocks: 1758481
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5018856d8fee Implement an ESLint rule to disallow passing {} as the target parameter for ChromeUtils.import. r=Gijs,mossop,perftest-reviewers,preferences-reviewers,sparky

Backed out changeset 5018856d8fee (bug 1758474) for causing node eslint failure.

Backout link: https://hg.mozilla.org/integration/autoland/rev/9a3cf71fe2f7be7919f564182a0829f2bf083d6e

Push with failures

Failure log

[task 2022-03-10T09:41:23.814Z] TEST-UNEXPECTED-FAIL | reject-chromeutils-import-params.js | ChromeUtils.import("resource://some/path/to/My.js", {}) | args.at is not a function
[task 2022-03-10T09:41:23.814Z] Occurred while linting <input>:1
Flags: needinfo?(standard8)
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bbd63e7b1857 Implement an ESLint rule to disallow passing {} as the target parameter for ChromeUtils.import. r=Gijs,mossop,perftest-reviewers,preferences-reviewers,sparky
Flags: needinfo?(standard8)
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch
Pushed by mkmelin@iki.fi: https://hg.mozilla.org/comm-central/rev/9b6afe631195 fix up 2 remaining callers passing {} as the target parameter for `ChromeUtils.import`. rs=eslint
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: