Skip to content

Commit c10b497

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
ESLint: lint *.d.ts files
Bug: none Change-Id: Ie91dbdc6ed1533c2c58cdb2eafa6d5f23632d243 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6311457 Reviewed-by: Nikolay Vitkov <[email protected]> Commit-Queue: Jack Franklin <[email protected]> Auto-Submit: Jack Franklin <[email protected]> Reviewed-by: Mathias Bynens <[email protected]>
1 parent 4bac856 commit c10b497

File tree

10 files changed

+56
-34
lines changed

10 files changed

+56
-34
lines changed

config/typescript/tsconfig.eslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"include": [
1414
"../../front_end/**/*.ts",
1515
"../../inspector_overlay/**/*.ts",
16-
"../../scripts/protocol_typescript/*.ts",
16+
"../../scripts/**/*.ts",
1717
"../../test/**/*.ts",
1818
"../../extensions/**/*.ts",
1919
]

eslint.config.mjs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import jsdocPlugin from 'eslint-plugin-jsdoc';
1313
import mochaPlugin from 'eslint-plugin-mocha';
1414
import rulesdirPlugin from 'eslint-plugin-rulesdir';
1515
import globals from 'globals';
16-
import { join } from 'path';
16+
import {join} from 'path';
1717

1818
rulesdirPlugin.RULES_DIR = join(
19-
import.meta.dirname,
20-
'scripts',
21-
'eslint_rules',
22-
'lib',
19+
import.meta.dirname,
20+
'scripts',
21+
'eslint_rules',
22+
'lib',
2323
);
2424

2525
/**
@@ -74,7 +74,6 @@ export default [
7474
'test/**/fixtures/',
7575
'test/e2e/**/*.js',
7676
'test/shared/**/*.js',
77-
'**/*.d.ts',
7877
],
7978
},
8079
{
@@ -317,11 +316,11 @@ export default [
317316
parserOptions: {
318317
allowAutomaticSingleRunInference: true,
319318
project: join(
320-
import.meta.dirname,
321-
'config',
322-
'typescript',
323-
'tsconfig.eslint.json',
324-
),
319+
import.meta.dirname,
320+
'config',
321+
'typescript',
322+
'tsconfig.eslint.json',
323+
),
325324
},
326325
},
327326

@@ -549,12 +548,12 @@ export default [
549548
{
550549
// Enforce that any import of models/trace/trace.js names the import Trace.
551550
modulePath: join(
552-
import.meta.dirname,
553-
'front_end',
554-
'models',
555-
'trace',
556-
'trace.js',
557-
),
551+
import.meta.dirname,
552+
'front_end',
553+
'models',
554+
'trace',
555+
'trace.js',
556+
),
558557
importName: 'Trace',
559558
},
560559
],
@@ -820,4 +819,13 @@ export default [
820819
'rulesdir/canvas-context-tracking': 'error',
821820
},
822821
},
822+
{
823+
name: 'TypeScript type-definitions',
824+
files: ['**/*.d.ts'],
825+
rules: {
826+
// Not a useful rule for .d.ts files where we are
827+
// representing an existing module.
828+
'import/no-default-export': 'off'
829+
}
830+
}
823831
];

