Bug 1917530 - Fix some ESLint no-shadow issues in misc code. r=frontend-codestyle-reviewers,perftest-reviewers,translations-reviewers,omc-reviewers,migration-reviewers,webcompat-reviewers,urlbar-reviewers,dao,twisniewski,sparky,mconley,emcminn,mossop

Differential Revision: https://phabricator.services.mozilla.com/D221443
This commit is contained in:
Mark Banner 2024-09-12 21:08:44 +00:00
Родитель 7f08ffc091
Коммит 3a3d0b8465
17 изменённых файлов: 50 добавлений и 45 удалений

Просмотреть файл

@ -943,7 +943,6 @@ export class ContextMenuChild extends JSWindowActorChild {
? undefined
: context.target.title || context.target.alt,
};
const { SVGAnimatedLength } = context.target.ownerGlobal;
if (SVGAnimatedLength.isInstance(context.imageInfo.height)) {
context.imageInfo.height = context.imageInfo.height.animVal.value;
}

Просмотреть файл

@ -238,7 +238,7 @@ export class ASRouterAdminInner extends React.PureComponent {
}
onChangeTargetingParameters(event) {
const { name } = event.target;
const { name: eventName } = event.target;
const { value } = event.target;
let targetingParametersError = null;
@ -246,14 +246,14 @@ export class ASRouterAdminInner extends React.PureComponent {
JSON.parse(value);
event.target.classList.remove("errorState");
} catch (e) {
console.error(`Error parsing value of parameter ${name}`);
console.error(`Error parsing value of parameter ${eventName}`);
event.target.classList.add("errorState");
targetingParametersError = { id: name };
targetingParametersError = { id: eventName };
}
this.setState(({ stringTargetingParameters }) => {
const updatedParameters = { ...stringTargetingParameters };
updatedParameters[name] = value;
updatedParameters[eventName] = value;
return {
copiedToClipboard: false,
@ -692,6 +692,7 @@ export class ASRouterAdminInner extends React.PureComponent {
{this.state.messages
.map(message => message.template)
.filter(
// eslint-disable-next-line no-shadow
(value, index, self) => self.indexOf(value) === index
)
.map(template => (
@ -1224,11 +1225,11 @@ export class ASRouterAdminInner extends React.PureComponent {
}
onChangeAttributionParameters(event) {
const { name, value } = event.target;
const { eventName, value } = event.target;
this.setState(({ attributionParameters }) => {
const updatedParameters = { ...attributionParameters };
updatedParameters[name] = value;
updatedParameters[eventName] = value;
return { attributionParameters: updatedParameters };
});

Просмотреть файл

@ -736,7 +736,7 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
}
onChangeTargetingParameters(event) {
const {
name
name: eventName
} = event.target;
const {
value
@ -746,10 +746,10 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
JSON.parse(value);
event.target.classList.remove("errorState");
} catch (e) {
console.error(`Error parsing value of parameter ${name}`);
console.error(`Error parsing value of parameter ${eventName}`);
event.target.classList.add("errorState");
targetingParametersError = {
id: name
id: eventName
};
}
this.setState(({
@ -758,7 +758,7 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
const updatedParameters = {
...stringTargetingParameters
};
updatedParameters[name] = value;
updatedParameters[eventName] = value;
return {
copiedToClipboard: false,
evaluationStatus: {},
@ -1085,7 +1085,9 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
className: "row"
}, this.state.messages ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("h3", null, "Templates"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
className: "col"
}, this.state.messages.map(message => message.template).filter((value, index, self) => self.indexOf(value) === index).map(template => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("label", {
}, this.state.messages.map(message => message.template).filter(
// eslint-disable-next-line no-shadow
(value, index, self) => self.indexOf(value) === index).map(template => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("label", {
key: template
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("input", {
type: "checkbox",
@ -1390,7 +1392,7 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
}
onChangeAttributionParameters(event) {
const {
name,
eventName,
value
} = event.target;
this.setState(({
@ -1399,7 +1401,7 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
const updatedParameters = {
...attributionParameters
};
updatedParameters[name] = value;
updatedParameters[eventName] = value;
return {
attributionParameters: updatedParameters
};

Просмотреть файл

@ -420,18 +420,20 @@ export class ChromeProfileMigrator extends MigratorBase {
return;
}
let crypto;
let loginCrypto;
try {
if (AppConstants.platform == "win") {
let { ChromeWindowsLoginCrypto } = ChromeUtils.importESModule(
"resource:///modules/ChromeWindowsLoginCrypto.sys.mjs"
);
crypto = new ChromeWindowsLoginCrypto(_chromeUserDataPathSuffix);
loginCrypto = new ChromeWindowsLoginCrypto(
_chromeUserDataPathSuffix
);
} else if (AppConstants.platform == "macosx") {
let { ChromeMacOSLoginCrypto } = ChromeUtils.importESModule(
"resource:///modules/ChromeMacOSLoginCrypto.sys.mjs"
);
crypto = new ChromeMacOSLoginCrypto(
loginCrypto = new ChromeMacOSLoginCrypto(
_keychainServiceName,
_keychainAccountName,
_keychainMockPassphrase
@ -462,7 +464,7 @@ export class ChromeProfileMigrator extends MigratorBase {
}
let loginInfo = {
username: row.getResultByName("username_value"),
password: await crypto.decryptData(
password: await loginCrypto.decryptData(
row.getResultByName("password_value"),
null
),
@ -578,18 +580,20 @@ export class ChromeProfileMigrator extends MigratorBase {
type: MigrationUtils.resourceTypes.PAYMENT_METHODS,
async migrate(aCallback) {
let crypto;
let loginCrypto;
try {
if (AppConstants.platform == "win") {
let { ChromeWindowsLoginCrypto } = ChromeUtils.importESModule(
"resource:///modules/ChromeWindowsLoginCrypto.sys.mjs"
);
crypto = new ChromeWindowsLoginCrypto(_chromeUserDataPathSuffix);
loginCrypto = new ChromeWindowsLoginCrypto(
_chromeUserDataPathSuffix
);
} else if (AppConstants.platform == "macosx") {
let { ChromeMacOSLoginCrypto } = ChromeUtils.importESModule(
"resource:///modules/ChromeMacOSLoginCrypto.sys.mjs"
);
crypto = new ChromeMacOSLoginCrypto(
loginCrypto = new ChromeMacOSLoginCrypto(
_keychainServiceName,
_keychainAccountName,
_keychainMockPassphrase
@ -609,7 +613,7 @@ export class ChromeProfileMigrator extends MigratorBase {
for (let row of rows) {
cards.push({
"cc-name": row.getResultByName("name_on_card"),
"cc-number": await crypto.decryptData(
"cc-number": await loginCrypto.decryptData(
row.getResultByName("card_number_encrypted"),
null
),

Просмотреть файл

@ -10,6 +10,7 @@ import { PlacesUtils } from "resource://gre/modules/PlacesUtils.sys.mjs";
// Resources
// eslint-disable-next-line no-shadow
function History() {}
History.prototype = {

Просмотреть файл

@ -20,6 +20,7 @@ function Home(props) {
utmContent,
} = props;
// eslint-disable-next-line no-shadow
const [{ articles, status }, setArticlesState] = useState({
articles: [],
// Can be success, loading, or error.

Просмотреть файл

@ -3,7 +3,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/browser-window */
/**
* ResetPBMPanel contains the logic for the restart private browsing action.

Просмотреть файл

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/browser-window */
const DEFAULT_NEW_REPORT_ENDPOINT = "https://webcompat.com/issues/new";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

Просмотреть файл

@ -136,6 +136,7 @@ const UPDATE_CHECK_PERIOD_MS = 12 * 60 * 60 * 1000; // 12 hours
/**
* A node in the QueryScorer's phrase tree.
*/
// eslint-disable-next-line no-shadow
class Node {
constructor(word) {
this.word = word;

Просмотреть файл

@ -777,13 +777,13 @@ export let BrowserUsageTelemetry = {
return "keyboard";
}
const { URL } = node.ownerDocument;
if (URL == AppConstants.BROWSER_CHROME_URL) {
const { URL: url } = node.ownerDocument;
if (url == AppConstants.BROWSER_CHROME_URL) {
return this._getBrowserWidgetContainer(node);
}
if (
URL.startsWith("about:preferences") ||
URL.startsWith("about:settings")
url.startsWith("about:preferences") ||
url.startsWith("about:settings")
) {
// Find the element's category.
let container = node.closest("[data-category]");

Просмотреть файл

@ -602,6 +602,7 @@ export var TabCrashHandler = {
return;
}
// eslint-disable-next-line no-shadow
let { includeURL, comments, URL } = message.data;
let extraExtraKeyVals = {

Просмотреть файл

@ -490,6 +490,7 @@ export var TestRunner = {
},
async _cropImage(window, srcPath, bounds, rects, targetPath) {
// eslint-disable-next-line no-shadow
const { document, Image } = window;
const promise = new Promise((resolve, reject) => {
const img = new Image();

Просмотреть файл

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// eslint-disable-next-line no-shadow
import { AddonManager } from "resource://gre/modules/AddonManager.sys.mjs";
export var LightweightThemes = {

Просмотреть файл

@ -7,7 +7,7 @@
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
const URL =
const TEST_URL =
"https://test1.example.com/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/resources/lib/permissionPrompts.html";
let lastTab = null;
@ -146,7 +146,7 @@ async function clickOn(selector, beforeContentFn) {
// Save the tab so we can close it later.
lastTab = await BrowserTestUtils.openNewForegroundTab(
browserWindow.gBrowser,
URL
TEST_URL
);
let { SpecialPowers } = lastTab.ownerGlobal;

Просмотреть файл

@ -6,7 +6,7 @@ importScripts("mp4box.all.min.js");
importScripts("demuxer_mp4.js");
importScripts("shared.js");
self.onmessage = e => {
self.onmessage = event => {
const resolve = result => {
self.postMessage(result);
};
@ -16,15 +16,15 @@ self.onmessage = e => {
try {
runTestInternal(
e.data.testName,
e.data.canvasType,
e.data.offscreenCanvas,
event.data.testName,
event.data.canvasType,
event.data.offscreenCanvas,
/* isWorker */ true,
e.data.videoUri,
event.data.videoUri,
resolve,
reject
);
} catch (e) {
reject(e);
} catch (ex) {
reject(ex);
}
};

Просмотреть файл

@ -251,8 +251,7 @@ AbstractWorker.prototype = {
"id is",
id
);
let msg = exn.toMsg();
this.postMessage({ fail: msg, id, durationMs });
this.postMessage({ fail: exn.toMsg(), id, durationMs });
} else {
// If we encounter an exception for which we have no
// serialization mechanism in place, we have no choice but to

Просмотреть файл

@ -245,11 +245,8 @@ class Engine {
this.bergamot = bergamot;
/** @type {Bergamot["TranslationModel"][]} */
this.languageTranslationModels = languageTranslationModelFiles.map(
languageTranslationModelFiles =>
BergamotUtils.constructSingleTranslationModel(
bergamot,
languageTranslationModelFiles
)
modelFiles =>
BergamotUtils.constructSingleTranslationModel(bergamot, modelFiles)
);
/** @type {Bergamot["BlockingService"]} */