Skip to content

Commit 52a1797

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[eslint] Fix duplicate rule and new errors
Remove `extensions/cxx_debugging/third_party/` file from linting. Fix duplicate rule that was disabling the first one. Changed the interfaces to match camelCase as in TS style guide https://google.github.io/styleguide/tsguide.html#camel-case Also adds names to rules so it's easier to see what caused the error. Bug: none Change-Id: I3f5f6ba0a450a87c2905ba449c1ffbb0d00dcaa1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6172437 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Jack Franklin <[email protected]>
1 parent 1f699e5 commit 52a1797

File tree

5 files changed

+63
-58
lines changed

5 files changed

+63
-58
lines changed

eslint.config.mjs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rulesdirPlugin.RULES_DIR = join(
2020
*/
2121
export default [
2222
{
23+
name: 'Ignore list',
2324
ignores: [
2425
'front_end/diff/diff_match_patch.jD',
2526
'front_end/models/javascript_metadata/NativeFunctions.js',
@@ -35,7 +36,7 @@ export default [
3536
// own.
3637
'front_end/third_party/*/package/',
3738
// Any JS files are also not authored by devtools-frontend, so we ignore those.
38-
'front_end/third_party/**/*.js',
39+
'front_end/third_party/**/*',
3940
// Lighthouse doesn't have a package/ folder but has other nested folders, so
4041
// we ignore any folders within the lighthouse directory.
4142
'front_end/third_party/lighthouse/*/',
@@ -46,6 +47,8 @@ export default [
4647
'front_end/third_party/lit/src/*.ts',
4748
// @puppeteer/replay is auto-generated.
4849
'front_end/third_party/puppeteer-replay/**/*.ts',
50+
// Third party code we did not author for extensions
51+
'extensions/cxx_debugging/third_party/**/*',
4952

5053
'**/node_modules',
5154
'scripts/build/typescript/tests',
@@ -268,28 +271,15 @@ export default [
268271
parserOptions: {
269272
allowAutomaticSingleRunInference: true,
270273
project: join(
271-
import.meta.dirname,
272-
'config',
273-
'typescript',
274-
'tsconfig.eslint.json',
275-
),
274+
import.meta.dirname,
275+
'config',
276+
'typescript',
277+
'tsconfig.eslint.json',
278+
),
276279
},
277280
},
278281

279282
rules: {
280-
// Forbids interfaces starting with an I prefix.
281-
'@typescript-eslint/naming-convention': [
282-
'error',
283-
{
284-
selector: 'interface',
285-
format: ['PascalCase'],
286-
287-
custom: {
288-
regex: '^I[A-Z]',
289-
match: false,
290-
},
291-
},
292-
],
293283
'@typescript-eslint/no-explicit-any': [
294284
'error',
295285
{
@@ -375,6 +365,16 @@ export default [
375365

376366
'@typescript-eslint/naming-convention': [
377367
'error',
368+
// Forbids interfaces starting with an I prefix.
369+
{
370+
selector: 'interface',
371+
format: ['PascalCase'],
372+
373+
custom: {
374+
regex: '^I[A-Z]',
375+
match: false,
376+
},
377+
},
378378
{
379379
selector: [
380380
'function',
@@ -464,12 +464,12 @@ export default [
464464
{
465465
// Enforce that any import of models/trace/trace.js names the import Trace.
466466
modulePath: join(
467-
import.meta.dirname,
468-
'front_end',
469-
'models',
470-
'trace',
471-
'trace.js',
472-
),
467+
import.meta.dirname,
468+
'front_end',
469+
'models',
470+
'trace',
471+
'trace.js',
472+
),
473473
importName: 'Trace',
474474
},
475475
],
@@ -621,6 +621,7 @@ export default [
621621
},
622622
},
623623
{
624+
name: 'Use private class members rule',
624625
files: [
625626
'front_end/panels/**/components/*.ts',
626627
'front_end/ui/components/**/*.ts',
@@ -632,6 +633,7 @@ export default [
632633
},
633634
},
634635
{
636+
name: 'Ignore private class members rule',
635637
files: [
636638
'front_end/panels/recorder/**/*.ts',
637639
'front_end/ui/components/suggestion_input/*.ts',
@@ -642,6 +644,7 @@ export default [
642644
},
643645
},
644646
{
647+
name: 'Supported CSS properties rules',
645648
files: ['front_end/generated/SupportedCSSProperties.js'],
646649
rules: {
647650
'rulesdir/jslog-context-list': 'error',
@@ -676,6 +679,7 @@ export default [
676679
},
677680
},
678681
{
682+
name: 'Traces import rule',
679683
files: ['front_end/models/trace/handlers/**/*.ts'],
680684
rules: {
681685
'rulesdir/no-imports-in-directory': [
@@ -689,6 +693,7 @@ export default [
689693
},
690694
},
691695
{
696+
name: 'Recorder injected code',
692697
files: ['front_end/panels/recorder/injected/**/*.ts'],
693698
rules: {
694699
// The code is rolled up and tree-shaken independently from the regular entrypoints.

front_end/models/live-metrics/LiveMetrics.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export class LiveMetrics extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
4646
#target?: SDK.Target.Target;
4747
#scriptIdentifier?: Protocol.Page.ScriptIdentifier;
4848
#lastResetContextId?: Protocol.Runtime.ExecutionContextId;
49-
#lcpValue?: LCPValue;
50-
#clsValue?: CLSValue;
51-
#inpValue?: INPValue;
49+
#lcpValue?: LcpValue;
50+
#clsValue?: ClsValue;
51+
#inpValue?: InpValue;
5252
#interactions: InteractionMap = new Map();
5353
#interactionsByGroupId = new Map<Spec.InteractionEntryGroupId, Interaction[]>();
5454
#layoutShifts: LayoutShift[] = [];
@@ -70,15 +70,15 @@ export class LiveMetrics extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
7070
return liveMetricsInstance;
7171
}
7272

73-
get lcpValue(): LCPValue|undefined {
73+
get lcpValue(): LcpValue|undefined {
7474
return this.#lcpValue;
7575
}
7676

77-
get clsValue(): CLSValue|undefined {
77+
get clsValue(): ClsValue|undefined {
7878
return this.#clsValue;
7979
}
8080

81-
get inpValue(): INPValue|undefined {
81+
get inpValue(): InpValue|undefined {
8282
return this.#inpValue;
8383
}
8484

@@ -261,7 +261,7 @@ export class LiveMetrics extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
261261
switch (webVitalsEvent.name) {
262262
case 'LCP': {
263263
const warnings: string[] = [];
264-
const lcpEvent: LCPValue = {
264+
const lcpEvent: LcpValue = {
265265
value: webVitalsEvent.value,
266266
phases: webVitalsEvent.phases,
267267
warnings,
@@ -281,15 +281,15 @@ export class LiveMetrics extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
281281
break;
282282
}
283283
case 'CLS': {
284-
const event: CLSValue = {
284+
const event: ClsValue = {
285285
value: webVitalsEvent.value,
286286
clusterShiftIds: webVitalsEvent.clusterShiftIds,
287287
};
288288
this.#clsValue = event;
289289
break;
290290
}
291291
case 'INP': {
292-
const inpEvent: INPValue = {
292+
const inpEvent: InpValue = {
293293
value: webVitalsEvent.value,
294294
phases: webVitalsEvent.phases,
295295
interactionId: `interaction-${webVitalsEvent.entryGroupId}-${webVitalsEvent.startTime}`,
@@ -586,17 +586,17 @@ export interface NodeRef {
586586
link: Node;
587587
}
588588

589-
export interface LCPValue extends MetricValue {
590-
phases: Spec.LCPPhases;
589+
export interface LcpValue extends MetricValue {
590+
phases: Spec.LcpPhases;
591591
nodeRef?: NodeRef;
592592
}
593593

594-
export interface INPValue extends MetricValue {
595-
phases: Spec.INPPhases;
594+
export interface InpValue extends MetricValue {
595+
phases: Spec.InpPhases;
596596
interactionId: InteractionId;
597597
}
598598

599-
export interface CLSValue extends MetricValue {
599+
export interface ClsValue extends MetricValue {
600600
clusterShiftIds: Spec.UniqueLayoutShiftId[];
601601
}
602602

@@ -613,15 +613,15 @@ export interface Interaction {
613613
duration: number;
614614
startTime: number;
615615
nextPaintTime: number;
616-
phases: Spec.INPPhases;
616+
phases: Spec.InpPhases;
617617
longAnimationFrameTimings: Spec.PerformanceLongAnimationFrameTimingJSON[];
618618
nodeRef?: NodeRef;
619619
}
620620

621621
export interface StatusEvent {
622-
lcp?: LCPValue;
623-
cls?: CLSValue;
624-
inp?: INPValue;
622+
lcp?: LcpValue;
623+
cls?: ClsValue;
624+
inp?: InpValue;
625625
interactions: InteractionMap;
626626
layoutShifts: LayoutShift[];
627627
}

front_end/models/live-metrics/web-vitals-injected/spec/spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ export function getUniqueLayoutShiftId(entry: LayoutShift): UniqueLayoutShiftId
1919
return `layout-shift-${entry.value}-${entry.startTime}`;
2020
}
2121

22-
export interface LCPPhases {
22+
export interface LcpPhases {
2323
timeToFirstByte: number;
2424
resourceLoadDelay: number;
2525
resourceLoadTime: number;
2626
elementRenderDelay: number;
2727
}
2828

29-
export interface INPPhases {
29+
export interface InpPhases {
3030
inputDelay: number;
3131
processingDuration: number;
3232
presentationDelay: number;
3333
}
3434

35-
export interface LCPChangeEvent extends MetricChangeEvent {
35+
export interface LcpChangeEvent extends MetricChangeEvent {
3636
name: 'LCP';
37-
phases: LCPPhases;
37+
phases: LcpPhases;
3838
nodeIndex?: number;
3939
}
4040

41-
export interface CLSChangeEvent extends MetricChangeEvent {
41+
export interface ClsChangeEvent extends MetricChangeEvent {
4242
name: 'CLS';
4343
clusterShiftIds: UniqueLayoutShiftId[];
4444
}
4545

46-
export interface INPChangeEvent extends MetricChangeEvent {
46+
export interface InpChangeEvent extends MetricChangeEvent {
4747
name: 'INP';
4848
interactionType: INPAttribution['interactionType'];
49-
phases: INPPhases;
49+
phases: InpPhases;
5050
startTime: number;
5151
entryGroupId: InteractionEntryGroupId;
5252
}
@@ -92,7 +92,7 @@ export interface InteractionEntryEvent {
9292
startTime: number;
9393
nextPaintTime: number;
9494
duration: number;
95-
phases: INPPhases;
95+
phases: InpPhases;
9696
nodeIndex?: number;
9797
longAnimationFrameEntries: PerformanceLongAnimationFrameTimingJSON[];
9898
}
@@ -109,4 +109,4 @@ export interface ResetEvent {
109109
}
110110

111111
export type WebVitalsEvent =
112-
LCPChangeEvent|CLSChangeEvent|INPChangeEvent|InteractionEntryEvent|LayoutShiftEvent|ResetEvent;
112+
LcpChangeEvent|ClsChangeEvent|InpChangeEvent|InteractionEntryEvent|LayoutShiftEvent|ResetEvent;

front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function initialize(): void {
135135
});
136136

137137
onLCP(metric => {
138-
const event: Spec.LCPChangeEvent = {
138+
const event: Spec.LcpChangeEvent = {
139139
name: 'LCP',
140140
value: metric.value,
141141
phases: {
@@ -154,7 +154,7 @@ function initialize(): void {
154154
}, {reportAllChanges: true});
155155

156156
onCLS(metric => {
157-
const event: Spec.CLSChangeEvent = {
157+
const event: Spec.ClsChangeEvent = {
158158
name: 'CLS',
159159
value: metric.value,
160160
clusterShiftIds: metric.entries.map(Spec.getUniqueLayoutShiftId),
@@ -163,7 +163,7 @@ function initialize(): void {
163163
}, {reportAllChanges: true});
164164

165165
onINP(metric => {
166-
const event: Spec.INPChangeEvent = {
166+
const event: Spec.InpChangeEvent = {
167167
name: 'INP',
168168
value: metric.value,
169169
phases: {

front_end/panels/timeline/components/LiveMetricsView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
294294

295295
#isNode: boolean = false;
296296

297-
#lcpValue?: LiveMetrics.LCPValue;
298-
#clsValue?: LiveMetrics.CLSValue;
299-
#inpValue?: LiveMetrics.INPValue;
297+
#lcpValue?: LiveMetrics.LcpValue;
298+
#clsValue?: LiveMetrics.ClsValue;
299+
#inpValue?: LiveMetrics.InpValue;
300300
#interactions: LiveMetrics.InteractionMap = new Map();
301301
#layoutShifts: LiveMetrics.LayoutShift[] = [];
302302

0 commit comments

Comments
 (0)