From 0089981f2acb84b581f650651d86dc4b38bae28b Mon Sep 17 00:00:00 2001 From: magic-akari Date: Wed, 29 May 2024 16:49:12 +0800 Subject: [PATCH] fix: lint issue --- src/index.tsx | 4 +++- src/swc-ast-parser.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 9819817..9f3b335 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,7 +14,9 @@ if (location.hash.startsWith("#code/")) { init_code = localStore.code; } -createRoot(document.getElementById("root")!).render( +declare const root: HTMLElement; + +createRoot(root).render( , diff --git a/src/swc-ast-parser.ts b/src/swc-ast-parser.ts index 291b492..171763e 100644 --- a/src/swc-ast-parser.ts +++ b/src/swc-ast-parser.ts @@ -42,8 +42,8 @@ export function parse_swc_ast(source: string): Section[] { const span_match = span_regex.exec(text); if (span_match) { // span: 7..8#2, - const lo = Number.parseInt(span_match[1]); - const hi = Number.parseInt(span_match[2]); + const lo = Number.parseInt(span_match[1], 10); + const hi = Number.parseInt(span_match[2], 10); const span: Span = { lo, hi }; span_stack.push({ span, level }); } @@ -53,7 +53,7 @@ export function parse_swc_ast(source: string): Section[] { } else if (text[0] === "}") { const top = section_stack.pop(); if (!top || top.type !== "start" || level !== top.level) { - throw Error("Invalid section"); + throw new Error("Invalid section"); } if (top.level !== level) {