From 27a6b619ebddd2eec08224edd5f07d474c8ea2ab Mon Sep 17 00:00:00 2001 From: omuretsu <84951833+Snarling@users.noreply.github.com> Date: Tue, 16 May 2023 11:41:55 -0400 Subject: [PATCH] Lint fix Also reduce unnecessary imports --- src/ScriptEditor/ui/Editor.tsx | 2 -- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 5 ++--- src/ScriptEditor/ui/themes.ts | 18 +++++++++--------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/ScriptEditor/ui/Editor.tsx b/src/ScriptEditor/ui/Editor.tsx index 79e1fe137..538294da0 100644 --- a/src/ScriptEditor/ui/Editor.tsx +++ b/src/ScriptEditor/ui/Editor.tsx @@ -2,8 +2,6 @@ import * as monaco from "monaco-editor"; import * as React from "react"; import { useEffect, useRef } from "react"; -export type Monaco = typeof monaco; - interface EditorProps { /** Editor options */ options: monaco.editor.IEditorOptions; diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index 4b3511995..b5365ee1d 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -1,11 +1,10 @@ import React, { useState, useEffect, useRef } from "react"; -import { Editor, Monaco } from "./Editor"; +import { Editor } from "./Editor"; import * as monaco from "monaco-editor"; // @ts-expect-error This library does not have types. import * as MonacoVim from "monaco-vim"; type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor; -type EditorDecorations = monaco.editor.IEditorDecorationsCollection; type ITextModel = monaco.editor.ITextModel; import { OptionsModal } from "./OptionsModal"; import { Options } from "./Options"; @@ -321,7 +320,7 @@ export function Root(props: IProps): React.ReactElement { const source = (libSource + "").replace(/export /g, ""); monaco.languages.typescript.javascriptDefaults.addExtraLib(source, "netscript.d.ts"); monaco.languages.typescript.typescriptDefaults.addExtraLib(source, "netscript.d.ts"); - loadThemes(monaco); + loadThemes(monaco.editor.defineTheme); sanitizeTheme(Settings.EditorTheme); monaco.editor.defineTheme("customTheme", makeTheme(Settings.EditorTheme)); } diff --git a/src/ScriptEditor/ui/themes.ts b/src/ScriptEditor/ui/themes.ts index 625321398..b9cee6d8a 100644 --- a/src/ScriptEditor/ui/themes.ts +++ b/src/ScriptEditor/ui/themes.ts @@ -1,5 +1,5 @@ -import * as monaco from "monaco-editor"; -import type { Monaco } from "./Editor"; +import type { editor } from "monaco-editor"; +type DefineThemeFn = typeof editor.defineTheme; export interface IScriptEditorTheme { base: "vs" | "vs-dark" | "hc-black"; @@ -93,7 +93,7 @@ export const sanitizeTheme = (theme: IScriptEditorTheme): void => { } }; -export function makeTheme(theme: IScriptEditorTheme): monaco.editor.IStandaloneThemeData { +export function makeTheme(theme: IScriptEditorTheme): editor.IStandaloneThemeData { const themeRules = [ { token: "", @@ -208,8 +208,8 @@ export function makeTheme(theme: IScriptEditorTheme): monaco.editor.IStandaloneT return { base: theme.base, inherit: theme.inherit, rules: themeRules, colors: themeColors }; } -export async function loadThemes(monaco: Monaco): Promise { - monaco.editor.defineTheme("monokai", { +export async function loadThemes(defineTheme: DefineThemeFn): Promise { + defineTheme("monokai", { base: "vs-dark", inherit: true, rules: [ @@ -274,7 +274,7 @@ export async function loadThemes(monaco: Monaco): Promise { }, }); - monaco.editor.defineTheme("solarized-dark", { + defineTheme("solarized-dark", { base: "vs-dark", inherit: true, rules: [ @@ -351,7 +351,7 @@ export async function loadThemes(monaco: Monaco): Promise { }, }); - monaco.editor.defineTheme("solarized-light", { + defineTheme("solarized-light", { base: "vs", inherit: true, rules: [ @@ -429,7 +429,7 @@ export async function loadThemes(monaco: Monaco): Promise { }, }); - monaco.editor.defineTheme("dracula", { + defineTheme("dracula", { base: "vs-dark", inherit: true, rules: [ @@ -525,7 +525,7 @@ export async function loadThemes(monaco: Monaco): Promise { }, }); - monaco.editor.defineTheme("one-dark", { + defineTheme("one-dark", { base: "vs-dark", inherit: true, rules: [