Enable eqeqeq ESLint rule and fix violations (#2043)
This commit is contained in:
@@ -49,7 +49,6 @@ const baseConfig = {
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
"no-useless-escape": 0,
|
||||
camelcase: "off",
|
||||
eqeqeq: "off",
|
||||
"escompat/no-regexp-lookbehind": "off",
|
||||
"etc/no-implicit-any-catch": "error",
|
||||
"filenames/match-regex": "off",
|
||||
|
||||
@@ -51,7 +51,7 @@ export abstract class AbstractWebview<
|
||||
}
|
||||
|
||||
protected async getPanel(): Promise<WebviewPanel> {
|
||||
if (this.panel == undefined) {
|
||||
if (this.panel === undefined) {
|
||||
const { ctx } = this;
|
||||
|
||||
// This is an async method, so in theory this method can be called concurrently. To ensure that we don't
|
||||
|
||||
@@ -384,7 +384,7 @@ export class CodeQLCliServer implements Disposable {
|
||||
this.killProcessIfRunning();
|
||||
// Report the error (if there is a stderr then use that otherwise just report the error cod or nodejs error)
|
||||
const newError =
|
||||
stderrBuffers.length == 0
|
||||
stderrBuffers.length === 0
|
||||
? new Error(`${description} failed: ${err}`)
|
||||
: new Error(
|
||||
`${description} failed: ${Buffer.concat(stderrBuffers).toString(
|
||||
|
||||
@@ -357,7 +357,7 @@ export class QueryServerConfigListener
|
||||
if (memory === null) {
|
||||
return undefined;
|
||||
}
|
||||
if (memory == 0 || typeof memory !== "number") {
|
||||
if (memory === 0 || typeof memory !== "number") {
|
||||
void extLogger.log(
|
||||
`Ignoring value '${memory}' for setting ${MEMORY_SETTING.qualifiedName}`,
|
||||
);
|
||||
|
||||
@@ -128,9 +128,9 @@ function createTemplates(path: string): Record<string, string> {
|
||||
function isValidSelect(selectInfo: ResultSetSchema | undefined) {
|
||||
return (
|
||||
selectInfo &&
|
||||
selectInfo.columns.length == 3 &&
|
||||
selectInfo.columns[0].kind == ColumnKindCode.ENTITY &&
|
||||
selectInfo.columns[1].kind == ColumnKindCode.ENTITY &&
|
||||
selectInfo.columns[2].kind == ColumnKindCode.STRING
|
||||
selectInfo.columns.length === 3 &&
|
||||
selectInfo.columns[0].kind === ColumnKindCode.ENTITY &&
|
||||
selectInfo.columns[1].kind === ColumnKindCode.ENTITY &&
|
||||
selectInfo.columns[2].kind === ColumnKindCode.STRING
|
||||
);
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ export class DatabaseManager extends DisposableObject {
|
||||
token: vscode.CancellationToken,
|
||||
item: DatabaseItem,
|
||||
) {
|
||||
if (this._currentDatabaseItem == item) {
|
||||
if (this._currentDatabaseItem === item) {
|
||||
this._currentDatabaseItem = undefined;
|
||||
}
|
||||
const index = this.databaseItems.findIndex(
|
||||
|
||||
@@ -650,10 +650,10 @@ export class ReleasesApiConsumer {
|
||||
redirectCount < ReleasesApiConsumer._maxRedirects
|
||||
) {
|
||||
const parsedRedirectUrl = parse(redirectUrl);
|
||||
if (parsedRedirectUrl.protocol != "https:") {
|
||||
if (parsedRedirectUrl.protocol !== "https:") {
|
||||
throw new Error("Encountered a non-https redirect, rejecting");
|
||||
}
|
||||
if (parsedRedirectUrl.host != "api.github.com") {
|
||||
if (parsedRedirectUrl.host !== "api.github.com") {
|
||||
// Remove authorization header if we are redirected outside of the GitHub API.
|
||||
//
|
||||
// This is necessary to stream release assets since AWS fails if more than one auth
|
||||
|
||||
@@ -110,7 +110,7 @@ function sortInterpretedResults(
|
||||
function interpretedPageSize(
|
||||
interpretation: Interpretation | undefined,
|
||||
): number {
|
||||
if (interpretation?.data.t == "GraphInterpretationData") {
|
||||
if (interpretation?.data.t === "GraphInterpretationData") {
|
||||
// Graph views always have one result per page.
|
||||
return 1;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ function numPagesOfResultSet(
|
||||
const pageSize = interpretedPageSize(interpretation);
|
||||
|
||||
const n =
|
||||
interpretation?.data.t == "GraphInterpretationData"
|
||||
interpretation?.data.t === "GraphInterpretationData"
|
||||
? interpretation.data.dot.length
|
||||
: resultSet.schema.rows;
|
||||
|
||||
@@ -141,7 +141,7 @@ function numInterpretedPages(
|
||||
const pageSize = interpretedPageSize(interpretation);
|
||||
|
||||
const n =
|
||||
interpretation.data.t == "GraphInterpretationData"
|
||||
interpretation.data.t === "GraphInterpretationData"
|
||||
? interpretation.data.dot.length
|
||||
: interpretation.data.runs[0].results?.length || 0;
|
||||
|
||||
@@ -446,7 +446,7 @@ export class ResultsView extends AbstractWebview<
|
||||
|
||||
const selectedTable = getDefaultResultSetName(resultSetNames);
|
||||
const schema = resultSetSchemas.find(
|
||||
(resultSet) => resultSet.name == selectedTable,
|
||||
(resultSet) => resultSet.name === selectedTable,
|
||||
)!;
|
||||
|
||||
// Use sorted results path if it exists. This may happen if we are
|
||||
@@ -590,7 +590,7 @@ export class ResultsView extends AbstractWebview<
|
||||
const resultSetNames = allResultSetSchemas.map((schema) => schema.name);
|
||||
|
||||
const schema = resultSetSchemas.find(
|
||||
(resultSet) => resultSet.name == selectedTable,
|
||||
(resultSet) => resultSet.name === selectedTable,
|
||||
)!;
|
||||
if (schema === undefined)
|
||||
throw new Error(`Query result set '${selectedTable}' not found.`);
|
||||
|
||||
@@ -321,7 +321,7 @@ export async function compileAndRunQueryAgainstDatabase(
|
||||
// This test will produce confusing results if we ever change the name of the database schema files.
|
||||
const querySchemaName = basename(packConfig.dbscheme);
|
||||
const dbSchemaName = basename(dbItem.contents.dbSchemeUri.fsPath);
|
||||
if (querySchemaName != dbSchemaName) {
|
||||
if (querySchemaName !== dbSchemaName) {
|
||||
void extLogger.log(
|
||||
`Query schema was ${querySchemaName}, but database schema was ${dbSchemaName}.`,
|
||||
);
|
||||
@@ -403,7 +403,7 @@ export async function compileAndRunQueryAgainstDatabase(
|
||||
} catch (e) {
|
||||
if (
|
||||
e instanceof ResponseError &&
|
||||
e.code == LSPErrorCodes.RequestCancelled
|
||||
e.code === LSPErrorCodes.RequestCancelled
|
||||
) {
|
||||
return createSyntheticResult(query, "Query cancelled");
|
||||
} else {
|
||||
@@ -432,7 +432,7 @@ export async function compileAndRunQueryAgainstDatabase(
|
||||
query: query.queryEvalInfo,
|
||||
message,
|
||||
result,
|
||||
successful: result.resultType == messages.QueryResultType.SUCCESS,
|
||||
successful: result.resultType === messages.QueryResultType.SUCCESS,
|
||||
logFileLocation: result.logFileLocation,
|
||||
dispose: () => {
|
||||
qs.logger.removeAdditionalLogLocation(result.logFileLocation);
|
||||
|
||||
@@ -338,7 +338,7 @@ class JoinOrderScanner implements EvaluationLogScanner {
|
||||
inLayerEvent.predicateIterationMillis.length <= iteration
|
||||
? -1
|
||||
: inLayerEvent.predicateIterationMillis[iteration];
|
||||
if (iterationTime != -1) {
|
||||
if (iterationTime !== -1) {
|
||||
const run: PipelineRun =
|
||||
inLayerEvent.pipelineRuns[nextPipeline[predicate]++];
|
||||
func(inLayerEvent, run, iteration);
|
||||
|
||||
@@ -60,7 +60,7 @@ export function getPath(
|
||||
for (const codeFlows of result.codeFlows) {
|
||||
for (const threadFlow of codeFlows.threadFlows) {
|
||||
++index;
|
||||
if (index == key.pathIndex) return threadFlow;
|
||||
if (index === key.pathIndex) return threadFlow;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -192,8 +192,8 @@ export function shouldHighlightLine(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (highlightedRegion.endLine == undefined) {
|
||||
return lineNumber == highlightedRegion.startLine;
|
||||
if (highlightedRegion.endLine === undefined) {
|
||||
return lineNumber === highlightedRegion.startLine;
|
||||
}
|
||||
|
||||
return lineNumber <= highlightedRegion.endLine;
|
||||
|
||||
@@ -621,7 +621,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
await Promise.all(
|
||||
this.treeDataProvider.allHistory.map(async (item) => {
|
||||
if (
|
||||
item.t == "local" &&
|
||||
item.t === "local" &&
|
||||
item.completedQuery &&
|
||||
!(await pathExists(item.completedQuery?.query.querySaveDir))
|
||||
) {
|
||||
@@ -834,7 +834,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
if (
|
||||
prevItemClick !== undefined &&
|
||||
now.valueOf() - prevItemClick.time.valueOf() < DOUBLE_CLICK_TIME &&
|
||||
finalSingleItem == prevItemClick.item
|
||||
finalSingleItem === prevItemClick.item
|
||||
) {
|
||||
// show original query file on double click
|
||||
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
|
||||
@@ -1043,7 +1043,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
}
|
||||
|
||||
// If the JSON summary file location wasn't saved, display error
|
||||
if (finalSingleItem.jsonEvalLogSummaryLocation == undefined) {
|
||||
if (finalSingleItem.jsonEvalLogSummaryLocation === undefined) {
|
||||
this.warnInProgressEvalLogViewer();
|
||||
return;
|
||||
}
|
||||
@@ -1342,7 +1342,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
private updateTreeViewSelectionIfVisible() {
|
||||
if (this.treeView.visible) {
|
||||
const current = this.treeDataProvider.getCurrent();
|
||||
if (current != undefined) {
|
||||
if (current !== undefined) {
|
||||
// We must fire the onDidChangeTreeData event to ensure the current element can be selected
|
||||
// using `reveal` if the tree view was not visible when the current element was added.
|
||||
this.treeDataProvider.refresh();
|
||||
|
||||
@@ -149,7 +149,7 @@ export async function displayQuickQuery(
|
||||
} catch (e) {
|
||||
if (
|
||||
e instanceof ResponseError &&
|
||||
e.code == LSPErrorCodes.RequestCancelled
|
||||
e.code === LSPErrorCodes.RequestCancelled
|
||||
) {
|
||||
throw new UserCancellationException(getErrorMessage(e));
|
||||
} else {
|
||||
|
||||
@@ -153,7 +153,7 @@ export function tryGetRule(
|
||||
}
|
||||
|
||||
const ruleIndex = resultRule.index;
|
||||
if (ruleIndex != undefined) {
|
||||
if (ruleIndex !== undefined) {
|
||||
const toolComponentIndex = result.rule?.toolComponent?.index;
|
||||
const toolExtensions = sarifRun.tool.extensions;
|
||||
if (toolComponentIndex !== undefined && toolExtensions !== undefined) {
|
||||
|
||||
@@ -517,7 +517,7 @@ export async function determineSelectedQuery(
|
||||
let quickEvalPosition: messages.Position | undefined = undefined;
|
||||
let quickEvalText: string | undefined = undefined;
|
||||
if (quickEval) {
|
||||
if (editor == undefined) {
|
||||
if (editor === undefined) {
|
||||
throw new Error("Can't run quick evaluation without an active editor.");
|
||||
}
|
||||
if (editor.document.fileName !== queryPath) {
|
||||
|
||||
@@ -306,7 +306,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
reopenedDatabase,
|
||||
closedDatabase.name,
|
||||
);
|
||||
if (currentDatabaseUri == uri) {
|
||||
if (currentDatabaseUri?.toString() === uri.toString()) {
|
||||
await this.databaseManager.setCurrentDatabaseItem(
|
||||
reopenedDatabase,
|
||||
true,
|
||||
|
||||
@@ -53,7 +53,7 @@ export const CodeSnippetLine = ({
|
||||
message &&
|
||||
severity &&
|
||||
highlightedRegion &&
|
||||
highlightedRegion.endLine == startingLineIndex + lineIndex;
|
||||
highlightedRegion.endLine === startingLineIndex + lineIndex;
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -177,7 +177,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
|
||||
msg: string | undefined,
|
||||
locationHint: string,
|
||||
): JSX.Element | undefined {
|
||||
if (msg == undefined) return undefined;
|
||||
if (msg === undefined) return undefined;
|
||||
return <span title={locationHint}>{msg}</span>;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
|
||||
const paths: Sarif.ThreadFlow[] = Keys.getAllPaths(result);
|
||||
|
||||
const indices =
|
||||
paths.length == 1
|
||||
paths.length === 1
|
||||
? [resultKey, { ...resultKey, pathIndex: 0 }]
|
||||
: /* if there's exactly one path, auto-expand
|
||||
* the path when expanding the result */
|
||||
|
||||
@@ -80,7 +80,7 @@ export class Graph extends React.Component<GraphProps> {
|
||||
graphviz(`#${graphId}`)
|
||||
.options(options)
|
||||
.attributer(function (d) {
|
||||
if (d.tag == "a") {
|
||||
if (d.tag === "a") {
|
||||
const url = d.attributes["xlink:href"] || d.attributes["href"];
|
||||
const loc = tryGetLocationFromString(url);
|
||||
if (loc !== undefined) {
|
||||
@@ -94,13 +94,13 @@ export class Graph extends React.Component<GraphProps> {
|
||||
}
|
||||
|
||||
if ("fill" in d.attributes) {
|
||||
d.attributes.fill = d.tag == "text" ? color : backgroundColor;
|
||||
d.attributes.fill = d.tag === "text" ? color : backgroundColor;
|
||||
}
|
||||
if ("stroke" in d.attributes) {
|
||||
// There is no proper way to identify the element containing the graph (which we
|
||||
// don't want a border around), as it is just has tag 'polygon'. Instead we assume
|
||||
// that the first polygon we see is that element
|
||||
if (d.tag != "polygon" || !firstPolygon) {
|
||||
if (d.tag !== "polygon" || !firstPolygon) {
|
||||
d.attributes.stroke = borderColor;
|
||||
} else {
|
||||
firstPolygon = false;
|
||||
|
||||
@@ -92,7 +92,7 @@ export class ResultTables extends React.Component<
|
||||
// @ts-ignore 2783
|
||||
this.props.rawResultSets.map((rs) => ({ t: "RawResultSet", ...rs }));
|
||||
|
||||
if (this.props.interpretation != undefined) {
|
||||
if (this.props.interpretation !== undefined) {
|
||||
const tableName = this.getInterpretedTableName();
|
||||
resultSets.push({
|
||||
t: "InterpretedResultSet",
|
||||
@@ -307,10 +307,11 @@ export class ResultTables extends React.Component<
|
||||
const resultSetNames = this.getResultSetNames();
|
||||
|
||||
const resultSet = resultSets.find(
|
||||
(resultSet) => resultSet.schema.name == selectedTable,
|
||||
(resultSet) => resultSet.schema.name === selectedTable,
|
||||
);
|
||||
const nonemptyRawResults = resultSets.some(
|
||||
(resultSet) => resultSet.t == "RawResultSet" && resultSet.rows.length > 0,
|
||||
(resultSet) =>
|
||||
resultSet.t === "RawResultSet" && resultSet.rows.length > 0,
|
||||
);
|
||||
const numberOfResults = resultSet && renderResultCountString(resultSet);
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ export class ResultsApp extends React.Component<
|
||||
}
|
||||
sortStates={displayedResults.results.sortStates}
|
||||
interpretedSortState={
|
||||
data?.t == "SarifInterpretationData" ? data.sortState : undefined
|
||||
data?.t === "SarifInterpretationData" ? data.sortState : undefined
|
||||
}
|
||||
isLoadingNewResults={
|
||||
this.state.isExpectingResultsUpdate ||
|
||||
|
||||
@@ -130,7 +130,7 @@ const canSelect = (
|
||||
status: VariantAnalysisRepoStatus | undefined,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus | undefined,
|
||||
) =>
|
||||
status == VariantAnalysisRepoStatus.Succeeded &&
|
||||
status === VariantAnalysisRepoStatus.Succeeded &&
|
||||
downloadStatus === VariantAnalysisScannedRepositoryDownloadStatus.Succeeded;
|
||||
|
||||
const isExpandableContentLoaded = (
|
||||
|
||||
@@ -125,7 +125,7 @@ describe("serialize and deserialize", () => {
|
||||
}
|
||||
});
|
||||
expectedHistory.forEach((info) => {
|
||||
if (info.t == "local" && info.completedQuery) {
|
||||
if (info.t === "local" && info.completedQuery) {
|
||||
(info.completedQuery as any).dispose = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user