mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 07:07:50 +02:00
CODEBASE: Fix lint errors 2 (#1756)
This commit is contained in:
@@ -21,6 +21,9 @@ export function check(args: (string | number | boolean)[], server: BaseServer):
|
||||
Terminal.error(`No script named ${scriptName} is running on the server`);
|
||||
return;
|
||||
}
|
||||
runningScripts.values().next().value.displayLog();
|
||||
const next = runningScripts.values().next();
|
||||
if (!next.done) {
|
||||
next.value.displayLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ export function expr(args: (string | number | boolean)[]): void {
|
||||
|
||||
// Sanitize the math expression
|
||||
const sanitizedExpr = expr.replace(/[^-()\d/*+.%]/g, "");
|
||||
let result;
|
||||
let result: string;
|
||||
try {
|
||||
result = eval?.(sanitizedExpr);
|
||||
result = String(eval?.(sanitizedExpr));
|
||||
} catch (e) {
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}`);
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}. Error: ${e}.`);
|
||||
return;
|
||||
}
|
||||
Terminal.print(result);
|
||||
|
||||
@@ -86,7 +86,7 @@ export function TerminalInput(): React.ReactElement {
|
||||
function getSearchSuggestionPrespace() {
|
||||
const currentPrefix = `[${Player.getCurrentServer().hostname} /${Terminal.cwd()}]> `;
|
||||
const prefixLength = `${currentPrefix}${value}`.length;
|
||||
return Array(prefixLength).fill(" ");
|
||||
return Array<string>(prefixLength).fill(" ");
|
||||
}
|
||||
|
||||
function modifyInput(mod: Modification): void {
|
||||
@@ -206,7 +206,7 @@ export function TerminalInput(): React.ReactElement {
|
||||
return () => document.removeEventListener("keydown", keyDown);
|
||||
});
|
||||
|
||||
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> {
|
||||
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): Promise<void> {
|
||||
const ref = terminalInput.current;
|
||||
|
||||
// Run command or insert newline
|
||||
@@ -427,7 +427,11 @@ export function TerminalInput(): React.ReactElement {
|
||||
setPossibilities([]);
|
||||
resetSearch();
|
||||
},
|
||||
onKeyDown: onKeyDown,
|
||||
onKeyDown: (event) => {
|
||||
onKeyDown(event).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
}}
|
||||
></TextField>
|
||||
<Popper
|
||||
|
||||
@@ -41,7 +41,7 @@ export function TerminalRoot(): React.ReactElement {
|
||||
const [key, setKey] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const debounced = _.debounce(async () => rerender(), 25, { maxWait: 50 });
|
||||
const debounced = _.debounce(() => rerender(), 25, { maxWait: 50 });
|
||||
const unsubscribe = TerminalEvents.subscribe(debounced);
|
||||
return () => {
|
||||
debounced.cancel();
|
||||
@@ -51,7 +51,7 @@ export function TerminalRoot(): React.ReactElement {
|
||||
|
||||
useEffect(() => {
|
||||
const clear = () => setKey((key) => key + 1);
|
||||
const debounced = _.debounce(async () => clear(), 25, { maxWait: 50 });
|
||||
const debounced = _.debounce(() => clear(), 25, { maxWait: 50 });
|
||||
const unsubscribe = TerminalClearEvents.subscribe(debounced);
|
||||
return () => {
|
||||
debounced.cancel();
|
||||
|
||||
Reference in New Issue
Block a user