If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Validator: Incorrect "Global overwrite"

RESOLVED FIXED

Status

addons.mozilla.org Graveyard
Admin/Editor Tools
RESOLVED FIXED
7 years ago
2 years ago

People

(Reporter: nmaier, Assigned: basta)

Tracking

Details

(Reporter)

Description

7 years ago
The "Global overwrite" warning is sometimes incorrect, as it does not take the scope into account.

Correct:
- Actually overriding window/document in a window scope

Incorrect:
- Warning about a function-local variable:
function initWindow(window) {
  let document = window.document;
}
Primary use cases would include js-modules (instead of overlay scripts) as well as bootstrap.js (restartless) add-ons.
(Reporter)

Updated

7 years ago
Assignee: nobody → mbasta
(Assignee)

Comment 1

7 years ago
That functionality is intended. The idea was to prevent the developer from masking global variables and functions in a particular scope. If I'm not mistaken, it was designed to prevent things like this:

var Components = {interfaces: {"nsISomethingorother": /* ... */}};

The JS engine has come a long way, though, and it catches a hell of a lot more problems than it was originally planned to. I'll have to look into the original spec and do some research on what this was specifically intended to protect against, but I'm fairly certain that it can be removed safely.
(Assignee)

Comment 2

7 years ago
Fixed:

https://github.com/mattbasta/amo-validator/commit/5a4077f9a69ef89af53e15b7862ab764004cc09a

This will be included in the next pull to mozilla/origin.
(Assignee)

Comment 3

7 years ago
Done:

https://github.com/mozilla/amo-validator/pull/6
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.