CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)

This commit is contained in:
Snarling
2023-05-05 03:55:59 -04:00
committed by GitHub
parent d25254caf1
commit ebae35b1fb
202 changed files with 905 additions and 1110 deletions
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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;
};
}
+10 -4
View File
@@ -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
? {
+2 -2
View File
@@ -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";
}
};