Closed Bug 1771173 Opened 2 years ago Closed 2 years ago

Add a rule/detection for invalid accesses of modules when using ChromeUtils.defineLazyESModuleGetters

Categories

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

Tracking

(firefox103 fixed)

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

With moving to ESM modules, we are planning on defining a new system for lazy getters:

let lazy = {};
ChromeUtils.defineLazyESModuleGetters(lazy, {
  MyService: "MyService.sys.mjs",
});

// Access
lazy.MyService.add(1);

Whilst ESLint will automatically detect the lazy variable, I think we should be able to extend it to know what is available within lazy and report invalid accesses.

Blocks: 1773747
Depends on: 1775013
Attachment #9281975 - Attachment description: WIP: Bug 1771173 - Make XPIDatabase lazy getters easier to work with ESLint. → WIP: Bug 1771173 - Make XPIDatabase/XPIInstall lazy getters easier to work with linters.
Attachment #9281973 - Attachment description: WIP: Bug 1771173 - Fix/ignore some duplicate imports caught by the new valid-lazy rule. → Bug 1771173 - Fix/ignore some duplicate imports caught by the new valid-lazy rule. r?arai
Attachment #9281974 - Attachment description: WIP: Bug 1771173 - Rework FormAutoFill's log creation to make it easier for linters to handle. → Bug 1771173 - Rework FormAutoFill's log creation to make it easier for linters to handle. r?sgalich
Attachment #9281975 - Attachment description: WIP: Bug 1771173 - Make XPIDatabase/XPIInstall lazy getters easier to work with linters. → Bug 1771173 - Make XPIDatabase/XPIInstall lazy getters easier to work with linters. r?#extension-reviewers
Attachment #9282080 - Attachment description: WIP: Bug 1771173 - Clean up unused definitions of console in extension modules. → Bug 1771173 - Clean up unused definitions of console in extension modules. r?#extension-reviewers
Attachment #9282081 - Attachment description: WIP: Bug 1771173 - Remove unused imports. → Bug 1771173 - Remove unused imports. r?arai!,#geckoview-reviewers
Attachment #9281976 - Attachment description: WIP: Bug 1771173 - Add ESLint rule to check for correct usages of lazy. → Bug 1771173 - Add ESLint rule to check for correct usages of lazy. r?arai
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/542f213b208f
Fix/ignore some duplicate imports caught by the new valid-lazy rule. r=arai
https://hg.mozilla.org/integration/autoland/rev/e270b8b7f8bd
Rework FormAutoFill's log creation to make it easier for linters to handle. r=sgalich
https://hg.mozilla.org/integration/autoland/rev/b1415a0f03a0
Make XPIDatabase/XPIInstall lazy getters easier to work with linters. r=mixedpuppy
https://hg.mozilla.org/integration/autoland/rev/fe89c8b44d12
Clean up unused definitions of console in extension modules. r=mixedpuppy
https://hg.mozilla.org/integration/autoland/rev/ad6ec35d0534
Remove unused imports. r=geckoview-reviewers,arai,owlish
https://hg.mozilla.org/integration/autoland/rev/eb2616c17dd6
Add ESLint rule to check for correct usages of lazy. r=arai
Regressions: 1775472
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: