From 644db48d17ac9f6f8881a70e699c027e5452f87a Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 23 Jul 2026 13:36:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(lint):=20=E4=BF=AE=E5=A4=8D=20Biome=20?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mermaid-renderer/src/index.ts: import 与后续语句间补空行(organizeImports) - tiptap-editor footnote.test.ts: 局部 unescape 重命名为 unescapeFootnote, 避免遮蔽全局 restricted name(noShadowRestrictedNames) --- libs/mermaid-renderer/src/index.ts | 1 + libs/tiptap-editor/src/__tests__/footnote.test.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/mermaid-renderer/src/index.ts b/libs/mermaid-renderer/src/index.ts index 95f1780..ab3f95f 100644 --- a/libs/mermaid-renderer/src/index.ts +++ b/libs/mermaid-renderer/src/index.ts @@ -5,6 +5,7 @@ // 直接赋给 window.MermaidRenderer 作为构建时副作用,使 window.MermaidRenderer // 本身即 mermaid API(initialize/render)。 import mermaid from 'mermaid'; + // 构建时副作用:把 mermaid 挂到全局。ES module 的顶层赋值会被 vite 保留。 (globalThis as unknown as { MermaidRenderer: typeof mermaid }).MermaidRenderer = mermaid; diff --git a/libs/tiptap-editor/src/__tests__/footnote.test.ts b/libs/tiptap-editor/src/__tests__/footnote.test.ts index 3504907..7f0152d 100644 --- a/libs/tiptap-editor/src/__tests__/footnote.test.ts +++ b/libs/tiptap-editor/src/__tests__/footnote.test.ts @@ -16,7 +16,7 @@ import { beforeEach, describe, expect, it } from 'vitest'; */ const UNESCAPE_RE = /\\\[\^([^\n\\]*?)\\\]/g; -const unescape = (md: string) => md.replace(UNESCAPE_RE, '[^$1]'); +const unescapeFootnote = (md: string) => md.replace(UNESCAPE_RE, '[^$1]'); function makeEditor() { return new Editor({ @@ -41,31 +41,31 @@ describe('脚注语法 - escapeMarkdownSyntax 破坏与修复', () => { }); it('unescape 正则还原脚注引用 \\[^1\\] → [^1]', () => { - expect(unescape('\\[^1\\]')).toBe('[^1]'); + expect(unescapeFootnote('\\[^1\\]')).toBe('[^1]'); }); it('unescape 正则还原含空格的脚注 label', () => { - expect(unescape('\\[^my note\\]')).toBe('[^my note]'); + expect(unescapeFootnote('\\[^my note\\]')).toBe('[^my note]'); }); it('unescape 正则还原脚注定义 \\[^1\\]: → [^1]:', () => { - expect(unescape('\\[^1\\]: 定义内容')).toBe('[^1]: 定义内容'); + expect(unescapeFootnote('\\[^1\\]: 定义内容')).toBe('[^1]: 定义内容'); }); it('unescape 正则不影响普通链接 [text](url)', () => { const md = '\\[text\\](https://example.com)'; // 普通链接的 \[text\] 不以 ^ 开头,不会被误改 - expect(unescape(md)).toBe(md); + expect(unescapeFootnote(md)).toBe(md); }); it('unescape 正则一次处理多个脚注引用', () => { const md = '引用了\\[^1\\]和\\[^pc\\]和\\[^2\\]'; - expect(unescape(md)).toBe('引用了[^1]和[^pc]和[^2]'); + expect(unescapeFootnote(md)).toBe('引用了[^1]和[^pc]和[^2]'); }); it('完整往返:unescape(getMarkdown()) 保留脚注引用语法', () => { editor.commands.setContent('正文[^1]', { contentType: 'markdown' }); - const fixed = unescape(editor.getMarkdown()); + const fixed = unescapeFootnote(editor.getMarkdown()); expect(fixed).toContain('[^1]'); expect(fixed).not.toContain('\\[^1\\]'); });