eslint-plugin-clsx

raw JSON →
0.1.0 verified Sat Apr 25 auth: no javascript

ESLint plugin for clsx/classnames utility libraries providing 8 rules to enforce best practices and reduce redundant code. Current stable version 0.0.12 (0.1.0 available), active maintenance with regular releases. Supports ESLint 8, 9, and 10. Ships TypeScript types. Differentiators: auto-fixable rules, recommended and all presets, flat config support, settings for custom import names.

error Error: Failed to load plugin 'clsx': Cannot find module 'eslint-plugin-clsx'
cause Missing installation or incorrect module resolution
fix
npm install eslint-plugin-clsx --save-dev
error TypeError: Cannot read properties of undefined (reading 'recommended')
cause Attempting to access configs without proper import in flat config
fix
Use: import clsx from 'eslint-plugin-clsx'; then clsx.configs.flat.recommended
error Configuration for rule 'clsx/no-redundant-clsx' is invalid: severity must be 'off', 'warn', or 'error'.
cause Invalid severity level in rule configuration
fix
Set rule to 'off', 'warn', or 'error' (not boolean or string like 'true')
error ESLint configuration in .eslintrc.json is invalid: "extends": ["plugin:clsx/recommended"] is not a valid configuration.
cause Using legacy config syntax with ESLint 9+ flat config only project
fix
Switch to flat config format or ensure ESLint 8 compatibility
breaking v0.0.2 switched to TypeScript - existing CJS require may need update
fix Update to >=0.0.2 and use TypeScript or ensure CJS compatibility
breaking v0.0.7 cleanup published files - may break import paths if using deep imports
fix Use only top-level imports from 'eslint-plugin-clsx'
breaking v0.0.12 disallow extra properties in rule options - custom options may become invalid
fix Stick to documented options schema
gotcha Requires ESLint 8, 9, or 10 as peer dependency - not compatible with other versions
fix Install supported ESLint version
deprecated Legacy .eslintrc configs still work but flat configs are preferred for ESLint 9+
fix Migrate to flat config using clsx.configs.flat.recommended
npm install eslint-plugin-clsx
yarn add eslint-plugin-clsx
pnpm add eslint-plugin-clsx

Enable recommended rules with specific overrides in flat config format for ESLint 9+.

import clsx from 'eslint-plugin-clsx';
import { defineConfig } from 'eslint/config';

export default defineConfig({
  plugins: { clsx },
  rules: {
    'clsx/no-redundant-clsx': 'error',
    'clsx/forbid-array-expressions': 'warn',
    'clsx/forbid-false-inside-object-expressions': 'warn',
    'clsx/forbid-true-inside-object-expressions': 'warn',
    'clsx/no-spreading': 'warn',
    'clsx/prefer-merged-neighboring-elements': 'warn'
  }
});
// Also works with flat config preset:
// export default defineConfig(clsx.configs.flat.recommended);