Bug 1917530 - Fix ESLint no-shadow issues in devtools code. r=devtools-reviewers,profiler-reviewers,frontend-codestyle-reviewers,nchevobbe,julienw,mossop

Differential Revision: https://phabricator.services.mozilla.com/D221442
This commit is contained in:
Mark Banner 2024-09-12 21:08:43 +00:00
parent 5f340a7a98
commit 7f08ffc091
9 changed files with 25 additions and 7 deletions

View File

@ -45,6 +45,7 @@ const xpcshellTestPaths = [
// of the file.
const extraXpcshellTestPaths = [
"devtools/client/shared/remote-debugging/adb/xpcshell/",
"devtools/platform/tests/xpcshell/",
"dom/file/tests/",
"dom/ipc/tests/",

View File

@ -9,12 +9,18 @@ module.exports = {
globals: {
exports: true,
isWorker: true,
loader: true,
module: true,
require: true,
DebuggerNotificationObserver: true,
},
overrides: [
{
files: ["**/*.*"],
excludedFiles: ["**/*.sys.mjs", "**/*.worker.js"],
globals: {
loader: true,
module: true,
require: true,
},
},
{
files: ["client/framework/**"],
rules: {

View File

@ -6,7 +6,6 @@
// Parent config file for all devtools xpcshell files.
module.exports = {
extends: ["plugin:mozilla/xpcshell-test"],
rules: {
// Allow non-camelcase so that run_test doesn't produce a warning.
camelcase: "off",

View File

@ -5,7 +5,6 @@
"use strict";
module.exports = {
env: { browser: true },
globals: {
define: true,
},

View File

@ -34,6 +34,7 @@ const { getCompactSymbolTable, queryAPI } = wasm_bindgen;
// message properties.
function createPlainErrorObject(e) {
// Regular errors: just rewrap the object.
// eslint-disable-next-line no-shadow
const { name, message, fileName, lineNumber } = e;
return { name, message, fileName, lineNumber };
}
@ -65,6 +66,7 @@ class FileAndPathHelper {
);
}
// eslint-disable-next-line no-shadow
const { name, path, debugPath, arch } = lib;
const candidatePaths = [];
@ -152,6 +154,7 @@ class FileAndPathHelper {
);
}
// eslint-disable-next-line no-shadow
const { name, path, arch } = lib;
const candidatePaths = [];

View File

@ -419,6 +419,7 @@ export function getAllBrowsingContextsForContext(
}
if (typeof module == "object") {
// eslint-disable-next-line no-undef
module.exports = {
isBrowsingContextPartOfContext,
isWindowGlobalPartOfContext,

View File

@ -46,6 +46,7 @@ const listeners = new Set();
// Detecting worker is different if this file is loaded via Common JS loader (isWorker global)
// or as a JSM (constructor name)
// eslint-disable-next-line no-shadow
const isWorker =
globalThis.isWorker ||
globalThis.constructor.name == "WorkerDebuggerGlobalScope";
@ -70,6 +71,8 @@ const customLazy = {
// this module no longer has WorkerDebuggerGlobalScope as global,
// but has to use require() to pull Debugger.
if (isWorker) {
// require is defined for workers.
// eslint-disable-next-line no-undef
return require("Debugger");
}
const { addDebuggerToGlobal } = ChromeUtils.importESModule(

View File

@ -129,6 +129,7 @@ export function workerify(fn) {
"used in production."
);
// Fetch modules here as we don't want to include it normally.
// eslint-disable-next-line no-shadow
const { URL, Blob } = Services.wm.getMostRecentWindow("navigator:browser");
const stringifiedFn = createWorkerString(fn);
const blob = new Blob([stringifiedFn]);

View File

@ -515,7 +515,7 @@ DevToolsStartup.prototype = {
};
}
const console = cmdLine.handleFlag("jsconsole", false);
const jsConsole = cmdLine.handleFlag("jsconsole", false);
const devtools = cmdLine.handleFlag("devtools", false);
let devToolsServer;
@ -539,7 +539,12 @@ DevToolsStartup.prototype = {
debuggerFlag = cmdLine.handleFlag("jsdebugger", false);
}
return { console, debugger: debuggerFlag, devtools, devToolsServer };
return {
console: jsConsole,
debugger: debuggerFlag,
devtools,
devToolsServer,
};
},
/**