Require === and !== in Backend (#4086) Ferotiq

* eqeqeq in backend

* simplify
This commit is contained in:
Evan 2023-03-20 06:11:21 -05:00 committed by GitHub
parent 14da1438d9
commit 642e99331e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View file

@ -91,6 +91,12 @@
"sourceType": "module",
"project": "**/tsconfig.json"
}
},
{
"files": ["backend/**/*.ts"],
"rules": {
"eqeqeq": "error"
}
}
]
}

View file

@ -366,12 +366,8 @@ export async function addResult(
delete result.challenge;
}
let totalDurationTypedSeconds = 0;
let afk = result.afkDuration;
if (afk == undefined) {
afk = 0;
}
totalDurationTypedSeconds =
const afk = result.afkDuration ?? 0;
const totalDurationTypedSeconds =
result.testDuration + result.incompleteTestSeconds - afk;
updateTypingStats(uid, result.restartCount, totalDurationTypedSeconds);
PublicDAL.updateStats(result.restartCount, totalDurationTypedSeconds);

View file

@ -66,7 +66,7 @@ export async function add(
} else {
return { languageError: 1 };
}
if (duplicateId != -1) {
if (duplicateId !== -1) {
return { duplicateId, similarityScore };
}
await db.collection("new-quotes").insertOne(quote);

View file

@ -304,7 +304,7 @@ export async function removeTag(uid: string, _id: string): Promise<void> {
const user = await getUser(uid, "remove tag");
if (
user.tags === undefined ||
user.tags.filter((t) => t._id.toHexString() == _id).length === 0
user.tags.filter((t) => t._id.toHexString() === _id).length === 0
) {
throw new MonkeyError(404, "Tag not found");
}
@ -321,7 +321,7 @@ export async function removeTagPb(uid: string, _id: string): Promise<void> {
const user = await getUser(uid, "remove tag pb");
if (
user.tags === undefined ||
user.tags.filter((t) => t._id.toHexString() == _id).length === 0
user.tags.filter((t) => t._id.toHexString() === _id).length === 0
) {
throw new MonkeyError(404, "Tag not found");
}