Skip to content

Commit d1ebd9e

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[EsLint] Don't use empty blocks
Bug: 397260638 Change-Id: Ibf4389ce952333a7af1877450ded87a480d2041f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6298125 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 43ae423 commit d1ebd9e

File tree

37 files changed

+370
-311
lines changed

37 files changed

+370
-311
lines changed

eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ export default [
174174
},
175175
],
176176

177+
'no-empty': [
178+
'error',
179+
{
180+
allowEmptyCatch: true,
181+
},
182+
],
183+
'no-lonely-if': 'error',
184+
177185
'no-empty-character-class': 'error',
178186
'no-global-assign': 'error',
179187
'no-implied-eval': 'error',

extensions/cxx_debugging/e2e/TestDriver.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,10 @@ describe('CXX Debugging Extension Test Suite', function() {
119119
} else if (value) {
120120
assert.isTrue(scopeVariable?.endsWith(`: ${value}`));
121121
}
122-
} else {
123-
if (variableType) {
124-
assert.strictEqual(scopeVariable, `${variableName}: ${variableType}`);
125-
} else if (value) {
126-
assert.strictEqual(scopeVariable, `${variableName}: ${value}`);
127-
}
122+
} else if (variableType) {
123+
assert.strictEqual(scopeVariable, `${variableName}: ${variableType}`);
124+
} else if (value) {
125+
assert.strictEqual(scopeVariable, `${variableName}: ${value}`);
128126
}
129127
}
130128
}

extensions/cxx_debugging/src/WorkerRPC.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class WorkerRPC<LocalInterface extends Record<string, any>, RemoteInterfa
112112
},
113113
});
114114
while (Atomics.wait(this.semaphore, 0, 0) !== 'not-equal') {
115+
// Await the semaphore to be equal
115116
}
116117
const [response] = this.semaphore;
117118

front_end/core/platform/TypedArrayUtilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ class BitVectorImpl extends Uint8Array {
166166
}
167167
}
168168
// Next, iterate by bytes to skip over ranges of zeros.
169-
let byteIndex: number;
170-
for (byteIndex = (index >> 3) - 1; byteIndex >= 0 && this[byteIndex] === 0; --byteIndex) {
169+
let byteIndex: number = (index >> 3) - 1;
170+
while (byteIndex >= 0 && this[byteIndex] === 0) {
171+
--byteIndex;
171172
}
172173
if (byteIndex < 0) {
173174
return -1;

front_end/core/sdk/NetworkManager.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,12 +1776,10 @@ export class InterceptedRequest {
17761776
} else {
17771777
result.set(match[1], [header.value]);
17781778
}
1779+
} else if (result.has(header.value)) {
1780+
result.get(header.value)?.push(header.value);
17791781
} else {
1780-
if (result.has(header.value)) {
1781-
result.get(header.value)?.push(header.value);
1782-
} else {
1783-
result.set(header.value, [header.value]);
1784-
}
1782+
result.set(header.value, [header.value]);
17851783
}
17861784
}
17871785
return result;

front_end/core/sdk/SourceMapManager.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,11 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
145145
cancelAttachSourceMap(client: T): void {
146146
if (client === this.#attachingClient) {
147147
this.#attachingClient = null;
148-
} else {
149148
// This should not happen.
150-
if (this.#attachingClient) {
151-
console.error('cancel attach source map requested but a different source map was being attached');
152-
} else {
153-
console.error('cancel attach source map requested but no source map was being attached');
154-
}
149+
} else if (this.#attachingClient) {
150+
console.error('cancel attach source map requested but a different source map was being attached');
151+
} else {
152+
console.error('cancel attach source map requested but no source map was being attached');
155153
}
156154
}
157155

front_end/devtools_compatibility.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,13 @@ const DevToolsAPIImpl = class {
100100
// Support for legacy front-ends (<M41).
101101
if (window['WebInspector'] && window['WebInspector']['addExtensions']) {
102102
window['WebInspector']['addExtensions'](extensions);
103-
} else {
104103
// The addExtensions command is sent as the onload event happens for
105104
// DevTools front-end. We should buffer this command until the frontend
106105
// is ready for it.
107-
if (this._addExtensionCallback) {
108-
extensions.forEach(this._addExtensionCallback);
109-
} else {
110-
this._pendingExtensionDescriptors.push(...extensions);
111-
}
106+
} else if (this._addExtensionCallback) {
107+
extensions.forEach(this._addExtensionCallback);
108+
} else {
109+
this._pendingExtensionDescriptors.push(...extensions);
112110
}
113111
}
114112