extensions/cxx_debugging/src/SymbolsBackend.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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 @typescript-eslint/naming-convention */
6+
57
export interface EmbindObject {
68
new(): this;
79
delete(): void;
@@ -152,12 +154,12 @@ export interface Module extends EmscriptenModule {
152154
FieldInfoArray: Vector<FieldInfo>;
153155
EnumeratorArray: Vector<Enumerator>;
154156
ErrorCode:
155-
{INTERNAL_ERROR: ErrorCode; PROTOCOL_ERROR: ErrorCode; MODULE_NOT_FOUND_ERROR: ErrorCode; EVAL_ERROR: ErrorCode;};
157+
{INTERNAL_ERROR: ErrorCode, PROTOCOL_ERROR: ErrorCode, MODULE_NOT_FOUND_ERROR: ErrorCode, EVAL_ERROR: ErrorCode};
156158
Error: Error;
157159
RawLocationRange: RawLocationRange;
158160
RawLocation: RawLocation;
159161
SourceLocation: SourceLocation;
160-
VariableScope: {LOCAL: VariableScope; PARAMETER: VariableScope; GLOBAL: VariableScope;};
162+
VariableScope: {LOCAL: VariableScope, PARAMETER: VariableScope, GLOBAL: VariableScope};
161163
Variable: Variable;
162164
FieldInfo: FieldInfo;
163165
Enumerator: Enumerator;
@@ -173,5 +175,5 @@ export interface Module extends EmscriptenModule {
173175
EvaluateExpressionResponse: EvaluateExpressionResponse;
174176
}
175177

176-
declare var createSymbolsBackend: EmscriptenModuleFactory<Module>;
178+
declare let createSymbolsBackend: EmscriptenModuleFactory<Module>;
177179
export default createSymbolsBackend;

extensions/cxx_debugging/tests/LLDBEvalTests.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
import {type Vector} from '../src/SymbolsBackend.js';
4+
import type {Vector} from '../src/SymbolsBackend.js';
55

66
export interface Debugger {
77
runToLine(line: string): Promise<void>;
@@ -15,9 +15,10 @@ export interface EvalResult {
1515
}
1616

1717
interface Module extends EmscriptenModule {
18+
// eslint-disable-next-line @typescript-eslint/naming-convention
1819
StringArray: Vector<string>;
1920
runTests(dbg: Debugger, args: Vector<string>): Promise<number>;
2021
}
2122

22-
declare var loadModule: EmscriptenModuleFactory<Module>;
23+
declare let loadModule: EmscriptenModuleFactory<Module>;
2324
export default loadModule;

extensions/cxx_debugging/tests/SymbolsBackendTests.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// found in the LICENSE file.
44

55
export interface SymbolsBackendTestsModule extends EmscriptenModule {
6+
// eslint-disable-next-line @typescript-eslint/naming-convention
67
FS: typeof FS;
78
callMain(args?: string[]): void;
89
}
910

10-
declare var createModule: EmscriptenModuleFactory<SymbolsBackendTestsModule>;
11+
declare let createModule: EmscriptenModuleFactory<SymbolsBackendTestsModule>;
1112
export default createModule;

front_end/legacy/legacy-defs.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ interface Node {
9090
isSelfOrDescendant(node: Node|null): boolean;
9191
parentElementOrShadowHost(): Element|null;
9292
parentNodeOrShadowHost(): Node|null;
93-
setTextContentTruncatedIfNeeded(text: any, placeholder?: string): boolean;
93+
setTextContentTruncatedIfNeeded(text: unknown, placeholder?: string): boolean;
9494
traverseNextNode(stayWithin?: Node): Node|null;
9595
traversePreviousNode(stayWithin?: Node): Node|null;
96-
deepTextContent(): string
96+
deepTextContent(): string;
9797
window(): Window;
9898
childTextNodes(): Node[];
9999
}

scripts/ai_assistance/types.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import {AidaRequest} from '../../front_end/core/host/AidaClient.ts'
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import type {AidaRequest} from '../../front_end/core/host/AidaClient.ts';
26

37
/**
48
* Some types used in auto-run.js. They only exist here because it's
@@ -10,7 +14,7 @@ import {AidaRequest} from '../../front_end/core/host/AidaClient.ts'
1014
*/
1115
export interface RunResult {
1216
allExampleResults: IndividualPromptRequestResponse[];
13-
metadata: ExampleMetadata[]
17+
metadata: ExampleMetadata[];
1418
}
1519

1620
/**
@@ -49,7 +53,7 @@ export interface YargsInput {
4953
// Clang cannot handle the Record<> syntax over multiple lines, it seems.
5054
/* clang-format off */
5155
export type Logs = Record<string, {
52-
index: number;
53-
text: string;
56+
index: number,
57+
text: string,
5458
}> ;
5559
/* clang-format on */

scripts/javascript_natives/test.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
interface Array<T> {
26
at(index: number): T|undefined;
37
diffSig(oneSig: number): T|undefined;

scripts/protocol_typescript/protocol_schema.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export module Protocol {
8282

8383
type DomainType = {
8484
/** Name of property */
85-
id: string;
85+
id: string,
8686
/** Description of the type */
87-
description?: string;
88-
}&(StringType|ObjectType|ArrayType|PrimitiveType)
87+
description?: string,
88+
}&(StringType|ObjectType|ArrayType|PrimitiveType);
8989

9090
type ProtocolType = StringType|ObjectType|ArrayType|PrimitiveType|RefType|AnyType;
9191
type PropertyType = PropertyBaseType&ProtocolType;

test/e2e_non_hosted/types.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
14
import type {Platform} from '../conductor/platform.js';
25

36
import type {BrowserSettings, BrowserWrapper} from './shared/browser-helper.js';
47
import type {DevToolsFronendPage, DevtoolsSettings} from './shared/frontend-helper.js';
58
import type {InspectedPage} from './shared/target-helper.js';
69

7-
810
declare global {
911
namespace Mocha {
1012
export interface TestFunction {

0 commit comments

Comments
 (0)