Closed Bug 1880899 Opened 5 months ago Closed 4 months ago

Add a lint rule that prevents adding more globals to browser.js

Categories

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

Desktop
All

Tracking

(firefox125 fixed)

RESOLVED FIXED
Tracking Status
firefox125 --- fixed

People

(Reporter: Gijs, Assigned: Gijs)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

bug 1880897 has some rationale.

There are some 200-odd globals listed in browser.js.

The lint rule should:

  • only apply to browser.js
  • iterate over all the variable, function and class declarations in the global scope
  • hold an allowlist of known identifier strings
  • complain if the list in browser.js does not match its list (ie items removed from browser.js will need removing from the lint rule, and the lint rule will complain if the file has new globals that are not in its allowlist.

This probably seems like overkill. Unfortunately my experience with https://searchfox.org/mozilla-central/source/browser/base/content/test/general/browser.toml is that people are quite happy to submit patches that add items to a list even if every other line in the file tells them not to (in all caps, to boot), dutifully copying the warning line. Hopefully the linter will help...

We might be able to base something on or around the browser-window environment for ESLint.

We can already load that & generate a list of globals which we do for export purposes.

Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED

The severity field is not set for this bug.
:andi, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(bpostelnicu)
Type: defect → task
Flags: needinfo?(bpostelnicu)
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/a65344e02551
add lint rule that prevents adding more browser.js globals, r=Standard8
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.