mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)
This commit is contained in:
@@ -4,7 +4,7 @@ import { useEffect, useRef } from "react";
|
||||
|
||||
export type Monaco = typeof monaco;
|
||||
|
||||
type EditorProps = {
|
||||
interface EditorProps {
|
||||
/** Editor options */
|
||||
options: monaco.editor.IEditorOptions;
|
||||
/** Function to be ran prior to mounting editor */
|
||||
@@ -13,7 +13,7 @@ type EditorProps = {
|
||||
onMount: (editor: monaco.editor.IStandaloneCodeEditor) => void;
|
||||
/** Function to be ran every time the code is updated */
|
||||
onChange: (newCode?: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export function Editor({ options, beforeMount, onMount, onChange }: EditorProps) {
|
||||
const containerDiv = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export type WordWrapOptions = "on" | "off" | "bounded" | "wordWrapColumn";
|
||||
export type Options = {
|
||||
export interface Options {
|
||||
theme: string;
|
||||
insertSpaces: boolean;
|
||||
tabSize: number;
|
||||
@@ -9,4 +9,4 @@ export type Options = {
|
||||
fontLigatures: boolean;
|
||||
wordWrap: WordWrapOptions;
|
||||
vim: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -209,7 +209,10 @@ export function Root(props: IProps): React.ReactElement {
|
||||
MonacoVim.VimMode.Vim.mapCommand("gt", "action", "nextTabs", {}, { context: "normal" });
|
||||
MonacoVim.VimMode.Vim.mapCommand("gT", "action", "prevTabs", {}, { context: "normal" });
|
||||
editor.focus();
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
console.error("An error occurred while loading monaco-vim:");
|
||||
console.error(e);
|
||||
}
|
||||
} else if (!options.vim) {
|
||||
// When vim mode is disabled
|
||||
vimEditor?.dispose();
|
||||
@@ -422,7 +425,10 @@ export function Root(props: IProps): React.ReactElement {
|
||||
}
|
||||
try {
|
||||
infLoop(newCode);
|
||||
} catch (err) {}
|
||||
} catch (err) {
|
||||
console.error("An error occurred during infinite loop detection in the script editor:");
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
function saveScript(scriptToSave: OpenScript): void {
|
||||
@@ -449,7 +455,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
const cleanCode = currentScript.code.replace(/\s/g, "");
|
||||
const ns1 = "while(true){hack('n00dles');}";
|
||||
const ns2 = `exportasyncfunctionmain(ns){while(true){awaitns.hack('n00dles');}}`;
|
||||
if (cleanCode.indexOf(ns1) == -1 && cleanCode.indexOf(ns2) == -1) {
|
||||
if (!cleanCode.includes(ns1) && !cleanCode.includes(ns2)) {
|
||||
dialogBoxCreate("Please copy and paste the code from the tutorial!");
|
||||
return;
|
||||
}
|
||||
@@ -667,7 +673,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
{filteredOpenScripts.map(({ path: fileName, hostname }, index) => {
|
||||
const editingCurrentScript =
|
||||
currentScript?.path === filteredOpenScripts[index].path &&
|
||||
currentScript?.hostname === filteredOpenScripts[index].hostname;
|
||||
currentScript.hostname === filteredOpenScripts[index].hostname;
|
||||
const externalScript = hostname !== "home";
|
||||
const colorProps = editingCurrentScript
|
||||
? {
|
||||
|
||||
@@ -82,10 +82,10 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => {
|
||||
continue;
|
||||
}
|
||||
|
||||
const repairBlock = (block: { [key: string]: object | string }): void => {
|
||||
const repairBlock = (block: Record<string, object | string>): void => {
|
||||
for (const [k, v] of Object.entries(block)) {
|
||||
if (typeof v === "object") {
|
||||
repairBlock(v as { [key: string]: string });
|
||||
repairBlock(v as Record<string, string>);
|
||||
} else if (!v.match(colorRegExp)) block[k] = "FF0000";
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user