CODEBASE: Fix lint errors 3 (#1758)

This is a really big refactor because it actually *fixes* a lot of the lint errors instead of disabling them.
This commit is contained in:
catloversg
2024-11-14 23:18:57 +07:00
committed by GitHub
parent 97ca8c5f5e
commit 75cf9c88b5
31 changed files with 187 additions and 51 deletions
+1
View File
@@ -203,6 +203,7 @@ export class PlayerObject extends Person implements IPlayer {
// Remove any invalid jobs
for (const [loadedCompanyName, loadedJobName] of Object.entries(player.jobs)) {
if (!isMember("CompanyName", loadedCompanyName) || !isMember("JobName", loadedJobName)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete player.jobs[loadedCompanyName as CompanyName];
}
}
@@ -377,6 +377,7 @@ export function quitJob(this: PlayerObject, company: CompanyName, suppressDialog
}
}
}
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this.jobs[company];
}
@@ -10,6 +10,7 @@ import { scaleWorkStats } from "../../../Work/WorkStats";
import { getKeyList } from "../../../utils/helpers/getKeyList";
import { loadActionIdentifier } from "../../../Bladeburner/utils/loadActionIdentifier";
import { invalidWork } from "../../../Work/InvalidWork";
import { objectAssert } from "../../../utils/helpers/typeAssertion";
interface SleeveBladeburnerWorkParams {
actionId: ActionIdentifier & { type: BladeburnerActionType.General | BladeburnerActionType.Contract };
@@ -98,6 +99,7 @@ export class SleeveBladeburnerWork extends SleeveWorkClass {
/** Initializes a BladeburnerWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveBladeburnerWork {
objectAssert(value.data);
const actionId = loadActionIdentifier(value.data?.actionId);
if (!actionId) return invalidWork();
value.data.actionId = actionId;
@@ -7,6 +7,7 @@ import { Sleeve } from "../Sleeve";
import { scaleWorkStats, WorkStats } from "../../../Work/WorkStats";
import { Locations } from "../../../Locations/Locations";
import { isMember } from "../../../utils/EnumHelper";
import { objectAssert } from "../../../utils/helpers/typeAssertion";
export const isSleeveClassWork = (w: SleeveWorkClass | null): w is SleeveClassWork =>
w !== null && w.type === SleeveWorkType.CLASS;
@@ -54,8 +55,13 @@ export class SleeveClassWork extends SleeveWorkClass {
/** Initializes a ClassWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveClassWork {
if (!(value.data.classType in Classes)) value.data.classType = "Computer Science";
if (!(value.data.location in Locations)) value.data.location = LocationName.Sector12RothmanUniversity;
objectAssert(value.data);
if (typeof value.data.classType !== "string" || !(value.data.classType in Classes)) {
value.data.classType = "Computer Science";
}
if (typeof value.data.location !== "string" || !(value.data.location in Locations)) {
value.data.location = LocationName.Sector12RothmanUniversity;
}
return Generic_fromJSON(SleeveClassWork, value.data);
}
}