Bug 1787389 - [devtools] Fix ESLint consistent-return failures in devtools/client/debugger/src/actions. r=bomsy.

Differential Revision: https://phabricator.services.mozilla.com/D155824
This commit is contained in:
Nicolas Chevobbe 2022-08-31 11:40:15 +00:00
Родитель acff43bccc
Коммит 3074bcadc6
16 изменённых файлов: 88 добавлений и 77 удалений

Просмотреть файл

@ -33,21 +33,6 @@ module.exports = {
},
{
files: [
"client/debugger/src/actions/breakpoints/index.js",
"client/debugger/src/actions/breakpoints/modify.js",
"client/debugger/src/actions/breakpoints/syncBreakpoint.js",
"client/debugger/src/actions/expressions.js",
"client/debugger/src/actions/pause/commands.js",
"client/debugger/src/actions/pause/highlightCalls.js",
"client/debugger/src/actions/pause/inlinePreview.js",
"client/debugger/src/actions/pause/mapScopes.js",
"client/debugger/src/actions/pause/selectFrame.js",
"client/debugger/src/actions/pause/tests/pause.spec.js",
"client/debugger/src/actions/preview.js",
"client/debugger/src/actions/sources/newSources.js",
"client/debugger/src/actions/sources/select.js",
"client/debugger/src/actions/ui.js",
"client/debugger/src/client/firefox/commands.js",
"client/debugger/src/components/App.js",
"client/debugger/src/components/Editor/Breakpoint.js",
"client/debugger/src/components/Editor/ColumnBreakpoint.js",

Просмотреть файл

@ -215,7 +215,7 @@ export function toggleBreakpointAtLine(cx, line) {
const selectedSource = getSelectedSource(state);
if (!selectedSource) {
return;
return null;
}
const bp = getBreakpointAtLocation(state, { line, column: undefined });
@ -243,7 +243,7 @@ export function addBreakpointAtLine(
const source = getSelectedSource(state);
if (!source) {
return;
return null;
}
const breakpointLocation = {
sourceId: source.id,

Просмотреть файл

@ -83,7 +83,7 @@ export function enableBreakpoint(cx, initialBreakpoint) {
const { dispatch, getState, client } = thunkArgs;
const breakpoint = getBreakpoint(getState(), initialBreakpoint.location);
if (!breakpoint || !breakpoint.disabled) {
return;
return null;
}
dispatch(setSkipPausing(false));
@ -121,7 +121,7 @@ export function addBreakpoint(
// No position is found if the `initialLocation` is on a non-breakable line or
// the line no longer exists.
if (!position) {
return;
return null;
}
const { location, generatedLocation } = position;
@ -130,7 +130,7 @@ export function addBreakpoint(
const generatedSource = getLocationSource(getState(), generatedLocation);
if (!source || !generatedSource) {
return;
return null;
}
const originalContent = getSourceContent(getState(), source.id);
@ -160,7 +160,7 @@ export function addBreakpoint(
});
if (shouldCancel()) {
return;
return null;
}
dispatch(setSkipPausing(false));
@ -189,7 +189,7 @@ export function removeBreakpoint(cx, initialBreakpoint) {
const breakpoint = getBreakpoint(getState(), initialBreakpoint.location);
if (!breakpoint) {
return;
return null;
}
dispatch(setSkipPausing(false));
@ -270,7 +270,7 @@ export function disableBreakpoint(cx, initialBreakpoint) {
return ({ dispatch, getState, client }) => {
const breakpoint = getBreakpoint(getState(), initialBreakpoint.location);
if (!breakpoint || breakpoint.disabled) {
return;
return null;
}
dispatch(setSkipPausing(false));

Просмотреть файл

@ -56,7 +56,7 @@ export function syncBreakpoint(cx, sourceId, pendingBreakpoint) {
const generatedSource = getSource(getState(), generatedSourceId);
if (!source || !generatedSource) {
return;
return null;
}
const { location, generatedLocation } = pendingBreakpoint;
@ -110,7 +110,7 @@ export function syncBreakpoint(cx, sourceId, pendingBreakpoint) {
removeBreakpointAtGeneratedLocation(cx, sourceGeneratedLocation)
);
}
return;
return null;
}
const isSameLocation = comparePosition(

Просмотреть файл

@ -30,7 +30,7 @@ import { features } from "../utils/prefs";
export function addExpression(cx, input) {
return async ({ dispatch, getState, evaluationsParser }) => {
if (!input) {
return;
return null;
}
const expressionError = await evaluationsParser.hasSyntaxError(input);
@ -46,6 +46,8 @@ export function addExpression(cx, input) {
if (newExpression) {
return dispatch(evaluateExpression(cx, newExpression));
}
return null;
};
}
@ -126,7 +128,7 @@ function evaluateExpression(cx, expression) {
return async function({ dispatch, getState, client, sourceMaps }) {
if (!expression.input) {
console.warn("Expressions should not be empty");
return;
return null;
}
let { input } = expression;

Просмотреть файл

@ -61,7 +61,7 @@ export function selectThread(cx, thread) {
export function command(type) {
return async ({ dispatch, getState, client }) => {
if (!type) {
return;
return null;
}
// For now, all commands are by default against the currently selected thread
const thread = getCurrentThread(getState());
@ -85,9 +85,10 @@ export function command(type) {
*/
export function stepIn() {
return ({ dispatch, getState }) => {
if (getIsCurrentThreadPaused(getState())) {
return dispatch(command("stepIn"));
if (!getIsCurrentThreadPaused(getState())) {
return null;
}
return dispatch(command("stepIn"));
};
}
@ -99,9 +100,10 @@ export function stepIn() {
*/
export function stepOver() {
return ({ dispatch, getState }) => {
if (getIsCurrentThreadPaused(getState())) {
return dispatch(command("stepOver"));
if (!getIsCurrentThreadPaused(getState())) {
return null;
}
return dispatch(command("stepOver"));
};
}
@ -113,9 +115,10 @@ export function stepOver() {
*/
export function stepOut() {
return ({ dispatch, getState }) => {
if (getIsCurrentThreadPaused(getState())) {
return dispatch(command("stepOut"));
if (!getIsCurrentThreadPaused(getState())) {
return null;
}
return dispatch(command("stepOut"));
};
}
@ -127,10 +130,11 @@ export function stepOut() {
*/
export function resume() {
return ({ dispatch, getState }) => {
if (getIsCurrentThreadPaused(getState())) {
recordEvent("continue");
return dispatch(command("resume"));
if (!getIsCurrentThreadPaused(getState())) {
return null;
}
recordEvent("continue");
return dispatch(command("resume"));
};
}
@ -141,13 +145,14 @@ export function resume() {
*/
export function restart(cx, frame) {
return async ({ dispatch, getState, client }) => {
if (getIsCurrentThreadPaused(getState())) {
return dispatch({
type: "COMMAND",
command: "restart",
thread: cx.thread,
[PROMISE]: client.restart(cx.thread, frame.id),
});
if (!getIsCurrentThreadPaused(getState())) {
return null;
}
return dispatch({
type: "COMMAND",
command: "restart",
thread: cx.thread,
[PROMISE]: client.restart(cx.thread, frame.id),
});
};
}

Просмотреть файл

@ -27,7 +27,7 @@ function inHouseContainsPosition(a, b) {
export function highlightCalls(cx) {
return async function({ dispatch, getState, parser, client }) {
if (!cx) {
return;
return null;
}
const frame = await getSelectedFrame(
@ -36,29 +36,29 @@ export function highlightCalls(cx) {
);
if (!frame) {
return;
return null;
}
const { thread } = cx;
const originalAstScopes = await parser.getScopes(frame.location);
if (!originalAstScopes) {
return;
return null;
}
const source = getLocationSource(getState(), frame.location);
if (!source) {
return;
return null;
}
const symbols = getSymbols(getState(), source);
if (!symbols) {
return;
return null;
}
if (!symbols.callExpressions) {
return;
return null;
}
const localAstScope = originalAstScopes[0];

Просмотреть файл

@ -27,14 +27,14 @@ function getLocalScopeLevels(originalAstScopes) {
export function generateInlinePreview(cx, frame) {
return async function({ dispatch, getState, parser, client }) {
if (!frame || !features.inlinePreview) {
return;
return null;
}
const { thread } = cx;
// Avoid regenerating inline previews when we already have preview data
if (getInlinePreviews(getState(), thread, frame.id)) {
return;
return null;
}
const originalFrameScopes = getOriginalFrameScope(
@ -53,20 +53,20 @@ export function generateInlinePreview(cx, frame) {
let scopes = originalFrameScopes?.scope || generatedFrameScopes?.scope;
if (!scopes || !scopes.bindings) {
return;
return null;
}
// It's important to use selectedLocation, because we don't know
// if we'll be viewing the original or generated frame location
const selectedLocation = getSelectedLocation(getState());
if (!selectedLocation) {
return;
return null;
}
const originalAstScopes = await parser.getScopes(selectedLocation);
validateThreadContext(getState(), cx);
if (!originalAstScopes) {
return;
return null;
}
const allPreviews = [];

Просмотреть файл

@ -84,7 +84,8 @@ export async function buildOriginalScopes(
export function toggleMapScopes() {
return async function({ dispatch, getState, client, sourceMaps }) {
if (isMapScopesEnabled(getState())) {
return dispatch({ type: "TOGGLE_MAP_SCOPES", mapScopes: false });
dispatch({ type: "TOGGLE_MAP_SCOPES", mapScopes: false });
return;
}
dispatch({ type: "TOGGLE_MAP_SCOPES", mapScopes: true });

Просмотреть файл

@ -18,7 +18,8 @@ export function selectFrame(cx, frame) {
// Frames that aren't on-stack do not support evalling and may not
// have live inspectable scopes, so we do not allow selecting them.
if (frame.state !== "on-stack") {
return dispatch(selectLocation(cx, frame.location));
dispatch(selectLocation(cx, frame.location));
return;
}
dispatch({

Просмотреть файл

@ -64,6 +64,8 @@ const mockCommandClient = {
contentType: "text/rust",
});
}
return resolve();
});
},
getSourceActorBreakpointPositions: async () => ({}),

Просмотреть файл

@ -25,7 +25,7 @@ import { getMappedExpression } from "./expressions";
function findExpressionMatch(state, codeMirror, tokenPos) {
const source = getSelectedSource(state);
if (!source) {
return;
return null;
}
const symbols = getSymbols(state, source);
@ -167,7 +167,7 @@ export function clearPreview(cx) {
return ({ dispatch, getState, client }) => {
const currentSelection = getPreview(getState());
if (!currentSelection) {
return;
return null;
}
return dispatch({

Просмотреть файл

@ -65,6 +65,8 @@ function loadSourceMaps(cx, sources) {
throw error;
}
}
return [];
};
}
@ -136,7 +138,8 @@ function checkSelectedSource(cx, sourceId) {
if (rawPendingUrl === source.url) {
if (isPrettyURL(pendingUrl)) {
const prettySource = await dispatch(togglePrettyPrint(cx, source.id));
return dispatch(checkPendingBreakpoints(cx, prettySource.id));
dispatch(checkPendingBreakpoints(cx, prettySource.id));
return;
}
await dispatch(

Просмотреть файл

@ -131,7 +131,8 @@ export function selectLocation(cx, location, { keepContext = true } = {}) {
if (!source) {
// If there is no source we deselect the current selected source
return dispatch(clearSelectedLocation(cx));
dispatch(clearSelectedLocation(cx));
return;
}
const activeSearch = getActiveSearch(getState());
@ -228,7 +229,7 @@ export function selectSpecificLocation(cx, location) {
export function jumpToMappedLocation(cx, location) {
return async function({ dispatch, getState, client, sourceMaps }) {
if (!client) {
return;
return null;
}
// Map to either an original or a generated source location

Просмотреть файл

@ -165,7 +165,7 @@ export function clearHighlightLineRange() {
export function openConditionalPanel(location, log = false) {
if (!location) {
return;
return null;
}
return {

Просмотреть файл

@ -50,13 +50,15 @@ async function loadObjectProperties(root, threadActorID) {
function releaseActor(actor) {
if (!actor) {
return;
return Promise.resolve();
}
const objFront = commands.client.getFrontByID(actor);
if (objFront) {
return objFront.release().catch(() => {});
if (!objFront) {
return Promise.resolve();
}
return objFront.release().catch(() => {});
}
function lookupTarget(thread) {
@ -133,7 +135,8 @@ async function setXHRBreakpoint(path, method) {
const hasWatcherSupport = commands.targetCommand.hasTargetWatcherSupport();
if (!hasWatcherSupport) {
// Without watcher support, forward setXHRBreakpoint to all threads.
return forEachThread(thread => thread.setXHRBreakpoint(path, method));
await forEachThread(thread => thread.setXHRBreakpoint(path, method));
return;
}
const breakpointsFront = await commands.targetCommand.watcherFront.getBreakpointListActor();
await breakpointsFront.setXHRBreakpoint(path, method);
@ -143,7 +146,8 @@ async function removeXHRBreakpoint(path, method) {
const hasWatcherSupport = commands.targetCommand.hasTargetWatcherSupport();
if (!hasWatcherSupport) {
// Without watcher support, forward removeXHRBreakpoint to all threads.
return forEachThread(thread => thread.removeXHRBreakpoint(path, method));
await forEachThread(thread => thread.removeXHRBreakpoint(path, method));
return;
}
const breakpointsFront = await commands.targetCommand.watcherFront.getBreakpointListActor();
await breakpointsFront.removeXHRBreakpoint(path, method);
@ -155,18 +159,20 @@ export function toggleJavaScriptEnabled(enabled) {
});
}
function addWatchpoint(object, property, label, watchpointType) {
if (currentTarget().getTrait("watchpoints")) {
const objectFront = createObjectFront(object);
return objectFront.addWatchpoint(property, label, watchpointType);
async function addWatchpoint(object, property, label, watchpointType) {
if (!currentTarget().getTrait("watchpoints")) {
return;
}
const objectFront = createObjectFront(object);
await objectFront.addWatchpoint(property, label, watchpointType);
}
async function removeWatchpoint(object, property) {
if (currentTarget().getTrait("watchpoints")) {
const objectFront = createObjectFront(object);
await objectFront.removeWatchpoint(property);
if (!currentTarget().getTrait("watchpoints")) {
return;
}
const objectFront = createObjectFront(object);
await objectFront.removeWatchpoint(property);
}
function hasBreakpoint(location) {
@ -183,7 +189,7 @@ async function setBreakpoint(location, options) {
breakpoint &&
JSON.stringify(breakpoint.options) == JSON.stringify(options)
) {
return;
return null;
}
breakpoints[makePendingLocationId(location)] = { location, options };
@ -216,6 +222,8 @@ async function setBreakpoint(location, options) {
) {
return thread.setBreakpoint(location, serverOptions);
}
return Promise.resolve();
});
}
@ -240,6 +248,8 @@ async function removeBreakpoint(location) {
) {
return thread.removeBreakpoint(location);
}
return Promise.resolve();
});
}
@ -358,7 +368,8 @@ async function setSkipPausing(shouldSkip) {
async function setEventListenerBreakpoints(ids) {
const hasWatcherSupport = commands.targetCommand.hasTargetWatcherSupport();
if (!hasWatcherSupport) {
return forEachThread(thread => thread.setActiveEventBreakpoints(ids));
await forEachThread(thread => thread.setActiveEventBreakpoints(ids));
return;
}
const breakpointListFront = await commands.targetCommand.watcherFront.getBreakpointListActor();
await breakpointListFront.setActiveEventBreakpoints(ids);