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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import clsx from 'eslint-plugin-clsx'
✗ const clsx = require('eslint-plugin-clsx')
Default import is the plugin object. CJS require works but may lack type definitions.
configs.flat.recommended
✓ clsx.configs.flat.recommended
✗ clsx.configs.recommended
Use flat configs for ESLint 9+. Legacy configs available via plugin:clsx/recommended.
rules
✓ import { rules } from 'eslint-plugin-clsx'
✗ const rules = require('eslint-plugin-clsx').rules
Named export for accessing individual rule definitions.
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);
Errors
Common errors & fixes
Error: Failed to load plugin 'clsx': Cannot find module 'eslint-plugin-clsx'
Missing installation or incorrect module resolution
fixnpm install eslint-plugin-clsx --save-dev
TypeError: Cannot read properties of undefined (reading 'recommended')
Attempting to access configs without proper import in flat config
fixUse: import clsx from 'eslint-plugin-clsx'; then clsx.configs.flat.recommended
Configuration for rule 'clsx/no-redundant-clsx' is invalid: severity must be 'off', 'warn', or 'error'.
Invalid severity level in rule configuration
fixSet rule to 'off', 'warn', or 'error' (not boolean or string like 'true')
ESLint configuration in .eslintrc.json is invalid: "extends": ["plugin:clsx/recommended"] is not a valid configuration.
Using legacy config syntax with ESLint 9+ flat config only project
fixSwitch to flat config format or ensure ESLint 8 compatibility
Audit
Dependencies
eslintrequiredpeer dependency required to run