Closed Bug 1229857 Opened 8 years ago Closed 8 years ago

Create an eslint plugin for getting the globals from the browser window

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mossop, Unassigned)

References

Details

Many browser-chrome tests use globals from the browser window. Until we have all those listed somewhere we can't enable the no-undef rule for those tests. For now a hardcoded list will work (bug 1229142) but an idea I got from devtools was to use a plugin which parses the main JS in the browser window to build a list of globals dynamically.
This will also be useful for other files that are included in <script> tags in the browser window because they all share the same context so there's a lot of global variable reuse between them (e.g. Services.jsm is imported in browser.js but used by almost every other file).

Note: eslint has an "environment" setting that automatically defines common global properties like window, document, JSON, XMLHTTPRequest etc..
Well what I was thinking here is something that included a list of all the scripts in browser.xul and parsed them all for globals. I guess that is helpful for those scripts too with a bit of tweaking.

There is already a basic version of this in our plugin for tests: https://dxr.mozilla.org/mozilla-central/source/testing/eslint-plugin-mozilla/lib/rules/import-headjs-globals.js
Oh, I did this in bug 1229224.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.