CODEBASE: Fix lint errors 2 (#1756)

This commit is contained in:
catloversg
2024-11-07 14:09:11 +07:00
committed by GitHub
parent e3c10e9f0f
commit 36c143b687
48 changed files with 267 additions and 146 deletions
+4 -1
View File
@@ -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();
}
}
}
+3 -3
View File
@@ -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);
+7 -3
View File
@@ -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
+2 -2
View File
@@ -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();