From e5e392b656ad87eb9dfc299e8de6c322d984f979 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 13 Nov 2022 21:02:23 -0600 Subject: [PATCH] Fix --- website/src/frontend-scripts/util.ts | 3 +-- website/src/playground/Playground.tsx | 5 +---- website/src/playground/tabs/DiagnosticsListTab.tsx | 6 +++--- website/src/playground/tabs/SettingsTab.tsx | 14 +++++++++++--- website/src/playground/workers/romeWorker.ts | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/website/src/frontend-scripts/util.ts b/website/src/frontend-scripts/util.ts index 81adefb1704..2b698e543f4 100644 --- a/website/src/frontend-scripts/util.ts +++ b/website/src/frontend-scripts/util.ts @@ -8,8 +8,7 @@ export const matchesDark: undefined | MediaQueryList = export function getCurrentTheme(): ThemeName { let currentScheme = window.localStorage.getItem("data-theme"); if (currentScheme == null) { - currentScheme = - matchesDark !== undefined && matchesDark.matches ? "dark" : "light"; + currentScheme = matchesDark?.matches ? "dark" : "light"; } return currentScheme === "dark" ? "dark" : "light"; } diff --git a/website/src/playground/Playground.tsx b/website/src/playground/Playground.tsx index d8f7a9a21c1..2c9f44d9d24 100644 --- a/website/src/playground/Playground.tsx +++ b/website/src/playground/Playground.tsx @@ -1,7 +1,4 @@ -import type { - PlaygroundProps, - RomeAstSyntacticData, -} from "./types"; +import type { PlaygroundProps, RomeAstSyntacticData } from "./types"; import type { ReactCodeMirrorRef } from "@uiw/react-codemirror"; import CodeMirror from "./CodeMirror"; import type { ViewUpdate } from "@codemirror/view"; diff --git a/website/src/playground/tabs/DiagnosticsListTab.tsx b/website/src/playground/tabs/DiagnosticsListTab.tsx index 17fe8528d6a..1267802289b 100644 --- a/website/src/playground/tabs/DiagnosticsListTab.tsx +++ b/website/src/playground/tabs/DiagnosticsListTab.tsx @@ -44,13 +44,13 @@ function renderDiagnosticMessage(diagnostic: Diagnostic) { function DiagnosticIcon({ severity }: { severity: Diagnostic["severity"] }) { switch (severity) { case "Information": - return ; + return Info; case "Warning": - return ; + return Warning; default: - return ; + return Error; } } diff --git a/website/src/playground/tabs/SettingsTab.tsx b/website/src/playground/tabs/SettingsTab.tsx index 9bdec3e5d2f..b99a17ad38a 100644 --- a/website/src/playground/tabs/SettingsTab.tsx +++ b/website/src/playground/tabs/SettingsTab.tsx @@ -82,11 +82,13 @@ export default function SettingsTab({ return state; } + const { [state.currentFile]: _, ...otherFiles } = state.files; + const files: PlaygroundState["files"] = { - ...state.files, + ...otherFiles, [newFilename]: state.files[state.currentFile]!, }; - delete files[state.currentFile]; + return { ...state, currentFile: newFilename, @@ -97,6 +99,7 @@ export default function SettingsTab({ function createFile(filename: string) { if ( + // rome-ignore lint(complexity/useSimplifiedLogicExpression): Not sure how else to do this !isScriptFilename(filename) && !isJSXFilename(filename) && !isTypeScriptFilename(filename) @@ -233,7 +236,11 @@ function FileViewItem({ onClick: () => void; }) { return ( -
  • +
  • {filename}
  • ); @@ -273,6 +280,7 @@ function NewFileInput({ return ( { syntax: { // Replace 4 spaced indentation with 2 // TODO replace this in Rome itself - ast: syntaxTree.ast.replace(/ /g, " "), + ast: syntaxTree.ast.replace(/ {4}/g, " "), cst: syntaxTree.cst, }, diagnostics: {