From f5bfff80b70104cbadeb221a5cb5537ae83042f1 Mon Sep 17 00:00:00 2001 From: landaiqing Date: Wed, 24 Sep 2025 21:44:42 +0800 Subject: [PATCH] :rotating_light: Format code --- frontend/eslint.config.js | 6 +- .../common/prettier/plugins/dart/dart_fmt.mjs | 8 +- .../common/prettier/plugins/docker/index.ts | 61 +++--- .../src/common/prettier/plugins/go/index.ts | 2 +- .../common/prettier/plugins/groovy/index.ts | 2 +- .../plugins/java/printers/helpers.d.ts | 2 +- .../common/prettier/plugins/lua/lua_fmt.d.ts | 2 +- .../prettier/plugins/lua/lua_fmt_bg.wasm.d.ts | 2 +- .../prettier/plugins/python/ruff_fmt.d.ts | 2 +- .../plugins/python/ruff_fmt_bg.wasm.d.ts | 2 +- .../prettier/plugins/rust/rust_fmt.d.ts | 2 +- .../plugins/rust/rust_fmt_bg.wasm.d.ts | 2 +- .../prettier/plugins/shell/wasm_exec.d.cts | 4 +- .../common/prettier/plugins/sql/sql_fmt.d.ts | 2 +- .../prettier/plugins/sql/sql_fmt_bg.wasm.d.ts | 2 +- .../common/prettier/plugins/toml/printer.ts | 11 +- .../src/common/prettier/plugins/web/index.ts | 2 +- .../common/prettier/plugins/web/web_fmt.d.ts | 2 +- .../prettier/plugins/web/web_fmt_bg.wasm.d.ts | 2 +- .../src/components/monitor/MemoryMonitor.vue | 2 +- .../src/components/titlebar/MacOSTitleBar.vue | 10 +- .../components/toolbar/DocumentSelector.vue | 4 +- frontend/src/router/index.ts | 2 +- frontend/src/stores/backupStore.ts | 112 +++++------ frontend/src/stores/configStore.ts | 6 +- frontend/src/stores/documentStore.ts | 2 +- frontend/src/stores/extensionStore.ts | 30 +-- frontend/src/stores/keybindingStore.ts | 50 +++-- frontend/src/stores/systemStore.ts | 2 +- frontend/src/stores/translationStore.ts | 2 +- frontend/src/stores/updateStore.ts | 120 ++++++------ .../editor/contextMenu/contextMenuView.ts | 2 +- .../src/views/editor/contextMenu/index.ts | 8 - .../views/editor/extensions/checkbox/index.ts | 124 ++++++------- .../editor/extensions/codeblock/commands.ts | 10 +- .../editor/extensions/codeblock/copyPaste.ts | 10 +- .../extensions/codeblock/decorations.ts | 10 +- .../editor/extensions/codeblock/deleteLine.ts | 8 +- .../editor/extensions/codeblock/formatCode.ts | 72 ++++---- .../codeblock/lang-parser/codeblock-lang.ts | 4 +- .../codeblock/lang-parser/languages.ts | 22 +-- .../codeblock/lang-parser/nested-parser.ts | 4 +- .../editor/extensions/codeblock/mathBlock.ts | 12 +- .../editor/extensions/codeblock/moveLines.ts | 28 +-- .../editor/extensions/codeblock/selectAll.ts | 6 +- .../extensions/codeblock/transposeChars.ts | 10 +- .../editor/extensions/colorSelector/index.ts | 2 +- .../editor/extensions/fold/foldExtension.ts | 26 +-- .../editor/extensions/hyperlink/index.ts | 4 +- .../views/editor/extensions/minimap/config.ts | 2 +- .../editor/extensions/minimap/gutters.ts | 2 +- .../views/editor/extensions/minimap/index.ts | 2 +- .../editor/extensions/minimap/linesState.ts | 8 +- .../editor/extensions/minimap/selections.ts | 2 +- .../textHighlight/textHighlightExtension.ts | 2 +- .../vscodeSearch/FindReplaceControl.ts | 92 ++++----- .../extensions/vscodeSearch/commands.ts | 50 ++--- .../editor/extensions/vscodeSearch/index.ts | 4 +- .../editor/extensions/vscodeSearch/plugin.ts | 14 +- .../editor/extensions/vscodeSearch/state.ts | 2 +- .../editor/extensions/vscodeSearch/theme.ts | 4 +- .../editor/extensions/vscodeSearch/utility.ts | 2 +- .../views/editor/keymap/commandRegistry.ts | 46 ++--- frontend/src/views/editor/keymap/index.ts | 46 ++--- .../src/views/editor/keymap/keymapManager.ts | 56 +++--- frontend/src/views/editor/keymap/types.ts | 2 +- .../views/editor/manager/ExtensionManager.ts | 174 +++++++++--------- .../src/views/editor/manager/factories.ts | 134 +++++++------- frontend/src/views/editor/manager/index.ts | 46 ++--- .../views/settings/pages/AppearancePage.vue | 5 - .../src/views/settings/pages/BackupPage.vue | 2 +- .../views/settings/pages/ExtensionsPage.vue | 95 +++++----- .../src/views/settings/pages/GeneralPage.vue | 2 +- .../src/views/settings/pages/TestPage.vue | 80 ++++---- .../src/views/settings/pages/UpdatesPage.vue | 2 +- frontend/vite.config.ts | 4 +- 76 files changed, 839 insertions(+), 863 deletions(-) diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index edcf609..1fa3fb0 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -50,7 +50,11 @@ export default defineConfig([ '.local', '/bin', 'Dockerfile', - '**/bindings/' + '**/bindings/', + '*.js', + '**/*.js', + '**/*.cjs', + '**/*.mjs', ], } ]); \ No newline at end of file diff --git a/frontend/src/common/prettier/plugins/dart/dart_fmt.mjs b/frontend/src/common/prettier/plugins/dart/dart_fmt.mjs index 31f9f9c..7734b25 100644 --- a/frontend/src/common/prettier/plugins/dart/dart_fmt.mjs +++ b/frontend/src/common/prettier/plugins/dart/dart_fmt.mjs @@ -78,7 +78,7 @@ _69: () => { _70: () => { return typeof process != "undefined" && Object.prototype.toString.call(process) == "[object process]" && - process.platform == "win32" + process.platform == "win32"; }, _85: s => JSON.stringify(s), _86: s => printToConsole(s), @@ -126,7 +126,7 @@ _157: Function.prototype.call.bind(DataView.prototype.setFloat32), _158: Function.prototype.call.bind(DataView.prototype.getFloat64), _159: Function.prototype.call.bind(DataView.prototype.setFloat64), _165: x0 => format = x0, -_166: f => finalizeWrapper(f, function(x0,x1,x2) { return dartInstance.exports._166(f,arguments.length,x0,x1,x2) }), +_166: f => finalizeWrapper(f, function(x0,x1,x2) { return dartInstance.exports._166(f,arguments.length,x0,x1,x2); }), _184: (c) => queueMicrotask(() => dartInstance.exports.$invokeCallback(c)), _187: (s, m) => { @@ -337,14 +337,14 @@ _272: (x0,x1) => x0.lastIndex = x1 }); return dartInstance; -} +}; // Call the main function for the instantiated module // `moduleInstance` is the instantiated dart2wasm module // `args` are any arguments that should be passed into the main function. export const invoke = (moduleInstance, ...args) => { moduleInstance.exports.$invokeMain(args); -} +}; export let format; \ No newline at end of file diff --git a/frontend/src/common/prettier/plugins/docker/index.ts b/frontend/src/common/prettier/plugins/docker/index.ts index 8a1a39b..cf59533 100644 --- a/frontend/src/common/prettier/plugins/docker/index.ts +++ b/frontend/src/common/prettier/plugins/docker/index.ts @@ -1,5 +1,5 @@ -import type { Plugin, SupportLanguage, Parser, Printer, SupportOption } from 'prettier' -import dockerfileInit, { format } from './docker_fmt_vite.js' +import type { Plugin, SupportLanguage, Parser, Printer, SupportOption } from 'prettier'; +import dockerfileInit, { format } from './docker_fmt_vite.js'; // Language configuration for Dockerfile const languages: SupportLanguage[] = [ @@ -11,7 +11,7 @@ const languages: SupportLanguage[] = [ linguistLanguageId: 99, vscodeLanguageIds: ['dockerfile'], }, -] +]; // Parser configuration const parsers: Record> = { @@ -19,69 +19,60 @@ const parsers: Record> = { parse: (text: string) => { // For Dockerfile, we don't need complex parsing, just return the text // The formatting will be handled by the print function - return { type: 'dockerfile', value: text } + return { type: 'dockerfile', value: text }; }, astFormat: 'dockerfile', locStart: () => 0, locEnd: () => 0, }, -} +}; // Printer configuration const printers: Record> = { dockerfile: { // @ts-expect-error -- Support async printer like shell plugin async print(path: any, options: any) { - await ensureInitialized() - const text = path.getValue().value || path.getValue() + await ensureInitialized(); + const text = path.getValue().value || path.getValue(); try { const formatted = format(text, { indent: options.tabWidth || 2, trailingNewline: true, spaceRedirects: options.spaceRedirects !== false, - }) - return formatted + }); + return formatted; } catch (error) { - console.warn('Dockerfile formatting error:', error) - return text + console.warn('Dockerfile formatting error:', error); + return text; } }, }, -} +}; // WASM initialization -let isInitialized = false -let initPromise: Promise | null = null +let isInitialized = false; +let initPromise: Promise | null = null; async function ensureInitialized(): Promise { if (isInitialized) { - return Promise.resolve() + return Promise.resolve(); } if (!initPromise) { initPromise = (async () => { try { - await dockerfileInit() - isInitialized = true + await dockerfileInit(); + isInitialized = true; } catch (error) { - console.warn('Failed to initialize Dockerfile WASM module:', error) - initPromise = null - throw error + console.warn('Failed to initialize Dockerfile WASM module:', error); + initPromise = null; + throw error; } - })() + })(); } - return initPromise -} - -// Configuration mapping function -function mapOptionsToConfig(options: any) { - return { - indent: options.tabWidth || 2, - trailingNewline: options.insertFinalNewline !== false, - spaceRedirects: options.spaceRedirects !== false, - } + return initPromise; } // Plugin options @@ -92,7 +83,7 @@ const options: Record = { default: true, description: 'Add spaces around redirect operators', }, -} +}; // Plugin definition const plugin: Plugin = { @@ -105,7 +96,7 @@ const plugin: Plugin = { useTabs: false, spaceRedirects: true, }, -} +}; -export default plugin -export { languages, parsers, printers, options } \ No newline at end of file +export default plugin; +export { languages, parsers, printers, options }; \ No newline at end of file diff --git a/frontend/src/common/prettier/plugins/go/index.ts b/frontend/src/common/prettier/plugins/go/index.ts index 6812535..933723a 100644 --- a/frontend/src/common/prettier/plugins/go/index.ts +++ b/frontend/src/common/prettier/plugins/go/index.ts @@ -60,7 +60,7 @@ function initGofmt(): Promise { // Printer configuration const goPrinter: Printer = { // @ts-expect-error -- Support async printer like shell plugin - async print(path, options) { + async print(path, _options) { try { // Wait for initialization to complete await initGofmt(); diff --git a/frontend/src/common/prettier/plugins/groovy/index.ts b/frontend/src/common/prettier/plugins/groovy/index.ts index 4c9d964..dd1a5d6 100644 --- a/frontend/src/common/prettier/plugins/groovy/index.ts +++ b/frontend/src/common/prettier/plugins/groovy/index.ts @@ -39,7 +39,7 @@ const groovyPrinter: Printer = { return groovyBeautify(path.node, { width: options.printWidth || 80, }).trim(); - } catch (error) { + } catch (_error) { return path.node; } }, diff --git a/frontend/src/common/prettier/plugins/java/printers/helpers.d.ts b/frontend/src/common/prettier/plugins/java/printers/helpers.d.ts index c3eda0c..a270d5e 100644 --- a/frontend/src/common/prettier/plugins/java/printers/helpers.d.ts +++ b/frontend/src/common/prettier/plugins/java/printers/helpers.d.ts @@ -58,7 +58,7 @@ type ModifierNode = JavaNonTerminal & { annotation?: AnnotationCstNode[]; }; }; -type IsTuple = T extends [] ? true : T extends [infer First, ...infer Remain] ? IsTuple : false; +type IsTuple = T extends [] ? true : T extends [infer _First, ...infer Remain] ? IsTuple : false; type IndexProperties = IsTuple extends true ? Exclude["length"], T["length"]> : number; diff --git a/frontend/src/common/prettier/plugins/lua/lua_fmt.d.ts b/frontend/src/common/prettier/plugins/lua/lua_fmt.d.ts index 714a3cc..03c95ce 100644 --- a/frontend/src/common/prettier/plugins/lua/lua_fmt.d.ts +++ b/frontend/src/common/prettier/plugins/lua/lua_fmt.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export function format(input: string, filename: string, config?: Config): string; interface LayoutConfig { diff --git a/frontend/src/common/prettier/plugins/lua/lua_fmt_bg.wasm.d.ts b/frontend/src/common/prettier/plugins/lua/lua_fmt_bg.wasm.d.ts index ecdf7c3..bb56b93 100644 --- a/frontend/src/common/prettier/plugins/lua/lua_fmt_bg.wasm.d.ts +++ b/frontend/src/common/prettier/plugins/lua/lua_fmt_bg.wasm.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export const memory: WebAssembly.Memory; export const format: (a: number, b: number, c: number, d: number, e: number, f: number) => void; export const __wbindgen_export_0: (a: number, b: number) => number; diff --git a/frontend/src/common/prettier/plugins/python/ruff_fmt.d.ts b/frontend/src/common/prettier/plugins/python/ruff_fmt.d.ts index f04cb57..bc334d4 100644 --- a/frontend/src/common/prettier/plugins/python/ruff_fmt.d.ts +++ b/frontend/src/common/prettier/plugins/python/ruff_fmt.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export function format(input: string, path?: string, config?: Config): string; export interface Config { diff --git a/frontend/src/common/prettier/plugins/python/ruff_fmt_bg.wasm.d.ts b/frontend/src/common/prettier/plugins/python/ruff_fmt_bg.wasm.d.ts index ef4a4d1..aeddb51 100644 --- a/frontend/src/common/prettier/plugins/python/ruff_fmt_bg.wasm.d.ts +++ b/frontend/src/common/prettier/plugins/python/ruff_fmt_bg.wasm.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export const memory: WebAssembly.Memory; export const format: (a: number, b: number, c: number, d: number, e: number, f: number) => void; export const __wbindgen_export_0: (a: number, b: number) => number; diff --git a/frontend/src/common/prettier/plugins/rust/rust_fmt.d.ts b/frontend/src/common/prettier/plugins/rust/rust_fmt.d.ts index e7386a1..6137d56 100644 --- a/frontend/src/common/prettier/plugins/rust/rust_fmt.d.ts +++ b/frontend/src/common/prettier/plugins/rust/rust_fmt.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export function format(input: string, config?: Config | null): string; export interface Config { diff --git a/frontend/src/common/prettier/plugins/rust/rust_fmt_bg.wasm.d.ts b/frontend/src/common/prettier/plugins/rust/rust_fmt_bg.wasm.d.ts index 38ccf9a..08f414c 100644 --- a/frontend/src/common/prettier/plugins/rust/rust_fmt_bg.wasm.d.ts +++ b/frontend/src/common/prettier/plugins/rust/rust_fmt_bg.wasm.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export const memory: WebAssembly.Memory; export const format: (a: number, b: number, c: number, d: number) => void; export const __wbindgen_export_0: (a: number, b: number) => number; diff --git a/frontend/src/common/prettier/plugins/shell/wasm_exec.d.cts b/frontend/src/common/prettier/plugins/shell/wasm_exec.d.cts index 6f9c352..adc19ae 100644 --- a/frontend/src/common/prettier/plugins/shell/wasm_exec.d.cts +++ b/frontend/src/common/prettier/plugins/shell/wasm_exec.d.cts @@ -1,7 +1,7 @@ -import _fs from 'node:fs' +import _fs from 'node:fs'; declare global { namespace globalThis { - var fs: typeof _fs + let fs: typeof _fs; } } diff --git a/frontend/src/common/prettier/plugins/sql/sql_fmt.d.ts b/frontend/src/common/prettier/plugins/sql/sql_fmt.d.ts index 41efd3b..cb20464 100644 --- a/frontend/src/common/prettier/plugins/sql/sql_fmt.d.ts +++ b/frontend/src/common/prettier/plugins/sql/sql_fmt.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export function format(input: string, filename: string, config?: Config): string; interface LayoutConfig { diff --git a/frontend/src/common/prettier/plugins/sql/sql_fmt_bg.wasm.d.ts b/frontend/src/common/prettier/plugins/sql/sql_fmt_bg.wasm.d.ts index ecdf7c3..bb56b93 100644 --- a/frontend/src/common/prettier/plugins/sql/sql_fmt_bg.wasm.d.ts +++ b/frontend/src/common/prettier/plugins/sql/sql_fmt_bg.wasm.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export const memory: WebAssembly.Memory; export const format: (a: number, b: number, c: number, d: number, e: number, f: number) => void; export const __wbindgen_export_0: (a: number, b: number) => number; diff --git a/frontend/src/common/prettier/plugins/toml/printer.ts b/frontend/src/common/prettier/plugins/toml/printer.ts index 381b39a..a2c3e0f 100644 --- a/frontend/src/common/prettier/plugins/toml/printer.ts +++ b/frontend/src/common/prettier/plugins/toml/printer.ts @@ -23,7 +23,6 @@ import type { TomlDocument, TomlExpression, TomlKeyVal, - TomlComment, TomlContext } from './types'; @@ -221,11 +220,11 @@ class TomlBeautifierVisitor extends BaseTomlCstVisitor { } else { return this.visit(actualValueNode); } - } catch (error) { + } catch (_error) { // 如果getSingle失败,尝试直接处理children if (ctx.children) { // 处理不同类型的值 - for (const [childKey, childNodes] of Object.entries(ctx.children)) { + for (const [_childKey, childNodes] of Object.entries(ctx.children)) { if (Array.isArray(childNodes) && childNodes.length > 0) { const firstChild = childNodes[0]; @@ -385,14 +384,14 @@ class TomlBeautifierVisitor extends BaseTomlCstVisitor { /** * Visit newline (should not be called) */ - nl(ctx: any): never { + nl(_ctx: any): never { throw new Error('Should not get here!'); } /** * Visit comment newline (no-op) */ - commentNewline(ctx: any): void { + commentNewline(_ctx: any): void { // No operation needed } } @@ -407,7 +406,7 @@ const beautifierVisitor = new TomlBeautifierVisitor(); * @param print - Print function (unused in this implementation) * @returns Formatted document */ -export function print(path: AstPath, options?: any, print?: any): Doc { +export function print(path: AstPath, _options?: any, _print?: any): Doc { const cst = path.node as TomlDocument; return beautifierVisitor.visit(cst); } diff --git a/frontend/src/common/prettier/plugins/web/index.ts b/frontend/src/common/prettier/plugins/web/index.ts index c8adc20..424a6af 100644 --- a/frontend/src/common/prettier/plugins/web/index.ts +++ b/frontend/src/common/prettier/plugins/web/index.ts @@ -4,7 +4,7 @@ * This plugin provides support for formatting multiple web languages using the web_fmt WASM implementation. * web_fmt is a comprehensive formatter for web development supporting HTML, CSS, JavaScript, and JSON. */ -import type { Plugin, Parser, Printer, ParserOptions } from 'prettier'; +import type { Plugin, Parser, Printer } from 'prettier'; // Import the web_fmt WASM module import webInit, { format } from './web_fmt_vite.js'; diff --git a/frontend/src/common/prettier/plugins/web/web_fmt.d.ts b/frontend/src/common/prettier/plugins/web/web_fmt.d.ts index ecfc14a..878a96b 100644 --- a/frontend/src/common/prettier/plugins/web/web_fmt.d.ts +++ b/frontend/src/common/prettier/plugins/web/web_fmt.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export function format_json(src: string, config?: JsonConfig): string; export function format_markup(src: string, filename: string, config?: MarkupConfig): string; export function format_script(src: string, filename: string, config?: ScriptConfig): string; diff --git a/frontend/src/common/prettier/plugins/web/web_fmt_bg.wasm.d.ts b/frontend/src/common/prettier/plugins/web/web_fmt_bg.wasm.d.ts index f249126..bf55d67 100644 --- a/frontend/src/common/prettier/plugins/web/web_fmt_bg.wasm.d.ts +++ b/frontend/src/common/prettier/plugins/web/web_fmt_bg.wasm.d.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -/* eslint-disable */ + export const memory: WebAssembly.Memory; export const format_json: (a: number, b: number, c: number, d: number) => void; export const format_markup: (a: number, b: number, c: number, d: number, e: number, f: number) => void; diff --git a/frontend/src/components/monitor/MemoryMonitor.vue b/frontend/src/components/monitor/MemoryMonitor.vue index 583e3fa..3ee6b01 100644 --- a/frontend/src/components/monitor/MemoryMonitor.vue +++ b/frontend/src/components/monitor/MemoryMonitor.vue @@ -42,7 +42,7 @@ const withSilentErrorHandling = async ( ): Promise => { try { return await operation(); - } catch (error) { + } catch (_error) { // 静默处理错误,不输出到控制台 return fallback; } diff --git a/frontend/src/components/titlebar/MacOSTitleBar.vue b/frontend/src/components/titlebar/MacOSTitleBar.vue index ceb350e..80c02a3 100644 --- a/frontend/src/components/titlebar/MacOSTitleBar.vue +++ b/frontend/src/components/titlebar/MacOSTitleBar.vue @@ -50,7 +50,7 @@