Closed Bug 1478305 Opened 7 years ago Closed 7 years ago

ESLint should treat ChomeUtils.import as real variable definitions where possible

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement, P2)

enhancement

Tracking

(firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

Details

Attachments

(7 files)

Building on Kris' change in bug 1456686 to treat some imports as real variable definitions, I think we can do the same for Cu.import, where the imported module has only one export. This will help us eliminate more unused imports, mainly in *.jsm files where we have no-unused-vars in the global scope. There's a few other locations where that is also enabled globally so they will benefit as well.
Note: the reason we can't really do it for modules that have more than one export (at the moment), is that if only one export is used it'll flag the others as unused. We can maybe have a follow-up to start to get people to use the explicit form of imports.
Summary: ESLint should treat Cu.import as real variable definitions where possible → ESLint should treat ChomeUtils.import as real variable definitions where possible
Priority: -- → P2
Depends on: 1478308
Blocks: 1355202
Comment on attachment 8995923 [details] Bug 1478305 - Remove unnecessary ChromeUtils.import calls in mobile/. https://reviewboard.mozilla.org/r/260222/#review267288
Attachment #8995923 - Flags: review?(snorp) → review+
Comment on attachment 8995922 [details] Bug 1478305 - Remove unnecessary ChromeUtils.import calls in dom/media. https://reviewboard.mozilla.org/r/260220/#review267296
Attachment #8995922 - Flags: review?(docfaraday) → review+
Comment on attachment 8995920 [details] Bug 1478305 - For xpcshell-test head files, limit checking no-unused-vars to the local scope only. https://reviewboard.mozilla.org/r/260216/#review267344
Attachment #8995920 - Flags: review?(dtownsend) → review+
Comment on attachment 8995924 [details] Bug 1478305 - Remove unnecessary ChromeUtils.import calls in testing/. https://reviewboard.mozilla.org/r/260224/#review267346 ::: testing/marionette/test/unit/test_cookie.js:43 (Diff revision 2) > - let hostCookies = this.cookies.filter(cookie => cookie.host === host || > - cookie.host === "." + host); > + let hostCookies = this.cookies.filter(c => c.host === host || > + c.host === "." + host); This change looks unrelated.
Attachment #8995924 - Flags: review?(dtownsend) → review+
Comment on attachment 8995925 [details] Bug 1478305 - Remove unnecessary imports and fix ESLint warnings about unused variables for toolkit/. https://reviewboard.mozilla.org/r/260226/#review267348
Attachment #8995925 - Flags: review?(dtownsend) → review+
Comment on attachment 8994782 [details] Bug 1478305 - Update ESLint to treat ChromeUtils.import definitions as real variable definitions for single-export modules. https://reviewboard.mozilla.org/r/259314/#review267350
Attachment #8994782 - Flags: review?(dtownsend) → review+
Comment on attachment 8995924 [details] Bug 1478305 - Remove unnecessary ChromeUtils.import calls in testing/. https://reviewboard.mozilla.org/r/260224/#review267346 > This change looks unrelated. This is needed, because the import at the top of the file is importing a global named `cookie`, which now conflicts with this variable and triggers the no-shadow rule.
Attachment #8995921 - Flags: review?(MattN+bmo) → review?(jaws)
Comment on attachment 8995921 [details] Bug 1478305 - Remove unnecessary imports and fix ESLint warnings about unused variables for browser/. https://reviewboard.mozilla.org/r/260218/#review267810
Attachment #8995921 - Flags: review?(jaws) → review+
The updates were for bitrot (and fixing my forget to change reviewer in commit message), and to add a version bump for eslint-plugin-mozilla so that we can update it for those that use it outside.
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/60a10f910397 For xpcshell-test head files, limit checking no-unused-vars to the local scope only. r=mossop https://hg.mozilla.org/integration/autoland/rev/ed8954c61a36 Remove unnecessary imports and fix ESLint warnings about unused variables for browser/. r=jaws https://hg.mozilla.org/integration/autoland/rev/a0a4329018c2 Remove unnecessary ChromeUtils.import calls in dom/media. r=bwc https://hg.mozilla.org/integration/autoland/rev/90115883e292 Remove unnecessary ChromeUtils.import calls in mobile/. r=snorp https://hg.mozilla.org/integration/autoland/rev/d3cca460f38d Remove unnecessary ChromeUtils.import calls in testing/. r=mossop https://hg.mozilla.org/integration/autoland/rev/d28accbc115d Remove unnecessary imports and fix ESLint warnings about unused variables for toolkit/. r=mossop https://hg.mozilla.org/integration/autoland/rev/0fd5b04d2dee Update ESLint to treat ChromeUtils.import definitions as real variable definitions for single-export modules. r=mossop
Commit pushed to master at https://github.com/mozilla/activity-stream https://github.com/mozilla/activity-stream/commit/1150780da479166f959008147bdb5995ac3de093 Port Bug 1478305 - Remove unnecessary imports and fix ESLint warnings about unused variables for browser/. r=jaws
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: