Skip to content

Commit 2205050

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[eslint] Add extensions folder to linting
Includes linting of the extensions folder. Also add .mjs files to the PRESUBMIT which was previously missing. Bug: none Change-Id: I6ae5bb8a218461c3b2bf07d95310d79c57f2cdd9 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6177277 Reviewed-by: Philip Pfaffe <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 89e7a5f commit 2205050

30 files changed

+193
-168
lines changed

PRESUBMIT.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def _CheckDevToolsLint(input_api, output_api):
301301

302302
should_bail_out, files_to_lint = _getFilesToLint(
303303
input_api, output_api, lint_config_files, default_linted_directories,
304-
['.css', '.js', '.ts'], results)
304+
['.css', '.mjs', '.js', '.ts'], results)
305305
if should_bail_out:
306306
return results
307307

config/typescript/tsconfig.eslint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"../../front_end/**/*.ts",
1515
"../../inspector_overlay/**/*.ts",
1616
"../../scripts/protocol_typescript/*.ts",
17-
"../../test/**/*.ts"
17+
"../../test/**/*.ts",
18+
"../../extensions/**/*.ts",
1819
]
1920
}

extensions/cxx_debugging/e2e/TestDriver.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import {assert} from 'chai';
6-
import {type ElementHandle, type JSHandle} from 'puppeteer-core';
6+
import type {ElementHandle, JSHandle} from 'puppeteer-core';
77
import {TestConfig} from 'test/conductor/test_config.js';
88
import {
99
CONSOLE_TAB_SELECTOR,
@@ -26,7 +26,6 @@ import {
2626
assertNotNullOrUndefined,
2727
click,
2828
clickElement,
29-
debuggerStatement,
3029
getBrowserAndPages,
3130
getPendingEvents,
3231
installEventListener,
@@ -35,7 +34,6 @@ import {
3534
waitForFunction,
3635
} from 'test/shared/helper.js';
3736

38-
3937
import {
4038
type Action,
4139
loadTests,

extensions/cxx_debugging/e2e/cxx-debugging-extension-helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface Step {
4040
export interface TestSpec {
4141
name: string;
4242
test: string;
43+
// eslint-disable-next-line @typescript-eslint/naming-convention
4344
extension_parameters?: string;
4445
script?: Step[];
4546
file?: string;

extensions/cxx_debugging/e2e/standalone/MemoryInspector_test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
waitForMany,
1919
} from 'test/shared/helper.js';
2020

21-
2221
import {
2322
openTestSuiteResourceInSourcesPanel,
2423
} from '../cxx-debugging-extension-helpers.js';

extensions/cxx_debugging/src/CreditsItem.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
/* eslint-disable rulesdir/check-component-naming, rulesdir/no-underscored-properties, rulesdir/no-style-tags-in-lit-html, rulesdir/no-a-tags-in-lit-html, rulesdir/lit-html-host-this */
65
import {html, render} from 'lit-html';
76

8-
export type CreditsItemData = {
9-
title: string,
10-
homepage: string,
11-
license: string,
12-
};
7+
export interface CreditsItemData {
8+
title: string;
9+
homepage: string;
10+
license: string;
11+
}
1312

1413
function onClick(e: KeyboardEvent): void {
1514
const {target} = e;

extensions/cxx_debugging/src/CustomFormatters.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import {type Chrome} from '../../../extension-api/ExtensionAPI.js';
5+
import type {Chrome} from '../../../extension-api/ExtensionAPI.js';
66

7-
import {type WasmValue} from './WasmTypes.js';
8-
import {type HostInterface} from './WorkerRPC.js';
7+
import type {WasmValue} from './WasmTypes.js';
8+
import type {HostInterface} from './WorkerRPC.js';
99

1010
export interface FieldInfo {
1111
typeId: string;
@@ -363,7 +363,7 @@ export class CXXValue implements Value, LazyObject {
363363
const formattedValue = await formatter.format(this.wasm, value);
364364
return lazyObjectFromAny(formattedValue, this.objectStore, this.type, this.displayValue, this.memoryAddress)
365365
.asRemoteObject();
366-
} catch (e) {
366+
} catch {
367367
// Fallthrough
368368
}
369369
}

extensions/cxx_debugging/src/DWARFSymbols.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import './Formatters.js';
66

7-
import {type Chrome} from '../../../extension-api/ExtensionAPI.js';
7+
import type {Chrome} from '../../../extension-api/ExtensionAPI.js';
88

99
import * as Formatters from './CustomFormatters.js';
1010
import {
@@ -15,7 +15,7 @@ import {
1515
} from './ModuleConfiguration.js';
1616
import type * as SymbolsBackend from './SymbolsBackend.js';
1717
import createSymbolsBackend from './SymbolsBackend.js';
18-
import {type HostInterface} from './WorkerRPC.js';
18+
import type {HostInterface} from './WorkerRPC.js';
1919

2020
function mapVector<T, ApiT>(vector: SymbolsBackend.Vector<ApiT>, callback: (apiElement: ApiT) => T): T[] {
2121
const elements: T[] = [];
@@ -26,11 +26,11 @@ function mapVector<T, ApiT>(vector: SymbolsBackend.Vector<ApiT>, callback: (apiE
2626
return elements;
2727
}
2828

29-
type ScopeInfo = {
30-
type: 'GLOBAL'|'LOCAL'|'PARAMETER',
31-
typeName: string,
32-
icon?: string,
33-
};
29+
interface ScopeInfo {
30+
type: 'GLOBAL'|'LOCAL'|'PARAMETER';
31+
typeName: string;
32+
icon?: string;
33+
}
3434

3535
type LazyFSNode = FS.FSNode&{contents: {cacheLength: Function, length: number}};
3636

@@ -196,7 +196,7 @@ export class DWARFLanguageExtensionPlugin implements Chrome.DevTools.LanguageExt
196196
// Sometimes these stick around.
197197
try {
198198
backend.FS.unlink(absolutePath);
199-
} catch (_) {
199+
} catch {
200200
}
201201
// Ensure directory exists
202202
if (parentDirectory.length > 1) {
@@ -211,9 +211,9 @@ export class DWARFLanguageExtensionPlugin implements Chrome.DevTools.LanguageExt
211211
const wrapper = (): void => {
212212
try {
213213
cacheLength.apply(node.contents);
214-
this.hostInterface.reportResourceLoad(dwoURL, {success: true, size: node.contents.length});
214+
void this.hostInterface.reportResourceLoad(dwoURL, {success: true, size: node.contents.length});
215215
} catch (e) {
216-
this.hostInterface.reportResourceLoad(dwoURL, {success: false, errorMessage: (e as Error).message});
216+
void this.hostInterface.reportResourceLoad(dwoURL, {success: false, errorMessage: (e as Error).message});
217217
// Rethrow any error fetching the content as errno 44 (EEXIST)
218218
// TypeScript doesn't know about the ErrnoError constructor
219219
// @ts-ignore

extensions/cxx_debugging/src/DevToolsPluginHost.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import {DEFAULT_MODULE_CONFIGURATIONS, type ModuleConfigurations} from './ModuleConfiguration.js';
6-
import {type Chrome} from '../../../extension-api/ExtensionAPI.js';
5+
import type {Chrome} from '../../../extension-api/ExtensionAPI.js';
76

8-
import {WorkerRPC, type AsyncHostInterface, type WorkerInterface} from './WorkerRPC.js';
9-
import {type WasmValue} from './WasmTypes.js';
7+
import {DEFAULT_MODULE_CONFIGURATIONS, type ModuleConfigurations} from './ModuleConfiguration.js';
8+
import type {WasmValue} from './WasmTypes.js';
9+
import {type AsyncHostInterface, type WorkerInterface, WorkerRPC} from './WorkerRPC.js';
1010

1111
export class WorkerPlugin implements Chrome.DevTools.LanguageExtensionPlugin, AsyncHostInterface {
1212
private readonly worker: Worker;
@@ -127,8 +127,8 @@ if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') {
127127
}
128128

129129
const defaultConfig = {
130-
'moduleConfigurations': DEFAULT_MODULE_CONFIGURATIONS,
131-
'logPluginApiCalls': false,
130+
moduleConfigurations: DEFAULT_MODULE_CONFIGURATIONS,
131+
logPluginApiCalls: false,
132132
};
133133
chrome.storage.local.get(defaultConfig, ({moduleConfigurations, logPluginApiCalls}) => {
134134
let pluginPromise = registerPlugin(moduleConfigurations, logPluginApiCalls);

extensions/cxx_debugging/src/DevToolsPluginWorker.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import {type Chrome} from '../../../extension-api/ExtensionAPI.js';
5+
import type {Chrome} from '../../../extension-api/ExtensionAPI.js';
66

77
import {createPlugin, type ResourceLoader} from './DWARFSymbols.js';
8-
import {type ModuleConfigurations} from './ModuleConfiguration.js';
9-
8+
import type {ModuleConfigurations} from './ModuleConfiguration.js';
109
import {deserializeWasmMemory, deserializeWasmValue, kMaxWasmValueSize, type WasmValue} from './WasmTypes.js';
11-
12-
import {SynchronousIOMessage} from './WorkerRPC.js';
13-
import {WorkerRPC, type Channel, type HostInterface, type WorkerInterface} from './WorkerRPC.js';
10+
import {type Channel, type HostInterface, SynchronousIOMessage, type WorkerInterface, WorkerRPC} from './WorkerRPC.js';
1411

1512
class SynchronousLinearMemoryMessage extends SynchronousIOMessage<ArrayBuffer> {
1613
deserialize(length: number): ArrayBuffer {

extensions/cxx_debugging/src/DevToolsPluginWorkerMain.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
import {RPCInterface} from './DevToolsPluginWorker.js';
66
import {ResourceLoader} from './MEMFSResourceLoader.js';
77

8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
89
new RPCInterface(globalThis as any, new ResourceLoader());

extensions/cxx_debugging/src/ExtensionOptions.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
/* eslint-disable rulesdir/check-component-naming */
6-
/* eslint-disable rulesdir/inject-checkbox-styles */
7-
/* eslint-disable rulesdir/lit-html-host-this */
8-
95
import './CreditsItem.js';
106
import './ModuleConfigurationList.js';
117

128
import {html, render} from 'lit-html';
13-
import {until} from 'lit-html/directives/until.js'; // eslint-disable-line rulesdir/es-modules-import
9+
import {until} from 'lit-html/directives/until.js';
1410

15-
import {type CreditsItemData} from './CreditsItem.js';
16-
import {type Storage} from './DevToolsPluginHost.js';
11+
import type {CreditsItemData} from './CreditsItem.js';
12+
import type {Storage} from './DevToolsPluginHost.js';
1713
import {DEFAULT_MODULE_CONFIGURATIONS} from './ModuleConfiguration.js';
18-
import {type ModuleConfigurationsChangedEvent} from './ModuleConfigurationList.js';
14+
import type {ModuleConfigurationsChangedEvent} from './ModuleConfigurationList.js';
1915

2016
const CREDITS_ITEMS: CreditsItemData[] = [
2117
{
@@ -667,7 +663,7 @@ export class ExtensionOptions extends HTMLElement {
667663
private render(): void {
668664
const configurations = new Promise<{[key: string]: unknown}>(
669665
resolve => chrome.storage.local.get(
670-
{'moduleConfigurations': DEFAULT_MODULE_CONFIGURATIONS, 'logPluginApiCalls': false}, resolve));
666+
{moduleConfigurations: DEFAULT_MODULE_CONFIGURATIONS, logPluginApiCalls: false}, resolve));
671667
const moduleConfigurationListPromise = configurations.then(
672668
data => html`
673669
<devtools-cxx-debugging-module-configuration-list .data=${data} @module-configurations-changed=${
@@ -682,7 +678,7 @@ export class ExtensionOptions extends HTMLElement {
682678
<input data-input="true" type="checkbox" .checked=${data.logPluginApiCalls} @change=${
683679
(event: Event): void => {
684680
const checkbox = event.target as HTMLInputElement;
685-
this.updateConfigurations({'logPluginApiCalls': checkbox.checked});
681+
this.updateConfigurations({logPluginApiCalls: checkbox.checked});
686682
}}>
687683
<span>Log calls to plugin API</span>
688684
</label>`);

extensions/cxx_debugging/src/Formatters.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
type Value,
1111
type WasmInterface,
1212
} from './CustomFormatters.js';
13-
import {type ForeignObject, type WasmValue} from './WasmTypes.js';
13+
import type {ForeignObject} from './WasmTypes.js';
1414

1515
/*
1616
* Numbers
@@ -149,8 +149,10 @@ CustomFormatters.addFormatter({
149149

150150
type CharArrayConstructor = typeof Uint8Array|typeof Uint16Array|typeof Uint32Array;
151151
function formatRawString<T extends CharArrayConstructor>(
152-
wasm: WasmInterface, value: Value, charType: T, decode: (chars: InstanceType<T>) => string): string|
153-
{[key: string]: Value | null} {
152+
wasm: WasmInterface, value: Value, charType: T, decode: (chars: InstanceType<T>) => string): string|{
153+
[key: string]: Value|null,
154+
}
155+
{
154156
const address = value.asUint32();
155157
if (address < Constants.SAFE_HEAP_START) {
156158
return formatPointerOrReference(wasm, value);
@@ -180,15 +182,20 @@ function formatRawString<T extends CharArrayConstructor>(
180182
return formatPointerOrReference(wasm, value);
181183
}
182184

183-
export function formatCString(wasm: WasmInterface, value: Value): string|{[key: string]: Value | null} {
184-
return formatRawString(wasm, value, Uint8Array, str => new TextDecoder().decode(str));
185+
export function formatCString(wasm: WasmInterface, value: Value): string|{
186+
[key: string]: Value|null,
185187
}
188+
{ return formatRawString(wasm, value, Uint8Array, str => new TextDecoder().decode(str)); }
186189

187-
export function formatU16CString(wasm: WasmInterface, value: Value): string|{[key: string]: Value | null} {
188-
return formatRawString(wasm, value, Uint16Array, str => new TextDecoder('utf-16le').decode(str));
190+
export function formatU16CString(wasm: WasmInterface, value: Value): string|{
191+
[key: string]: Value|null,
189192
}
193+
{ return formatRawString(wasm, value, Uint16Array, str => new TextDecoder('utf-16le').decode(str)); }
190194

191-
export function formatCWString(wasm: WasmInterface, value: Value): string|{[key: string]: Value | null} {
195+
export function formatCWString(wasm: WasmInterface, value: Value): string|{
196+
[key: string]: Value|null,
197+
}
198+
{
192199
// emscripten's wchar is 4 byte
193200
return formatRawString(wasm, value, Uint32Array, str => Array.from(str).map(v => String.fromCodePoint(v)).join(''));
194201
}

extensions/cxx_debugging/src/MEMFSResourceLoader.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import type {Chrome} from '../../../extension-api/ExtensionAPI.js';
66

77
import type * as DWARFSymbols from './DWARFSymbols.js';
8-
import {type HostInterface} from './WorkerRPC.js';
8+
import type {HostInterface} from './WorkerRPC.js';
99

1010
export class ResourceLoader implements DWARFSymbols.ResourceLoader {
1111
protected async fetchSymbolsData(rawModule: DWARFSymbols.RawModule, url: URL, hostInterface: HostInterface):
@@ -39,11 +39,11 @@ export class ResourceLoader implements DWARFSymbols.ResourceLoader {
3939
symbolsResponse.arrayBuffer(),
4040
symbolsDwpResponse && symbolsDwpResponse.ok ? symbolsDwpResponse.arrayBuffer() : undefined,
4141
]);
42-
hostInterface.reportResourceLoad(url.href, {success: true, size: symbolsData.byteLength});
42+
void hostInterface.reportResourceLoad(url.href, {success: true, size: symbolsData.byteLength});
4343
if (symbolsDwpData) {
44-
hostInterface.reportResourceLoad(dwpUrl, {success: true, size: symbolsDwpData.byteLength});
44+
void hostInterface.reportResourceLoad(dwpUrl, {success: true, size: symbolsDwpData.byteLength});
4545
} else {
46-
hostInterface.reportResourceLoad(
46+
void hostInterface.reportResourceLoad(
4747
dwpUrl, {success: false, errorMessage: `Failed to fetch dwp file: ${symbolsDwpError}`});
4848
}
4949
return {symbolsData, symbolsDwpData};
@@ -52,11 +52,11 @@ export class ResourceLoader implements DWARFSymbols.ResourceLoader {
5252
if (rawModule.url !== url.href) {
5353
const errorMessage = `NotFoundError: Unable to load debug symbols from '${url}' for the WebAssembly module '${
5454
rawModule.url}' (${statusText}), double-check the parameter to -gseparate-dwarf in your Emscripten link step`;
55-
hostInterface.reportResourceLoad(url.href, {success: false, errorMessage});
55+
void hostInterface.reportResourceLoad(url.href, {success: false, errorMessage});
5656
throw new Error(errorMessage);
5757
}
5858
const errorMessage = `NotFoundError: Unable to load debug symbols from '${url}' (${statusText})`;
59-
hostInterface.reportResourceLoad(url.href, {success: false, errorMessage});
59+
void hostInterface.reportResourceLoad(url.href, {success: false, errorMessage});
6060
throw new Error(errorMessage);
6161
}
6262

@@ -74,7 +74,7 @@ export class ResourceLoader implements DWARFSymbols.ResourceLoader {
7474
// This file is sometimes preserved on reload, causing problems.
7575
try {
7676
fileSystem.unlink('/' + symbolsFileName);
77-
} catch (_) {
77+
} catch {
7878
}
7979

8080
fileSystem.createDataFile(

extensions/cxx_debugging/src/ModuleConfiguration.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {globMatch} from './GlobMatch.js';
1111
* and `settings set target.source-map old new` feature that
1212
* is found in LLDB.
1313
*/
14-
export type PathSubstitution = {
14+
export interface PathSubstitution {
1515
readonly from: string; readonly to: string;
16-
};
16+
}
1717

1818
/**
1919
* List of {@type PathSubstitution}s.
2020
*/
21-
export type PathSubstitutions = ReadonlyArray<PathSubstitution>;
21+
export type PathSubstitutions = readonly PathSubstitution[];
2222

2323
/**
2424
* Resolve a source path (as stored in DWARF debugging information) to an absolute URL.
@@ -77,16 +77,16 @@ export function resolveSourcePathToURL(pathSubstitutions: PathSubstitutions, sou
7777
* The name can be a wildcard pattern, and {@see globMatch} will be used to
7878
* match the name against the URL of the WebAssembly module file.
7979
*/
80-
export type ModuleConfiguration = {
80+
export interface ModuleConfiguration {
8181
readonly name?: string; readonly pathSubstitutions: PathSubstitutions;
82-
};
82+
}
8383

8484
/**
8585
* List of {@type ModuleConfiguration}s. These lists are intended to have
8686
* a default configuration, whose name field is `undefined`, which is chosen
8787
* when no matching named configuration is found.
8888
*/
89-
export type ModuleConfigurations = ReadonlyArray<ModuleConfiguration>;
89+
export type ModuleConfigurations = readonly ModuleConfiguration[];
9090

9191
/**
9292
* Locate the configuration for a given `something.wasm` module file name.

0 commit comments

Comments
 (0)