Vite Plugin Checker
vite-plugin-checker is a Vite plugin designed to offload various code health checks, such as TypeScript type checking, ESLint linting, Biome formatting/linting, Stylelint, Oxlint, and Vue-specific checks (VLS, vue-tsc), into a separate worker process. This architecture prevents these potentially time-consuming checks from blocking the main Vite development server, thereby improving HMR performance and overall developer experience. The current stable version is 0.13.0, with minor releases occurring frequently to add new features, support newer versions of linters, and address bug fixes. Its key differentiators include its multi-tool support, its use of worker threads for performance, and its integration with Vite's overlay for displaying issues. It's an essential tool for maintaining code quality in large Vite projects, especially those using TypeScript or Vue.js.
Common errors
-
Error: require() of ES Module ... is not supported. Instead change the require of ... to a dynamic import()
cause Attempting to use `require()` to import `vite-plugin-checker` in a CommonJS context.fixMigrate your Vite configuration file (`vite.config.js` or `vite.config.ts`) to use ES module syntax (`import ... from '...'`). Ensure `package.json` has `"type": "module"` if not using `.mjs` file extension. -
No ESLint output found. Please make sure ESLint is configured correctly.
cause ESLint is either not installed, not configured, or the `lintCommand` in `checker` options is incorrect or points to non-existent files.fixVerify ESLint is installed (`npm install -D eslint`). Check your `.eslintrc.*` configuration. Ensure the `lintCommand` in `vite-plugin-checker` accurately targets your source files (e.g., `eslint "./src/**/*.{js,jsx,ts,tsx,vue}"`). -
TypeScript checker is not running. Did you install `typescript`?
cause TypeScript is not installed in the project or `typescript: true` is enabled in checker options without a valid `tsconfig.json`.fixInstall TypeScript (`npm install -D typescript`). Ensure a `tsconfig.json` file exists in your project root with correct configuration. -
TypeError: Cannot read properties of undefined (reading 'Diagnostics') when using `vue-tsc`.
cause Incompatible versions of `vue-tsc` and `vite-plugin-checker`, or incorrect configuration for `vue-tsc`.fixEnsure `vue-tsc` is installed (`npm install -D vue-tsc`). Check the `peerDependencies` of `vite-plugin-checker` for compatible `vue-tsc` versions. Try enabling `vueTsc: true` in the checker options. -
ERROR: Failed to load config "prettier" from "eslint-config-prettier"
cause A common issue where ESLint or other linters cannot find their required configurations or plugins, often due to missing installations or incorrect paths.fixEnsure all ESLint/Stylelint/Biome configurations and their respective plugins are correctly installed as dev dependencies. For example, `npm install -D eslint-config-prettier` if that's the missing piece. Double-check your config files (`.eslintrc`, `.stylelintrc`, `biome.json`) for correct `extends` paths.
Warnings
- breaking The plugin dropped support for CommonJS (CJS) usage. Projects must use ES Modules (ESM) for importing and configuring the plugin.
- breaking The internal dependency `strip-ansi` was replaced with Node's built-in functionality. While this is unlikely to directly break user code, it signals an internal refactor that might have subtle impacts or require specific Node.js versions.
- gotcha Requires specific versions of peer dependencies like `@biomejs/biome`, `eslint`, `stylelint`, `typescript`, `vite`, `vue-tsc`, etc. Mismatched versions can lead to errors or the checker not functioning correctly.
- breaking Upgrade to `chokidar v4` introduced potential breaking changes due to how file watching is handled. This might affect performance or specific watch configurations.
- gotcha ESLint v10.x introduced breaking changes. While `vite-plugin-checker` adds support for ESLint v10.x, older configurations or ESLint plugins might not be compatible.
Install
-
npm install vite-plugin-checker -
yarn add vite-plugin-checker -
pnpm add vite-plugin-checker
Imports
- checker
const checker = require('vite-plugin-checker')import { checker } from 'vite-plugin-checker' - UserConfig
import type { UserConfig } from 'vite' - CheckerOptions
import { CheckerOptions } from 'vite-plugin-checker'import type { CheckerOptions } from 'vite-plugin-checker'
Quickstart
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { checker } from 'vite-plugin-checker';
export default defineConfig({
plugins: [
vue(),
checker({
typescript: true, // Enable TypeScript type checking
eslint: {
lintCommand: 'eslint "./src/**/*.{js,jsx,ts,tsx,vue}"', // ESLint command
},
// biome: {
// lintCommand: 'biome check --write --no-errors-on-unmatched --files-ignore-unknown=true .',
// },
// stylelint: {
// lintCommand: 'stylelint "./src/**/*.{css,scss,vue}"',
// },
// vueTsc: true, // Enable vue-tsc if using Vue 3
}),
],
server: {
// Optional: Configure the server to display overlay for errors
overlay: {
initialIsOpen: false,
// Make sure the checker overlay doesn't conflict with Vite's own overlay
},
},
});