From b20fbf2ba1e1c75a93ed847270a26809b8a8a81d Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Sat, 24 May 2025 17:08:35 +0000 Subject: [PATCH] Bug 1881701 - Fix remainder of newly raised devtools issues after switching to the ESLint flat config. r=devtools-reviewers,frontend-codestyle-reviewers,mossop,nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D249957 --- .eslintrc-test-paths.js | 1 + devtools/.eslintrc.mjs | 11 ++++++++ .../client/debugger/src/utils/bootstrap.js | 1 + .../client/shared/build/build-debugger.js | 1 + devtools/client/shared/build/build.js | 4 ++- .../components/object-inspector/actions.js | 4 +-- .../components/ObjectInspector.js | 5 ++-- .../components/object-inspector/utils/node.js | 1 + devtools/server/actors/object/previewers.js | 27 ++++++++----------- .../server/actors/object/property-iterator.js | 5 ++-- devtools/server/actors/object/utils.js | 8 ------ .../shared/commands/object/object-command.js | 3 ++- .../commands/object/tests/browser_object.js | 6 ----- .../tests/objects/AllJavascriptTypes.mjs | 2 ++ .../tests/objects/JSObjectsTestUtils.sys.mjs | 4 +-- 15 files changed, 42 insertions(+), 41 deletions(-) diff --git a/.eslintrc-test-paths.js b/.eslintrc-test-paths.js index 733827d0ab9f..5297e79b669f 100644 --- a/.eslintrc-test-paths.js +++ b/.eslintrc-test-paths.js @@ -163,6 +163,7 @@ const extraBrowserTestPaths = [ "devtools/shared/commands/inspected-window/tests/", "devtools/shared/commands/inspector/tests/", "devtools/shared/commands/network/tests/", + "devtools/shared/commands/object/tests/", "devtools/shared/commands/resource/tests/", "devtools/shared/commands/script/tests/", "devtools/shared/commands/target-configuration/tests/", diff --git a/devtools/.eslintrc.mjs b/devtools/.eslintrc.mjs index d9434dc818d1..a1859b404d43 100644 --- a/devtools/.eslintrc.mjs +++ b/devtools/.eslintrc.mjs @@ -289,4 +289,15 @@ export default [ files: ["**/node/**"], languageOptions: { globals: globals.jest }, }, + { + // Bug 1967461 - Fix the files and re-enable these rules. + files: [ + "client/shared/components/object-inspector/components/ObjectInspector.js", + "client/shared/components/object-inspector/components/ObjectInspectorItem.js", + ], + rules: { + "react/prop-types": "off", + "react/sort-comp": "off", + }, + }, ]; diff --git a/devtools/client/debugger/src/utils/bootstrap.js b/devtools/client/debugger/src/utils/bootstrap.js index de37b642346b..2ee74a3aed46 100644 --- a/devtools/client/debugger/src/utils/bootstrap.js +++ b/devtools/client/debugger/src/utils/bootstrap.js @@ -58,6 +58,7 @@ export function bootstrapStore(client, workers, panel, initialState) { registerStoreObserver(store, updatePrefs); const actions = bindActionCreators( + // eslint-disable-next-line mozilla/reject-relative-requires require("../actions/index").default, store.dispatch ); diff --git a/devtools/client/shared/build/build-debugger.js b/devtools/client/shared/build/build-debugger.js index 6cb964bc0541..64b9aa7dd91d 100644 --- a/devtools/client/shared/build/build-debugger.js +++ b/devtools/client/shared/build/build-debugger.js @@ -4,6 +4,7 @@ "use strict"; +// eslint-disable-next-line mozilla/reject-relative-requires const Babel = require("./babel"); const _path = require("path"); diff --git a/devtools/client/shared/build/build.js b/devtools/client/shared/build/build.js index 7bb00d51458e..80b816163e9f 100644 --- a/devtools/client/shared/build/build.js +++ b/devtools/client/shared/build/build.js @@ -10,6 +10,7 @@ "use strict"; +// eslint-disable-next-line mozilla/reject-relative-requires const Babel = require("./babel"); const fs = require("fs"); const _path = require("path"); @@ -19,7 +20,8 @@ const defaultPlugins = ["proposal-class-properties"]; function transform(filePath) { // Use the extra plugins only for the debugger const plugins = filePath.includes("devtools/client/debugger") - ? require("./build-debugger")(filePath) + ? // eslint-disable-next-line mozilla/reject-relative-requires + require("./build-debugger")(filePath) : defaultPlugins; const doc = fs.readFileSync(filePath, "utf8"); diff --git a/devtools/client/shared/components/object-inspector/actions.js b/devtools/client/shared/components/object-inspector/actions.js index 678eaa8e2fdd..e2b4b7394e8f 100644 --- a/devtools/client/shared/components/object-inspector/actions.js +++ b/devtools/client/shared/components/object-inspector/actions.js @@ -11,7 +11,7 @@ const { nodeIsBucket, getFront, } = require("resource://devtools/client/shared/components/object-inspector/utils/node.js"); -const { getLoadedProperties, getWatchpoints } = require("resource://devtools/client/shared/components/object-inspector/reducer.js"); +const { getLoadedProperties } = require("resource://devtools/client/shared/components/object-inspector/reducer.js"); /** * This action is responsible for expanding a given node, which also means that @@ -194,7 +194,7 @@ async function releaseActors(client, oldRoots, newRoots = []) { } function invokeGetter(node, receiverId) { - return async ({ dispatch, client, getState }) => { + return async ({ dispatch, client, _getState }) => { try { const objectFront = getParentFront(node) || diff --git a/devtools/client/shared/components/object-inspector/components/ObjectInspector.js b/devtools/client/shared/components/object-inspector/components/ObjectInspector.js index 0fbcb36331fd..29a0a4d2ebbb 100644 --- a/devtools/client/shared/components/object-inspector/components/ObjectInspector.js +++ b/devtools/client/shared/components/object-inspector/components/ObjectInspector.js @@ -80,7 +80,7 @@ class ObjectInspector extends Component { static defaultProps = { autoReleaseObjectActors: true }; - constructor(props) { + constructor(_props) { super(); this.cachedNodes = new Map(); @@ -358,7 +358,7 @@ class ObjectInspector extends Component { } } -function mapStateToProps(state, props) { +function mapStateToProps(state, _props) { return { expandedPaths: getExpandedPaths(state), loadedProperties: getLoadedProperties(state), @@ -368,6 +368,7 @@ function mapStateToProps(state, props) { const OI = connect(mapStateToProps, actions)(ObjectInspector); +// eslint-disable-next-line react/display-name module.exports = props => { const { roots, standalone = false } = props; diff --git a/devtools/client/shared/components/object-inspector/utils/node.js b/devtools/client/shared/components/object-inspector/utils/node.js index 5b62cc512b29..c01786377799 100644 --- a/devtools/client/shared/components/object-inspector/utils/node.js +++ b/devtools/client/shared/components/object-inspector/utils/node.js @@ -544,6 +544,7 @@ function makeNodesForOwnProps(propertiesNames, parent, ownProperties) { }); } +// eslint-disable-next-line complexity function makeNodesForProperties(objProps, parent) { const { ownProperties = {}, diff --git a/devtools/server/actors/object/previewers.js b/devtools/server/actors/object/previewers.js index de346c87cf98..60c52059e272 100644 --- a/devtools/server/actors/object/previewers.js +++ b/devtools/server/actors/object/previewers.js @@ -4,7 +4,8 @@ "use strict"; -const { DevToolsServer } = require("resource://devtools/server/devtools-server.js"); +/* global Temporal, TrustedHTML, TrustedScript, TrustedScriptURL */ + const DevToolsUtils = require("resource://devtools/shared/DevToolsUtils.js"); loader.lazyRequireGetter( this, @@ -229,63 +230,56 @@ const previewers = { ], "Temporal.Instant": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.Instant, objectActor, grip); return true; }, ], "Temporal.PlainDate": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.PlainDate, objectActor, grip); return true; }, ], "Temporal.PlainDateTime": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.PlainDateTime, objectActor, grip); return true; }, ], - "Temporal.PlainDate": [ - function(objectActor, grip, depth) { - temporalPreviewer(Temporal.PlainDate, objectActor, grip); - return true; - }, - ], - "Temporal.PlainMonthDay": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.PlainMonthDay, objectActor, grip); return true; }, ], "Temporal.PlainTime": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.PlainTime, objectActor, grip); return true; }, ], "Temporal.PlainYearMonth": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.PlainYearMonth, objectActor, grip); return true; }, ], "Temporal.ZonedDateTime": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.ZonedDateTime, objectActor, grip); return true; }, ], "Temporal.Duration": [ - function(objectActor, grip, depth) { + function(objectActor, grip, _depth) { temporalPreviewer(Temporal.Duration, objectActor, grip); return true; }, @@ -858,6 +852,7 @@ function temporalPreviewer(cls, objectActor, grip) { * when we are inspecting nested attributes. * @returns */ +// eslint-disable-next-line complexity function GenericObject(objectActor, grip, depth) { const { obj, safeRawObj } = objectActor; if (grip.preview || grip.displayString || depth > 1) { diff --git a/devtools/server/actors/object/property-iterator.js b/devtools/server/actors/object/property-iterator.js index 9557bb1696fa..b570c73bdc8b 100644 --- a/devtools/server/actors/object/property-iterator.js +++ b/devtools/server/actors/object/property-iterator.js @@ -54,8 +54,8 @@ class PropertyIteratorActor extends Actor { if (!DevToolsUtils.isSafeDebuggerObject(objectActor.obj)) { this.iterator = { size: 0, - propertyName: index => undefined, - propertyDescription: index => undefined, + propertyName: _index => undefined, + propertyDescription: _index => undefined, }; } else if (options.enumEntries) { const cls = objectActor.className; @@ -663,6 +663,7 @@ function enumCustomStateSetEntries(objectActor, depth) { // We also need to waive Xrays on the result of the call to `values` as we don't have // Xrays to Iterator objects (see Bug 1023984) const values = Array.from( + // eslint-disable-next-line no-undef waiveXrays(CustomStateSet.prototype.values.call(waiveXrays(rawObj))) ); diff --git a/devtools/server/actors/object/utils.js b/devtools/server/actors/object/utils.js index 63074c8337b7..aa7cebdbebd5 100644 --- a/devtools/server/actors/object/utils.js +++ b/devtools/server/actors/object/utils.js @@ -24,14 +24,6 @@ loader.lazyRequireGetter( true ); - -loader.lazyRequireGetter( - this, - "EnvironmentActor", - "resource://devtools/server/actors/environment.js", - true -); - /** * Get thisDebugger.Object referent's `promiseState`. * diff --git a/devtools/shared/commands/object/object-command.js b/devtools/shared/commands/object/object-command.js index 5812f3114834..c3991b9d020e 100644 --- a/devtools/shared/commands/object/object-command.js +++ b/devtools/shared/commands/object/object-command.js @@ -9,9 +9,10 @@ * of all inspected JavaScript objects. */ class ObjectCommand { - constructor({ commands, descriptorFront, watcherFront }) { + constructor({ commands, _descriptorFront, _watcherFront }) { this.#commands = commands; } + // eslint-disable-next-line no-unused-private-class-members #commands = null; /** diff --git a/devtools/shared/commands/object/tests/browser_object.js b/devtools/shared/commands/object/tests/browser_object.js index 9f6d5132d3ec..7c95e8485c29 100644 --- a/devtools/shared/commands/object/tests/browser_object.js +++ b/devtools/shared/commands/object/tests/browser_object.js @@ -11,8 +11,6 @@ add_task(async function testObjectRelease() { const commands = await CommandsFactory.forTab(tab); await commands.targetCommand.startListening(); - const { objectCommand } = commands; - const evaluationResponse = await commands.scriptCommand.execute( "window.foo" ); @@ -72,8 +70,6 @@ add_task(async function testMultiTargetObjectRelease() { const [,iframeTarget] = commands.targetCommand.getAllTargets(commands.targetCommand.ALL_TYPES); is(iframeTarget.url, "data:text/html,bar"); - const { objectCommand } = commands; - const evaluationResponse1 = await commands.scriptCommand.execute( "window" ); @@ -107,8 +103,6 @@ add_task(async function testWorkerObjectRelease() { const [,workerTarget] = commands.targetCommand.getAllTargets(commands.targetCommand.ALL_TYPES); is(workerTarget.url, workerUrl); - const { objectCommand } = commands; - const evaluationResponse = await commands.scriptCommand.execute( "foo", { selectedTargetFront: workerTarget, diff --git a/devtools/shared/tests/objects/AllJavascriptTypes.mjs b/devtools/shared/tests/objects/AllJavascriptTypes.mjs index 88935c6d03c3..099f490492cf 100644 --- a/devtools/shared/tests/objects/AllJavascriptTypes.mjs +++ b/devtools/shared/tests/objects/AllJavascriptTypes.mjs @@ -3,6 +3,7 @@ /* eslint-disable object-shorthand */ +// eslint-disable-next-line mozilla/reject-import-system-module-from-non-system import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; // Try replicating real world environment, by using @@ -495,6 +496,7 @@ const Errors = [ prefs: [ ["javascript.options.experimental.explicit_resource_management", true], ], + // eslint-disable-next-line no-constant-binary-expression disabled: true || !AppConstants.ENABLE_EXPLICIT_RESOURCE_MANAGEMENT, }, ]; diff --git a/devtools/shared/tests/objects/JSObjectsTestUtils.sys.mjs b/devtools/shared/tests/objects/JSObjectsTestUtils.sys.mjs index 19d6df44a4a3..00a59bed5059 100644 --- a/devtools/shared/tests/objects/JSObjectsTestUtils.sys.mjs +++ b/devtools/shared/tests/objects/JSObjectsTestUtils.sys.mjs @@ -112,7 +112,6 @@ function loadExpectedValues(expectedValuesFileName) { gExpectedValuesFilePath = Services.io.newURI(resHandler.resolveURI(resURL)).QueryInterface(Ci.nsIFileURL).file.path; } - let expectedValues; if (!isUpdate) { dump(`Loading test data file: ${url}\n`); return ChromeUtils.importESModule(url).default; @@ -225,7 +224,6 @@ async function runTest(expectedValuesFileName, testFunction) { "`More info in https://firefox-source-docs.mozilla.org/devtools/tests/js-object-tests.html\n"; const isMochitest = "gTestPath" in gTestScope; - const isXpcshell = !isMochitest; // If we aren't in "update" mode, we are reading assertion values from $EXPECTED_VALUES_FILE // and will assert the current returned values against these values @@ -236,7 +234,7 @@ async function runTest(expectedValuesFileName, testFunction) { } catch(e) { // deepEqual only throws in case of differences when running in XPCShell tests. Mochitest won't throw and keep running. // XPCShell will stop at the first failing assertion, so ensure showing our failure message and ok() will throw and stop the test. - if (isXpcshell) { + if (!isMochitest) { gTestScope.Assert.ok(false, failureMessage); } throw e;