front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,12 +1124,10 @@ export abstract class HeapSnapshot {
11241124
if (stringIndexes.has(nodes.getValue(nodeIndex + nodeNameOffset))) {
11251125
nodeIds.push(nodes.getValue(nodeIndex + nodeIdOffset));
11261126
}
1127-
} else {
11281127
// If the node is displaying a customized name, then we must perform the
11291128
// full string search within that name here.
1130-
if (useRegExp ? regexp.test(name) : (name.indexOf(query) !== -1)) {
1131-
nodeIds.push(nodes.getValue(nodeIndex + nodeIdOffset));
1132-
}
1129+
} else if (useRegExp ? regexp.test(name) : (name.indexOf(query) !== -1)) {
1130+
nodeIds.push(nodes.getValue(nodeIndex + nodeIdOffset));
11331131
}
11341132
}
11351133
return nodeIds;

front_end/legacy_test_runner/data_grid_test_runner/data_grid_test_runner.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {TestRunner} from '../test_runner/test_runner.js';
99
*/
1010
export const DataGridTestRunner = {};
1111

12-
DataGridTestRunner.dumpDataGrid = function(root, descentIntoCollapsed, prefix) {
12+
DataGridTestRunner.dumpDataGrid = function(
13+
root,
14+
descentIntoCollapsed,
15+
prefix,
16+
) {
1317
if (!prefix) {
1418
prefix = '';
1519
}
@@ -43,16 +47,16 @@ DataGridTestRunner.validateDataGrid = function(root) {
4347
throw 'Wrong parent for child ' + child.data.id + ' of ' + root.data.id;
4448
}
4549

46-
if (child.nextSibling !== ((i + 1 === children.length ? null : children[i + 1]))) {
47-
throw 'Wrong child.nextSibling for ' + child.data.id + ' (' + i + ' of ' + children.length + ') ';
50+
if (child.nextSibling !== (i + 1 === children.length ? null : children[i + 1])) {
51+
throw ('Wrong child.nextSibling for ' + child.data.id + ' (' + i + ' of ' + children.length + ') ');
4852
}
4953

50-
if (child.previousSibling !== ((i ? children[i - 1] : null))) {
51-
throw 'Wrong child.previousSibling for ' + child.data.id + ' (' + i + ' of ' + children.length + ') ';
54+
if (child.previousSibling !== (i ? children[i - 1] : null)) {
55+
throw ('Wrong child.previousSibling for ' + child.data.id + ' (' + i + ' of ' + children.length + ') ');
5256
}
5357

5458
if (child.parent && !child.parent.isRoot && child.depth !== root.depth + 1) {
55-
throw 'Wrong depth for ' + child.data.id + ' expected ' + (root.depth + 1) + ' but got ' + child.depth;
59+
throw ('Wrong depth for ' + child.data.id + ' expected ' + (root.depth + 1) + ' but got ' + child.depth);
5660
}
5761

5862
DataGridTestRunner.validateDataGrid(child);
@@ -65,11 +69,12 @@ DataGridTestRunner.validateDataGrid = function(root) {
6569
throw 'Selected node is not selectable';
6670
}
6771
let node = selectedNode;
68-
for (; node && node !== root; node = node.parent) {
72+
while (node && node !== root) {
73+
node = node.parent;
6974
}
7075

7176
if (!node) {
72-
throw 'Selected node (' + selectedNode.data.id + ') is not within the DataGrid';
77+
throw ('Selected node (' + selectedNode.data.id + ') is not within the DataGrid');
7378
}
7479
}
7580
};

front_end/models/persistence/Automapping.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ export class Automapping {
246246
PersistenceImpl.rewrapNodeJSContent(status.fileSystem, fileContent, networkContent.content);
247247
isValid = fileContent === rewrappedNetworkContent;
248248
}
249-
} else {
250-
if (networkContent.content) {
251-
// Trim trailing whitespaces because V8 adds trailing newline.
252-
isValid = fileContent.trimEnd() === networkContent.content.trimEnd();
253-
}
249+
} else if (networkContent.content) {
250+
// Trim trailing whitespaces because V8 adds trailing newline.
251+
isValid = fileContent.trimEnd() === networkContent.content.trimEnd();
254252
}
255253
if (!isValid) {
256254
this.prevalidationFailedForTest(status);

0 commit comments

Comments
 (0)