Skip to content

Commit

Permalink
Bug 1784073 - [devtools] Fix ESLint consistent-return failures in dev…
Browse files Browse the repository at this point in the history
…tools/client/debugger/src/utils/. r=bomsy.

Depends on D154244

Differential Revision: https://phabricator.services.mozilla.com/D154245
  • Loading branch information
nchevobbe committed Aug 12, 2022
1 parent a77c3be commit 39880dc
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 30 deletions.
8 changes: 0 additions & 8 deletions devtools/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ module.exports = {
"client/debugger/src/selectors/pause.js",
"client/debugger/src/selectors/sources.js",
"client/debugger/src/selectors/visibleColumnBreakpoints.js",
"client/debugger/src/utils/build-query.js",
"client/debugger/src/utils/editor/source-documents.js",
"client/debugger/src/utils/editor/source-search.js",
"client/debugger/src/utils/editor/token-events.js",
"client/debugger/src/utils/pause/scopes/getScope.js",
"client/debugger/src/utils/quick-open.js",
"client/debugger/src/utils/source.js",
"client/debugger/src/utils/test-head.js",
"client/debugger/src/workers/parser/frameworks.js",
"client/debugger/src/workers/parser/mapBindings.js",
"client/debugger/src/workers/parser/utils/ast.js",
Expand Down
2 changes: 2 additions & 0 deletions devtools/client/debugger/src/utils/build-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function buildFlags(caseSensitive, isGlobal) {
if (!caseSensitive && !isGlobal) {
return "i";
}

return null;
}

export default function buildQuery(
Expand Down
7 changes: 4 additions & 3 deletions devtools/client/debugger/src/utils/editor/source-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ function resetLineNumberFormat(editor) {
resizeToggleButton(cm);
}

export function updateLineNumberFormat(editor, sourceId) {
function updateLineNumberFormat(editor, sourceId) {
if (!isWasm(sourceId)) {
return resetLineNumberFormat(editor);
resetLineNumberFormat(editor);
return;
}
const cm = editor.codeMirror;
const lineNumberFormatter = getWasmLineNumberFormatter(sourceId);
Expand Down Expand Up @@ -151,7 +152,7 @@ export function showSourceText(editor, source, sourceTextContent, symbols) {
editor.replaceDocument(doc);
updateLineNumberFormat(editor, source.id);
setMode(editor, source, sourceTextContent, symbols);
return doc;
return;
}

const doc = editor.createDocument();
Expand Down
19 changes: 10 additions & 9 deletions devtools/client/debugger/src/utils/editor/source-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ function isWhitespace(query) {
}

/**
* This returns a mode object used by CoeMirror's addOverlay function
* This returns a mode object used by CodeMirror's addOverlay function
* to parse and style tokens in the file.
* The mode object contains a tokenizer function (token) which takes
* a character stream as input, advances it a character at a time,
* and returns style(s) for that token. For more details see
* https://codemirror.net/doc/manual.html#modeapi
*
* Also the token function code is mainly based of work done
* by the chrome devtools team. Thanks guys! :)
* https://codemirror.net/5/doc/manual.html#modeapi
*
* @memberof utils/source-search
* @static
Expand All @@ -68,14 +65,18 @@ function searchOverlay(query, modifiers) {
// set the class for a match
stream.pos += match[0].length || 1;
return "highlight highlight-full";
} else if (match) {
}

if (match) {
// if we have a match somewhere in the line, go to that point in the
// stream
stream.pos = match.index;
} else {
// if we have no matches in this line, skip to the end of the line
stream.skipToEnd();
}

return null;
},
};
}
Expand Down Expand Up @@ -134,14 +135,14 @@ function doSearch(
) {
const { cm, ed } = ctx;
if (!cm) {
return;
return null;
}
const defaultIndex = { line: -1, ch: -1 };

return cm.operation(function() {
if (!query || isWhitespace(query)) {
clearSearch(cm, query);
return;
return null;
}

const state = getSearchState(cm, query);
Expand Down Expand Up @@ -177,7 +178,7 @@ export function searchSourceForHighlight(
return;
}

return cm.operation(function() {
cm.operation(function() {
const state = getSearchState(cm, query);
const isNewQuery = state.query !== query;
state.query = query;
Expand Down
3 changes: 2 additions & 1 deletion devtools/client/debugger/src/utils/editor/token-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function onMouseOver(codeMirror) {

function onMouseLeave(event) {
if (invalidLeaveTarget(event.relatedTarget)) {
return addMouseLeave(event.target);
addMouseLeave(event.target);
return;
}

prevTokenPos = null;
Expand Down
2 changes: 2 additions & 0 deletions devtools/client/debugger/src/utils/pause/scopes/getScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@ export function mergeScopes(scope, parentScope, item, parentItem) {
type: NODE_TYPES.BLOCK,
};
}

return null;
}
12 changes: 7 additions & 5 deletions devtools/client/debugger/src/utils/quick-open.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ export function parseLineColumn(query) {
const [, line, column] = query.split(":");
const lineNumber = parseInt(line, 10);
const columnNumber = parseInt(column, 10);
if (!isNaN(lineNumber)) {
return {
line: lineNumber,
...(!isNaN(columnNumber) ? { column: columnNumber } : null),
};
if (isNaN(lineNumber)) {
return null;
}

return {
line: lineNumber,
...(!isNaN(columnNumber) ? { column: columnNumber } : null),
};
}

export function formatSourceForList(
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/debugger/src/utils/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export function isGenerated(source) {

export function getSourceQueryString(source) {
if (!source) {
return;
return "";
}

return parseURL(getRawSourceURL(source.url)).search;
Expand Down
4 changes: 1 addition & 3 deletions devtools/client/debugger/src/utils/test-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ function createMakeSource() {
return false;
},
getCachedFront(typeName) {
if (typeName == "thread") {
return { actorID: "FakeThread" };
}
return typeName == "thread" ? { actorID: "FakeThread" } : null;
},
},
// Allow to use custom ID's for reducer source objects
Expand Down

0 comments on commit 39880dc

Please sign in to comment.