Registry / web-framework / vite-plugin-stylelint

vite-plugin-stylelint

JSON →
library6.1.0jsnpmunverified

A Vite plugin that integrates Stylelint for linting CSS/SCSS/Less files during development and build. Current stable version 6.1.0, actively maintained with support for Vite 2–8 and Stylelint 13–17. Requires Node >=18. Key differentiator: runs linting in a worker thread for non-blocking performance, and automatically handles imported style files without extra file watchers (chokidar removed in v6). Ships TypeScript types and supports both ESM and CJS.

npm install vite-plugin-stylelint
INSTALL
IMPORT
SIG · VITE-PLUGIN-STYLEL
V
vite-plugin-stylelint
web-frameworkjavascriptv6.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stylelint
import stylelint from 'vite-plugin-stylelint'
import { stylelint } from 'vite-plugin-stylelint'
Default export only. Named export does not exist.
default
const stylelint = require('vite-plugin-stylelint').default
const stylelint = require('vite-plugin-stylelint')
In CJS, the default export is under .default. Direct require() returns an object with default property.
defineConfig
import { defineConfig } from 'vite'
defineConfig is from Vite, not this plugin. Common confusion.

Basic integration of vite-plugin-stylelint in Vite config with optional include/exclude patterns and lint-on-start disabled.

// vite.config.ts import { defineConfig } from 'vite'; import stylelint from 'vite-plugin-stylelint'; export default defineConfig({ plugins: [stylelint({ // Options (optional) include: ['src/**/*.css', 'src/**/*.scss'], exclude: ['node_modules'], lintOnStart: false, emitError: true, emitWarning: true, })], });
Debug
Known issues
breakingv6.0.0 removes chokidar and changes how imported style files are handled. Previously, chokidar watched files; now the plugin relies on Vite's module graph and transforms.
fix
Update your configuration: the 'chokidar' option no longer exists. If you relied on custom chokidar options, remove them.
affects: >=6.0.0
breakingThe peer dependency range expanded to include Vite 6, 7, 8 and Stylelint 17. If your project uses an older Vite or Stylelint, ensure compatibility.
fix
No action needed unless you pin an older version of the plugin.
affects: >=6.1.0
deprecatedUsing Stylelint v13 requires @types/stylelint and postcss as peer deps. Consider upgrading to Stylelint v14+ which removes these dependencies.
fix
Install @types/stylelint@^13 and postcss@^7 || ^8 as devDependencies if using Stylelint v13. Better yet, upgrade Stylelint.
affects: *
gotchaThe plugin does not install Stylelint for you. You must install it separately and configure it with a .stylelintrc file or similar.
fix
Run `npm install stylelint -D` and create a stylelint configuration file.
affects: *
gotchaThe plugin runs linting in a worker thread. If Stylelint instance is not initialized before calling lintFiles, you may see errors. This was fixed in v6.0.0.
fix
Upgrade to v6.0.0 or later.
affects: <6.0.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-stylelint' or its corresponding type declarations.
Missing installation of the package.
fix
Run `npm install vite-plugin-stylelint -D` and ensure it is in your devDependencies.
The requested module 'vite-plugin-stylelint' does not provide an export named 'stylelint'
Attempting named import instead of default import.
fix
Use `import stylelint from 'vite-plugin-stylelint'` (default import).
TypeError: stylelint is not a function
Trying to use the plugin without calling it as a function, or incorrectly importing it.
fix
Ensure you call the default export as a function in the plugins array: `stylelint()`.
Error: stylelint version must be >=13 and <=16
Using an incompatible version of Stylelint. Plugin supports v13–16 (v17 may also work but not officially tested).
fix
Install a compatible version: `npm install stylelint@^16 -D`.
Upgrade
Version history
6.1.0latest on npm
Audit
Dependencies
viterequiredrequired peer dependency
stylelintrequiredrequired peer dependency
@types/stylelintoptionalrequired for Stylelint v13 only
postcssoptionalrequired peer dependency for Stylelint v13/v14
rollupoptionaloptional peer dependency for custom build integration
rolldownoptionaloptional peer dependency for rolldown integration
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources