mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-02 03:09:09 +08:00
This rule disallows assigning a value in a return statement. It also works in one-liner arrow functions. For instance, a => a = 2 will trigger a warning. This is to avoid cases where you actually meant to compare a to 2, not assign the value 2 (maybe you wanted to return a boolean in a filter callback). These sorts of issues can easily pass review and cause weird problems that are hard to track down later. The rule is enabled in this CL, and all warnings are fixed with this CL. More info about the rule: https://eslint.org/docs/rules/no-return-assign Bug: 1093379 Change-Id: I38b98ea59ecaedc83a7f69073b17980808f9a3bf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2242761 Reviewed-by: Patrick Brosset <patrick.brosset@microsoft.com> Reviewed-by: Jose Leal <joselea@microsoft.com> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Patrick Brosset <patrick.brosset@microsoft.com>
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
// Copyright 2018 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 SDK from '../sdk/sdk.js';
|
|
import * as UI from '../ui/ui.js';
|
|
|
|
/**
|
|
* @implements {Protocol.InspectorDispatcher}
|
|
*/
|
|
export class TargetDetachedDialog extends SDK.SDKModel.SDKModel {
|
|
/**
|
|
* @param {!SDK.SDKModel.Target} target
|
|
*/
|
|
constructor(target) {
|
|
super(target);
|
|
target.registerInspectorDispatcher(this);
|
|
target.inspectorAgent().enable();
|
|
this._hideCrashedDialog = null;
|
|
TargetDetachedDialog._disconnectedScreenWithReasonWasShown = false;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} reason
|
|
*/
|
|
detached(reason) {
|
|
TargetDetachedDialog._disconnectedScreenWithReasonWasShown = true;
|
|
UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(reason);
|
|
}
|
|
|
|
static webSocketConnectionLost() {
|
|
UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(ls`WebSocket disconnected`);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
*/
|
|
targetCrashed() {
|
|
// In case of service workers targetCrashed usually signals that the worker is stopped
|
|
// and in any case it is restarted automatically (in which case front-end will receive
|
|
// targetReloadedAfterCrash event).
|
|
if (this.target().parentTarget()) {
|
|
return;
|
|
}
|
|
const dialog = new UI.Dialog.Dialog();
|
|
dialog.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent);
|
|
dialog.addCloseButton();
|
|
dialog.setDimmed(true);
|
|
this._hideCrashedDialog = dialog.hide.bind(dialog);
|
|
new UI.TargetCrashedScreen
|
|
.TargetCrashedScreen(() => {
|
|
this._hideCrashedDialog = null;
|
|
})
|
|
.show(dialog.contentElement);
|
|
dialog.show();
|
|
}
|
|
|
|
/**
|
|
* @override;
|
|
*/
|
|
targetReloadedAfterCrash() {
|
|
this.target().runtimeAgent().runIfWaitingForDebugger();
|
|
if (this._hideCrashedDialog) {
|
|
this._hideCrashedDialog.call(null);
|
|
this._hideCrashedDialog = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
SDK.SDKModel.SDKModel.register(TargetDetachedDialog, SDK.SDKModel.Capability.Inspector, true);
|