mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-30 09:54:02 +08:00
This CL adds the eslint-plugin-jsdoc plugin and enables just one rule, `jsdoc/check-alignment`, which ensures that all the lines in a comment are correctly aligned. For example: ``` /** * foo * bar */ ``` Would fail the check and be corrected to: ``` /** * foo * bar */ ``` DISABLE_THIRD_PARTY_CHECK=deliberate install + use of eslint-plugin-jsdoc node_module Bug: none Change-Id: I969983cd550653654a334ede3409b8c850467245 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4110906 Commit-Queue: Andres Olivares <andoli@chromium.org> Reviewed-by: Andres Olivares <andoli@chromium.org> Auto-Submit: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as Common from '../../core/common/common.js';
|
|
import type * as Protocol from '../../generated/protocol.js';
|
|
|
|
import {type Issue} from './Issue.js';
|
|
import {IssuesManager, Events as IssueManagerEvents, type IssueAddedEvent} from './IssuesManager.js';
|
|
|
|
/**
|
|
* A class that facilitates resolving an issueId to an issue. See `ResolverBase` for more info.
|
|
*/
|
|
export class IssueResolver extends Common.ResolverBase.ResolverBase<Protocol.Audits.IssueId, Issue> {
|
|
#issuesListener: Common.EventTarget.EventDescriptor|null = null;
|
|
#issuesManager: IssuesManager;
|
|
|
|
constructor(issuesManager: IssuesManager = IssuesManager.instance()) {
|
|
super();
|
|
this.#issuesManager = issuesManager;
|
|
}
|
|
|
|
protected override getForId(id: Protocol.Audits.IssueId): Issue|null {
|
|
return this.#issuesManager.getIssueById(id) || null;
|
|
}
|
|
|
|
#onIssueAdded(event: Common.EventTarget.EventTargetEvent<IssueAddedEvent>): void {
|
|
const {issue} = event.data;
|
|
const id = issue.getIssueId();
|
|
if (id) {
|
|
this.onResolve(id, issue);
|
|
}
|
|
}
|
|
|
|
protected override startListening(): void {
|
|
if (this.#issuesListener) {
|
|
return;
|
|
}
|
|
this.#issuesListener =
|
|
this.#issuesManager.addEventListener(IssueManagerEvents.IssueAdded, this.#onIssueAdded, this);
|
|
}
|
|
|
|
protected override stopListening(): void {
|
|
if (!this.#issuesListener) {
|
|
return;
|
|
}
|
|
Common.EventTarget.removeEventListeners([this.#issuesListener]);
|
|
this.#issuesListener = null;
|
|
}
|
|
}
|