{"id":25140,"library":"css-modules-lint","title":"css-modules-lint","description":"Lint, autocomplete, and generate types for CSS Modules. Version 1.0.3 runs on Node >=20 and supports TypeScript, Vite, and ESLint. Includes a TypeScript Language Service Plugin for real-time diagnostics, Vite plugin for automatic .d.ts generation, and an ESLint plugin with undefined/unused class rules. Differentiators include unified tooling for both type generation and linting, CLI for CI integration, and support for SCSS, CSS, and Less modules.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript","plugin","css-modules","scss","lint"],"install":[{"cmd":"npm install css-modules-lint","lang":"bash","label":"npm"},{"cmd":"yarn add css-modules-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add css-modules-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for TypeScript plugin and types","package":"typescript","optional":false},{"reason":"peer dependency for ESLint plugin","package":"eslint","optional":true},{"reason":"peer dependency for Vite plugin","package":"vite","optional":true}],"imports":[{"note":"ESM-only; ESLint >=9 flat config required","wrong":"const cssModulesLint = require('css-modules-lint/eslint')","symbol":"cssModulesLint (ESLint plugin)","correct":"import cssModulesLint from 'css-modules-lint/eslint'"},{"note":"Default export from 'css-modules-lint/vite', not named","wrong":"import { cssModulesDts } from 'css-modules-lint/vite'","symbol":"cssModulesDts (Vite plugin)","correct":"import cssModulesDts from 'css-modules-lint/vite'"},{"note":"Not a JS import; configured in tsconfig.json","wrong":"{ \"plugins\": [{ \"name\": \"css-modules-lint/typescript\" }] }","symbol":"TypeScript plugin","correct":"{ \"plugins\": [{ \"name\": \"css-modules-lint\" }] }"}],"quickstart":{"code":"// Install\nnpm install -D css-modules-lint\n\n// Automatic setup\nnpx css-modules-lint init\n\n// Or manual setup:\n// 1. tsconfig.json\n{\n  \"compilerOptions\": {\n    \"plugins\": [{ \"name\": \"css-modules-lint\" }]\n  }\n}\n\n// 2. Vite plugin (optional)\n// vite.config.ts\nimport cssModulesDts from 'css-modules-lint/vite';\nexport default defineConfig({\n  plugins: [cssModulesDts()],\n});\n\n// 3. ESLint plugin (optional)\n// eslint.config.js\nimport cssModulesLint from 'css-modules-lint/eslint';\nexport default [cssModulesLint.configs.recommended];\n\n// 4. .gitignore\n*.module.scss.d.ts\n*.module.css.d.ts\n*.module.less.d.ts\n\n// 5. CI script\n\"scripts\": {\n  \"lint:css\": \"css-modules-lint check\"\n}\n\n// Run\nnpx css-modules-lint check\nnpx css-modules-lint generate","lang":"typescript","description":"Full setup with init command, manual configurations for TypeScript, Vite, ESLint, .gitignore, and CI script."},"warnings":[{"fix":"Update Node, TypeScript, ESLint, or Vite to the required versions.","message":"Peer dependencies: requires Node >=20, TypeScript >=5, ESLint >=9, and Vite >=4","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Migrate ESLint config to flat config and use ESM imports (e.g., import cssModulesLint from 'css-modules-lint/eslint').","message":"ESLint plugin uses flat config only (ESLint >=9) and ESM imports","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"After adding plugin to tsconfig.json, reload the TypeScript language server (e.g., VS Code: Ctrl+Shift+P -> TypeScript: Reload Project).","message":"TypeScript plugin must be configured in tsconfig.json and editor's TypeScript language server must be restarted for changes to take effect","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Prefer using the Vite plugin cssModulesDts() for automatic generation during dev/build; CLI generate is still valid for CI.","message":"CLI 'generate' command for .d.ts generation is superseded by Vite plugin for development workflows","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Add *.module.scss.d.ts, *.module.css.d.ts, *.module.less.d.ts to .gitignore.","message":"Generated .d.ts files should be gitignored to avoid conflicts; they are regenerated by Vite plugin or CLI","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import statement: import cssModulesLint from 'css-modules-lint/eslint'; and ensure package.json has \"type\": \"module\" or file extension .mjs.","cause":"Using CommonJS require() instead of ESM import","error":"Error: Cannot find module 'css-modules-lint/eslint'"},{"fix":"Ensure tsconfig.json has: \"plugins\": [{ \"name\": \"css-modules-lint\" }] (not 'css-modules-lint/typescript' or other paths).","cause":"Plugin name not correctly specified in tsconfig.json","error":"Cannot start TypeScript LSP: No registered language service plugin 'css-modules-lint'"},{"fix":"Upgrade to ESLint >=9 and use eslint.config.js with import syntax.","cause":"ESLint config still using legacy .eslintrc format but package requires flat config","error":"Parsing error: The keyword 'import' is reserved"},{"fix":"Change import to: import cssModulesDts from 'css-modules-lint/vite'; (not named import).","cause":"Importing named export instead of default from 'css-modules-lint/vite'","error":"TypeError: cssModulesDts is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}