Bug 1773740 - Part 3: Cover js files including ChromeUtils r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D148938
This commit is contained in:
Kagami Sascha Rosylight
2022-06-27 20:31:33 +00:00
parent a75ecefdf5
commit e29a0027f8
4 changed files with 72 additions and 4 deletions

View File

@@ -5,6 +5,17 @@ Prefer ``.isInstance()`` in chrome scripts over the standard ``instanceof``
operator for DOM interfaces, since the latter will return false when the object
is created from a different context.
These files are covered:
- ``*.sys.mjs``
- ``*.jsm``
- ``*.jsm.js``
- ``*.js`` with a heuristic
Since there is no straightforward way to detect chrome scripts, currently the
linter assumes that any script including ``ChromeUtils`` is chrome privileged.
This of course may not be sufficient and is open for change.
Examples of incorrect code for this rule:
-----------------------------------------