mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 22:07:06 +02:00
CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)
This commit is contained in:
@@ -17,10 +17,10 @@ import Collapse from "@mui/material/Collapse";
|
||||
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||
import ExpandLess from "@mui/icons-material/ExpandLess";
|
||||
|
||||
type IProps = {
|
||||
interface IProps {
|
||||
aug: Augmentation;
|
||||
level?: number | string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export function AugmentationAccordion(props: IProps): React.ReactElement {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
@@ -37,7 +37,6 @@ import { ReputationRate } from "./ReputationRate";
|
||||
import { isCompanyWork } from "../../Work/CompanyWork";
|
||||
import { isCrimeWork } from "../../Work/CrimeWork";
|
||||
import { ActionIdentifier } from "../../Bladeburner/ActionIdentifier";
|
||||
import { Bladeburner } from "../../Bladeburner/Bladeburner";
|
||||
import { Skills } from "../../PersonObjects/Skills";
|
||||
import { calculateSkillProgress } from "../../PersonObjects/formulas/skill";
|
||||
import { EventEmitter } from "../../utils/EventEmitter";
|
||||
@@ -98,12 +97,12 @@ interface SkillBarProps {
|
||||
color?: string;
|
||||
}
|
||||
function SkillBar({ name, color }: SkillBarProps): React.ReactElement {
|
||||
const [mult, setMult] = useState(skillMultUpdaters[name]?.());
|
||||
const [mult, setMult] = useState(skillMultUpdaters[name]());
|
||||
const [progress, setProgress] = useState(calculateSkillProgress(Player.exp[skillNameMap[name]], mult));
|
||||
useEffect(() => {
|
||||
const clearSubscription = OverviewEventEmitter.subscribe(() => {
|
||||
setMult(skillMultUpdaters[name]());
|
||||
setProgress(calculateSkillProgress(Player.exp[skillNameMap[name] as keyof Skills], mult));
|
||||
setProgress(calculateSkillProgress(Player.exp[skillNameMap[name]], mult));
|
||||
});
|
||||
return clearSubscription;
|
||||
}, []);
|
||||
@@ -239,8 +238,9 @@ export function CharacterOverview({ parentOpen, save, killScripts }: OverviewPro
|
||||
}
|
||||
|
||||
function ActionText(props: { action: ActionIdentifier }): React.ReactElement {
|
||||
// This component should never be called if Bladeburner is null, due to conditional checks in BladeburnerText
|
||||
const action = (Player.bladeburner as Bladeburner).getTypeAndNameFromActionId(props.action);
|
||||
const bladeburner = Player.bladeburner;
|
||||
if (!bladeburner) return <></>;
|
||||
const action = bladeburner.getTypeAndNameFromActionId(props.action);
|
||||
return (
|
||||
<Typography>
|
||||
{action.type}: {action.name}
|
||||
|
||||
@@ -11,7 +11,7 @@ import Button from "@mui/material/Button";
|
||||
interface IProps {
|
||||
purchase: () => void;
|
||||
canPurchase: boolean;
|
||||
onChange: (event: SelectChangeEvent<string>) => void;
|
||||
onChange: (event: SelectChangeEvent) => void;
|
||||
value: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
|
||||
type IProps = {
|
||||
interface IProps {
|
||||
value: string;
|
||||
color?: string;
|
||||
variant?:
|
||||
@@ -21,7 +21,7 @@ type IProps = {
|
||||
| "overline"
|
||||
| "inherit"
|
||||
| undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export function CopyableText(props: IProps): React.ReactElement {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
@@ -161,7 +161,7 @@ function LogWindow(props: IProps): React.ReactElement {
|
||||
};
|
||||
|
||||
const setPosition = ({ x, y }: LogBoxPositionData) => {
|
||||
const node = rootRef?.current;
|
||||
const node = rootRef.current;
|
||||
if (!node) return;
|
||||
const state = node.state as { x: number; y: number };
|
||||
state.x = x;
|
||||
@@ -267,7 +267,7 @@ function LogWindow(props: IProps): React.ReactElement {
|
||||
}, []);
|
||||
|
||||
const onWindowResize = debounce((): void => {
|
||||
const node = draggableRef?.current;
|
||||
const node = draggableRef.current;
|
||||
if (!node) return;
|
||||
|
||||
if (!isOnScreen(node)) {
|
||||
|
||||
@@ -94,7 +94,7 @@ export function Overview({ children, mode }: IProps): React.ReactElement {
|
||||
}, []);
|
||||
|
||||
const fakeDrag = debounce((): void => {
|
||||
const node = draggableRef?.current;
|
||||
const node = draggableRef.current;
|
||||
if (!node) return;
|
||||
|
||||
// No official way to trigger an onChange to recompute the bounds
|
||||
|
||||
@@ -30,7 +30,7 @@ export function PromptManager(): React.ReactElement {
|
||||
|
||||
function close(): void {
|
||||
if (prompt === null) return;
|
||||
if (["text", "select"].includes(prompt?.options?.type ?? "")) {
|
||||
if (["text", "select"].includes(prompt.options?.type ?? "")) {
|
||||
prompt.resolve("");
|
||||
} else {
|
||||
prompt.resolve(false);
|
||||
@@ -38,14 +38,14 @@ export function PromptManager(): React.ReactElement {
|
||||
setPrompt(null);
|
||||
}
|
||||
|
||||
const types: { [key: string]: (props: IContentProps) => React.ReactElement } = {
|
||||
const types: Record<string, (props: IContentProps) => React.ReactElement> = {
|
||||
text: PromptMenuText,
|
||||
select: PromptMenuSelect,
|
||||
};
|
||||
|
||||
let PromptContent = PromptMenuBoolean;
|
||||
if (prompt?.options?.type && ["text", "select"].includes(prompt?.options?.type))
|
||||
PromptContent = types[prompt?.options?.type];
|
||||
if (prompt.options?.type && ["text", "select"].includes(prompt.options.type))
|
||||
PromptContent = types[prompt.options.type];
|
||||
const resolve = (value: boolean | string): void => {
|
||||
prompt.resolve(value);
|
||||
setPrompt(null);
|
||||
@@ -123,7 +123,7 @@ function PromptMenuSelect({ prompt, resolve }: IContentProps): React.ReactElemen
|
||||
|
||||
const submit = (): void => resolve(value);
|
||||
|
||||
const onChange = (event: SelectChangeEvent<string>): void => {
|
||||
const onChange = (event: SelectChangeEvent): void => {
|
||||
setValue(event.target.value);
|
||||
};
|
||||
|
||||
@@ -139,7 +139,7 @@ function PromptMenuSelect({ prompt, resolve }: IContentProps): React.ReactElemen
|
||||
return content;
|
||||
};
|
||||
|
||||
if (!Array.isArray(prompt?.options?.choices)) {
|
||||
if (!Array.isArray(prompt.options?.choices)) {
|
||||
return <Typography>Error: Please provide an array of string choices</Typography>;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ function PromptMenuSelect({ prompt, resolve }: IContentProps): React.ReactElemen
|
||||
<>
|
||||
<div style={{ display: "flex", alignItems: "center", paddingTop: "10px" }}>
|
||||
<Select onChange={onChange} value={value} style={{ flex: "1 0 auto" }}>
|
||||
{getItems(prompt?.options?.choices || [])}
|
||||
{getItems(prompt.options?.choices || [])}
|
||||
</Select>
|
||||
<Button onClick={submit} disabled={value === ""}>
|
||||
Confirm
|
||||
|
||||
@@ -25,7 +25,7 @@ interface IProps {
|
||||
purchase: () => void;
|
||||
canPurchase: boolean;
|
||||
serverType: number;
|
||||
onChange: (event: SelectChangeEvent<string>) => void;
|
||||
onChange: (event: SelectChangeEvent) => void;
|
||||
value: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ import Collapse from "@mui/material/Collapse";
|
||||
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||
import ExpandLess from "@mui/icons-material/ExpandLess";
|
||||
|
||||
type IProps = {
|
||||
interface IProps {
|
||||
level: number;
|
||||
sf: SourceFile;
|
||||
};
|
||||
}
|
||||
|
||||
export function SourceFileAccordion(props: IProps): React.ReactElement {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user