{"id":20685,"library":"vite-plugin-stylelint","title":"vite-plugin-stylelint","description":"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.","status":"active","version":"6.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/ModyQyW/vite-plugin-stylelint","tags":["javascript","stylelint","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-stylelint","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-stylelint","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-stylelint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required peer dependency","package":"vite","optional":false},{"reason":"required peer dependency","package":"stylelint","optional":false},{"reason":"required for Stylelint v13 only","package":"@types/stylelint","optional":true},{"reason":"required peer dependency for Stylelint v13/v14","package":"postcss","optional":true},{"reason":"optional peer dependency for custom build integration","package":"rollup","optional":true},{"reason":"optional peer dependency for rolldown integration","package":"rolldown","optional":true}],"imports":[{"note":"Default export only. Named export does not exist.","wrong":"import { stylelint } from 'vite-plugin-stylelint'","symbol":"stylelint","correct":"import stylelint from 'vite-plugin-stylelint'"},{"note":"In CJS, the default export is under .default. Direct require() returns an object with default property.","wrong":"const stylelint = require('vite-plugin-stylelint')","symbol":"default","correct":"const stylelint = require('vite-plugin-stylelint').default"},{"note":"defineConfig is from Vite, not this plugin. Common confusion.","wrong":null,"symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport stylelint from 'vite-plugin-stylelint';\n\nexport default defineConfig({\n  plugins: [stylelint({\n    // Options (optional)\n    include: ['src/**/*.css', 'src/**/*.scss'],\n    exclude: ['node_modules'],\n    lintOnStart: false,\n    emitError: true,\n    emitWarning: true,\n  })],\n});","lang":"typescript","description":"Basic integration of vite-plugin-stylelint in Vite config with optional include/exclude patterns and lint-on-start disabled."},"warnings":[{"fix":"Update your configuration: the 'chokidar' option no longer exists. If you relied on custom chokidar options, remove them.","message":"v6.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.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"No action needed unless you pin an older version of the plugin.","message":"The peer dependency range expanded to include Vite 6, 7, 8 and Stylelint 17. If your project uses an older Vite or Stylelint, ensure compatibility.","severity":"breaking","affected_versions":">=6.1.0"},{"fix":"Install @types/stylelint@^13 and postcss@^7 || ^8 as devDependencies if using Stylelint v13. Better yet, upgrade Stylelint.","message":"Using Stylelint v13 requires @types/stylelint and postcss as peer deps. Consider upgrading to Stylelint v14+ which removes these dependencies.","severity":"deprecated","affected_versions":"*"},{"fix":"Run `npm install stylelint -D` and create a stylelint configuration file.","message":"The plugin does not install Stylelint for you. You must install it separately and configure it with a .stylelintrc file or similar.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to v6.0.0 or later.","message":"The 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.","severity":"gotcha","affected_versions":"<6.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install vite-plugin-stylelint -D` and ensure it is in your devDependencies.","cause":"Missing installation of the package.","error":"Cannot find module 'vite-plugin-stylelint' or its corresponding type declarations."},{"fix":"Use `import stylelint from 'vite-plugin-stylelint'` (default import).","cause":"Attempting named import instead of default import.","error":"The requested module 'vite-plugin-stylelint' does not provide an export named 'stylelint'"},{"fix":"Ensure you call the default export as a function in the plugins array: `stylelint()`.","cause":"Trying to use the plugin without calling it as a function, or incorrectly importing it.","error":"TypeError: stylelint is not a function"},{"fix":"Install a compatible version: `npm install stylelint@^16 -D`.","cause":"Using an incompatible version of Stylelint. Plugin supports v13–16 (v17 may also work but not officially tested).","error":"Error: stylelint version must be >=13 and <=16"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}