Skip to content

Commit

Permalink
enable eqeqeq lint rule for internal
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Feb 20, 2025
1 parent 664d50f commit 70dcce9
Show file tree
Hide file tree
Showing 126 changed files with 550 additions and 491 deletions.
1 change: 1 addition & 0 deletions .dlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"include": [
"ban-untagged-todo",
"camelcase",
"eqeqeq",
"no-console",
"guard-for-in"
],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function handleMatrixItems(items: {
// use a free "ubuntu" runner on jobs that are skipped

// skip_pr is shorthand for skip = github.event_name == 'pull_request'.
if (item.skip_pr != null) {
if (item.skip_pr !== undefined) {
if (item.skip_pr === true) {
item.skip = "${{ github.event_name == 'pull_request' }}";
} else if (typeof item.skip_pr === "string") {
Expand Down
2 changes: 1 addition & 1 deletion cli/js/40_jupyter.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ function enableJupyter() {
evalue: err.message,
traceback: [],
});
} else if (typeof err == "string") {
} else if (typeof err === "string") {
await broadcast("error", {
ename: "Error",
evalue: err,
Expand Down
8 changes: 6 additions & 2 deletions cli/js/40_lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,12 @@ export class Context {
* @param {Deno.lint.ReportData} data
*/
report(data) {
const range = data.node ? data.node.range : data.range ? data.range : null;
if (range == null) {
const range = data.node
? data.node.range
: data.range
? data.range
: undefined;
if (range === undefined) {
throw new Error(
"Either `node` or `range` must be provided when reporting an error",
);
Expand Down
22 changes: 11 additions & 11 deletions cli/js/40_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ function wrapInner(fn) {
function getRunningStepDescs() {
const results = [];
let childDesc = desc;
while (childDesc.parent != null) {
while (childDesc.parent !== undefined) {
const state = MapPrototypeGet(testStates, childDesc.parent.id);
for (const siblingDesc of state.children) {
if (siblingDesc.id == childDesc.id) {
if (siblingDesc.id === childDesc.id) {
continue;
}
const siblingState = MapPrototypeGet(testStates, siblingDesc.id);
Expand Down Expand Up @@ -188,7 +188,7 @@ function wrapInner(fn) {
failedSteps++;
}
}
return failedSteps == 0 ? null : { failed: { failedSteps } };
return failedSteps === 0 ? null : { failed: { failedSteps } };
};
}

Expand Down Expand Up @@ -229,12 +229,12 @@ function testInner(
if (!maybeFn || typeof maybeFn !== "function") {
throw new TypeError("Missing test function");
}
if (optionsOrFn.fn != undefined) {
if (optionsOrFn.fn !== undefined && optionsOrFn.fn !== null) {
throw new TypeError(
"Unexpected 'fn' field in options, test function is already provided as the third argument",
);
}
if (optionsOrFn.name != undefined) {
if (optionsOrFn.name !== undefined && optionsOrFn.name !== null) {
throw new TypeError(
"Unexpected 'name' field in options, test name is already provided as the first argument",
);
Expand All @@ -250,10 +250,10 @@ function testInner(
if (!nameOrFnOrOptions.name) {
throw new TypeError("The test function must have a name");
}
if (optionsOrFn != undefined) {
if (optionsOrFn !== undefined && optionsOrFn !== null) {
throw new TypeError("Unexpected second argument to Deno.test()");
}
if (maybeFn != undefined) {
if (maybeFn !== undefined && maybeFn !== null) {
throw new TypeError("Unexpected third argument to Deno.test()");
}
testDesc = {
Expand All @@ -266,7 +266,7 @@ function testInner(
let name;
if (typeof optionsOrFn === "function") {
fn = optionsOrFn;
if (nameOrFnOrOptions.fn != undefined) {
if (nameOrFnOrOptions.fn !== undefined || nameOrFnOrOptions.fn !== null) {
throw new TypeError(
"Unexpected 'fn' field in options, test function is already provided as the second argument",
);
Expand Down Expand Up @@ -294,7 +294,7 @@ function testInner(
// Delete this prop in case the user passed it. It's used to detect steps.
delete testDesc.parent;

if (cachedOrigin == undefined) {
if (cachedOrigin === undefined) {
cachedOrigin = op_test_get_origin();
}

Expand Down Expand Up @@ -425,7 +425,7 @@ function createTestContext(desc) {
if (!nameOrFnOrOptions.name) {
throw new TypeError("The step function must have a name");
}
if (maybeFn != undefined) {
if (maybeFn !== undefined || maybeFn !== null) {
throw new TypeError(
"Unexpected second argument to TestContext.step()",
);
Expand Down Expand Up @@ -482,7 +482,7 @@ function createTestContext(desc) {
const elapsed = DateNow() - earlier;
state.failed = !!result.failed;
stepReportResult(stepDesc, result, elapsed);
return result == "ok";
return result === "ok";
},
};
}
Expand Down
11 changes: 6 additions & 5 deletions cli/tsc/97_ts_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const unstableMsgSuggestion =
* @returns {value is ts.CreateSourceFileOptions}
*/
function isCreateSourceFileOptions(value) {
return value != null && typeof value === "object" &&
return value !== null && typeof value === "object" &&
"languageVersion" in value;
}

Expand Down Expand Up @@ -177,7 +177,7 @@ export const LAST_REQUEST_SCOPE = {
ts.deno.setIsNodeSourceFileCallback((sourceFile) => {
const fileName = sourceFile.fileName;
let isNodeSourceFile = IS_NODE_SOURCE_FILE_CACHE.get(fileName);
if (isNodeSourceFile == null) {
if (isNodeSourceFile === undefined) {
const result = ops.op_is_node_file(fileName);
isNodeSourceFile = /** @type {boolean} */ (result);
IS_NODE_SOURCE_FILE_CACHE.set(fileName, isNodeSourceFile);
Expand Down Expand Up @@ -482,7 +482,7 @@ const hostImpl = {
}
const { data, scriptKind, version, isCjs } = fileInfo;
assert(
data != null,
data !== undefined && data !== null,
`"data" is unexpectedly null for "${specifier}".`,
);

Expand Down Expand Up @@ -559,7 +559,8 @@ const hostImpl = {
}
: arg;
return [
fileReference.resolutionMode == null
(fileReference.resolutionMode === undefined &&
fileReference.resolutionMode === null)
? isCjs
: fileReference.resolutionMode === ts.ModuleKind.CommonJS,
fileReference.fileName,
Expand Down Expand Up @@ -719,7 +720,7 @@ const hostImpl = {
}
}
let scriptSnapshot = SCRIPT_SNAPSHOT_CACHE.get(specifier);
if (scriptSnapshot == undefined) {
if (scriptSnapshot === undefined) {
/** @type {{ data: string, version: string, isCjs: boolean }} */
const fileInfo = ops.op_load(specifier);
if (!fileInfo) {
Expand Down
4 changes: 2 additions & 2 deletions cli/tsc/98_lsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const documentRegistry = {
SOURCE_REF_COUNTS.delete(path);
// We call `cleanupSemanticCache` for other purposes, don't bust the
// source cache in this case.
if (LAST_REQUEST_METHOD.get() != "cleanupSemanticCache") {
if (LAST_REQUEST_METHOD.get() !== "cleanupSemanticCache") {
const mapKey = path + key;
documentRegistrySourceFileCache.delete(mapKey);
SCRIPT_SNAPSHOT_CACHE.delete(path);
Expand Down Expand Up @@ -497,7 +497,7 @@ function serverRequestInner(id, method, args, scope, maybeChange) {
if (typeof ls[method] === "function") {
// The `getCompletionEntryDetails()` method returns null if the
// `source` is `null` for whatever reason. It must be `undefined`.
if (method == "getCompletionEntryDetails") {
if (method === "getCompletionEntryDetails") {
args[4] ??= undefined;
}
try {
Expand Down
8 changes: 4 additions & 4 deletions cli/tsc/99_main_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function performanceProgram({ program, fileCount }) {
stats.push(["Symbols", program.getSymbolCount()]);
stats.push(["Types", program.getTypeCount()]);
stats.push(["Instantiations", program.getInstantiationCount()]);
} else if (fileCount != null) {
} else if (fileCount !== undefined && fileCount !== null) {
stats.push(["Files", fileCount]);
}
const programTime = ts.performance.getDuration("Program");
Expand Down Expand Up @@ -162,7 +162,7 @@ function exec({ config, debug: debugFlag, rootNames, localOnly }) {
continue;
}
const sourceFile = program.getSourceFile(checkName);
if (sourceFile != null) {
if (sourceFile !== undefined && sourceFile !== null) {
checkFiles.push(sourceFile);
}
checkFileNames.add(checkName);
Expand All @@ -184,14 +184,14 @@ function exec({ config, debug: debugFlag, rootNames, localOnly }) {

const diagnostics = [
...program.getConfigFileParsingDiagnostics(),
...(checkFiles == null
...(checkFiles === undefined || checkFiles === null
? program.getSyntacticDiagnostics()
: ts.sortAndDeduplicateDiagnostics(
checkFiles.map((s) => program.getSyntacticDiagnostics(s)).flat(),
)),
...program.getOptionsDiagnostics(),
...program.getGlobalDiagnostics(),
...(checkFiles == null
...(checkFiles === undefined || checkFiles === null
? program.getSemanticDiagnostics()
: ts.sortAndDeduplicateDiagnostics(
checkFiles.map((s) => program.getSemanticDiagnostics(s)).flat(),
Expand Down
Loading

0 comments on commit 70dcce9

Please sign in to comment.