Skip to content

Commit

Permalink
Bug 1745030 - Improve structure and documentation around globals defi…
Browse files Browse the repository at this point in the history
…ned in eslint-plugin-mozilla and add structuredClone. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D133357
  • Loading branch information
Standard8 committed Dec 9, 2021
1 parent 463b693 commit f57ee82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ module.exports = {
extends: ["eslint:recommended", "plugin:prettier/recommended"],

globals: {
// These are all specific to Firefox unless otherwise stated.
Cc: false,
// Specific to Firefox (Chrome code only).
ChromeUtils: false,
Ci: false,
Components: false,
Cr: false,
Cu: false,
Debugger: false,
InstallTrigger: false,
// Specific to Firefox
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
InternalError: true,
Intl: false,
SharedArrayBuffer: false,
StopIteration: false,
// https://developer.mozilla.org/docs/Web/API/Window/dump
dump: true,
// Override the "browser" env definition of "location" to allow writing as it
// is a writeable property.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1509270#c1 for more information.
location: true,
openDialog: false,
saveStack: false,
// https://developer.mozilla.org/docs/Web/API/Window/sizeToContent
sizeToContent: false,
// Specific to Firefox
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
// structuredClone is a new global that only Firefox has currently and so isn't
// in ESLint's globals yet.
// https://developer.mozilla.org/docs/Web/API/structuredClone
structuredClone: false,
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/uneval
uneval: false,
},

Expand All @@ -58,6 +58,11 @@ module.exports = {
"mozilla/jsm": true,
},
files: ["**/*.jsm", "**/*.jsm.js"],
globals: {
// Intl is defined in the browser environment, but that's disabled
// for jsms, add it here manually.
Intl: false,
},
rules: {
"mozilla/mark-exported-symbols-as-used": "error",
// TODO: Bug 1575506 turn `builtinGlobals` on here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const extraGlobals = [
"byteSize",
"gc",
"gczeal",
"saveStack",
];

module.exports = getScriptGlobals(
Expand Down

0 comments on commit f57ee82

Please sign in to comment.