Update getScriptGlobals to support nullish
Categories
(Developer Infrastructure :: Lint and Formatting, task)
Tracking
(firefox76 fixed)
Tracking | Status | |
---|---|---|
firefox76 | --- | fixed |
People
(Reporter: Mardak, Assigned: mossop)
References
(Regressed 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
Looks like using new features like nullish in special browser global files causes issues, e.g., adding ??
to browser/base/content/browser.js then linting anything:
Could not load globals from file mozilla-central/browser/base/content/browser.js: SyntaxError: Unexpected token ?
You may need to update the mappings in mozilla-central/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
Error: Failed to load plugin 'mozilla' declared in '.eslintrc.js': Could not load globals from file mozilla-central/browser/base/content/browser.js: SyntaxError: Unexpected token ?
Referenced from: mozilla-central/.eslintrc.js
at getScriptGlobals (mozilla-central/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js:120:13)
at getMozillaCentralItems (mozilla-central/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js:137:25)
at Object.<anonymous> (mozilla-central/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js:143:5)
at Module._compile (mozilla-central/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (mozilla-central/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
I'm guessing this is because eslint-scope is used:
https://searchfox.org/mozilla-central/rev/3f8c67d7fd836d559491e3fe497bc739f707c1a6/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js#14
Comment 1•4 years ago
|
||
Comment 2•4 years ago
|
||
I started something, but I got a bit stuck part way through. The basic idea is to use babel-eslint's parser.
The part I got stuck with was helpers.walkAST
- we're currently using estraverse
, but I couldn't work out the right traverse to use from Babel - I tried the core one, but that didn't like the new operators.
Absolute worst case, we might be able to ban the new syntaxes on any non-module file... so they can at least be used in some places. Though if anyone has ideas about how to fix the traverser, feel free to take this on.
Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Pushed by dtownsend@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1870512ace0f When parsing an AST allow the chosen parser to override the default scope manager and visitor keys. r=Standard8
Comment 5•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Updated•2 years ago
|
Description
•