Bug 1880899 - add lint rule that prevents adding more browser.js globals, r?Standard8
ClosedPublic

Authored by Gijs on Feb 27 2024, 11:35 AM.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.

Code analysis found 3 defects in diff 827654:

  • 3 defects found by eslint (Mozlint)
IMPORTANT: Found 3 defects (error level) that must be fixed before landing.

You can run this analysis locally with:

  • ./mach lint --warnings --outgoing

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 827654.

Update browser globals file based on recently introduced globals.

3 defects closed compared to the previous diff 827654.


If you see a problem in this automated review, please report it here.

Standard8 added inline comments.
.eslintrc.js
256–260

I'm torn between adding this here and as a /* eslint mozilla/no-more-globals: "error" */ line at the top of browser.js. wdyt?

tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-more-globals.js
17

Please can you add the docs?

This revision now requires changes to proceed.Feb 28 2024, 6:01 PM
Gijs added inline comments.
.eslintrc.js
256–260

I think not centralising it in the config is helpful in terms of being able to easily adopt it for other files, though I'd need to doublecheck that doing the linting on encountering Program works in that case (like does that node's processing by eslint get invoked before or after the file level comment?).

However I'm a bit nervous someone would (accidentally or otherwise...) move or remove it and break it, which seems less likely with the eslint config.

Really kind of on the fence on this. Are my concerns about the fragility of the inline comment warranted at all, @Standard8 / @mossop ?

.eslintrc.js
256–260

Let's go with the config, it is probably safer, and if we feel it needs to change in the future, then we can do that.

Gijs requested review of this revision.Mar 14 2024, 6:20 PM
Gijs updated this revision to Diff 836331.

Rebase, add docs.

NOTE: A documentation file was modified in diff 836331

It can be previewed for one week:


If you see a problem in this automated review, please report it here.

Gijs marked 2 inline comments as done.Mar 14 2024, 7:00 PM
This revision is now accepted and ready to land.Mar 15 2024, 6:37 PM