From 41557cd1ff78fb44f65b07ad8dfdda4b7397744d Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 1 Nov 2026 15:54:56 -0500 Subject: [PATCH] chore(dev): scope and quiet the lint checker `vite-plugin-checker` logs `[oxlint] Found 0 error and 0 warning` after every lint run, clean or not, so each save during `pnpm dev` printed a line that reported nothing. Its `dev.logLevel` only filters diagnostics, so drop the clean summary from a custom dev-server logger. Errors and their summaries still print. The checker also watched its root, which includes output that dev rewrites constantly: `build/` on every Electron rebuild and the GraphQL generated modules on every codegen run. Neither is linted, so those runs only burned CPU. Limit the watcher to the linted sources and root config files; the startup run still lints the whole project. --- vite.config.mts | 57 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/vite.config.mts b/vite.config.mts index bb3b88c85..9e1184cb8 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -9,13 +9,42 @@ import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; import checker from 'vite-plugin-checker'; import electron from 'vite-plugin-electron/simple'; -import type { Plugin } from 'vite-plus'; -import { defineConfig } from 'vite-plus'; +import type { Logger, Plugin } from 'vite-plus'; +import { createLogger, defineConfig } from 'vite-plus'; import { Constants } from './src/renderer/constants.ts'; const projectRoot = fileURLToPath(new URL('.', import.meta.url)); +/** + * Lint summary `vite-plugin-checker` emits after a run that found nothing. + * + * The plugin logs a summary after *every* lint run, clean or not, so each file + * save during `pnpm dev` prints a line that reports nothing. Its `dev.logLevel` + * only filters diagnostics, not this summary, so we match the message text. + */ +const cleanLintSummaryPattern = /\[oxlint\] Found 0 error and 0 warning/; + +/** + * Dev-server logger that drops clean lint summaries from `vite-plugin-checker`. + * + * Diagnostics and summaries for runs that found something still pass through. + */ +const createDevLogger = (): Logger => { + const base = createLogger(); + + return { + ...base, + info(message, options) { + if (cleanLintSummaryPattern.test(message)) { + return; + } + + base.info(message, options); + }, + }; +}; + const packageJson = JSON.parse( fs.readFileSync(fileURLToPath(new URL('package.json', import.meta.url)), 'utf8'), ) as { dependencies?: Record }; @@ -210,6 +239,8 @@ const storeBarrelBoundaryPattern = { }; export default defineConfig({ + // Keep the dev output to real problems: see `createDevLogger` above. + customLogger: createDevLogger(), plugins: [ // only run the checker plugin in dev (not during `vite build`) ...(isBuild @@ -222,7 +253,27 @@ export default defineConfig({ root: projectRoot, // `vp lint` applies the `lint` config below. A bare `oxlint` binary // is not installed, and it would ignore that config anyway. - oxlint: { lintCommand: 'vp lint', dev: { logLevel: ['error'] } }, + oxlint: { + lintCommand: 'vp lint', + // The checker watches its root, which would include output that + // dev rewrites constantly: `build/` on every Electron rebuild and + // the GraphQL generated modules on every codegen run. Neither is + // linted, so those runs only burn CPU. The startup run still lints + // the whole project, so new root-level files only need adding here + // to be re-linted during a session. + watchPath: [ + 'src', + 'scripts', + 'codegen.ts', + 'electron-builder.js', + 'graphql.config.ts', + 'i18next.config.ts', + 'tailwind.config.mts', + 'vite.config.mts', + 'vitest.config.mts', + ], + dev: { logLevel: ['error'] }, + }, }), ]), reactDevToolsPlugin(),