Registry / testing / eslint-plugin-switch-case

eslint-plugin-switch-case

JSON →
library4.0.0jsnpmunverified

An ESLint plugin providing switch-case-specific linting rules, including no-default-case, no-case-curly, and newline-between-switch-case. Current stable version is 4.0.0, released with support for ESLint ^9.8.0 or ^10.0.0 and Node.js ^20.19.0 || ^22.13.0 || >= 24. The plugin enforces stylistic and logic rules for switch statements, filling a niche not covered by ESLint core rules. It is maintained by lukeapage and is in active development.

npm install eslint-plugin-switch-case
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SWIT
E
eslint-plugin-switch-case
testingjavascriptv4.0.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.

plugin
import switchCase from 'eslint-plugin-switch-case'
const switchCase = require('eslint-plugin-switch-case')
Plugin is typically used in ESLint config as a string reference, not imported directly. Use 'switch-case' in plugins array.
rules
import { rules } from 'eslint-plugin-switch-case'
const { rules } = require('eslint-plugin-switch-case')
ESM-only since v4; CommonJS require may fail if package is not transpiled.
configs
import { configs } from 'eslint-plugin-switch-case'
import configs from 'eslint-plugin-switch-case/configs'
Configs are accessed via the configs export, not default import.

Sets up ESLint with the switch-case plugin using recommended config and custom rule overrides.

// .eslintrc.js module.exports = { plugins: ['switch-case'], extends: ['plugin:switch-case/recommended'], rules: { 'switch-case/no-case-curly': 'error', 'switch-case/newline-between-switch-case': ['error', 'always'], 'switch-case/no-default-case': 'error' } };
Debug
Known issues
breakingv4.0.0 drops support for ESLint <9.8.0 and Node <20.19.0.
fix
Upgrade ESLint to ^9.8.0 || ^10.0.0 and Node to ^20.19.0 || ^22.13.0 || >= 24.
affects: >=4.0.0
breakingv4.0.0 is ESM-only; CommonJS require('eslint-plugin-switch-case') may fail.
fix
Use import statements or ensure your project is configured for ESM.
affects: >=4.0.0
deprecatedThe plugin previously exported a default object; v4 uses named exports.
fix
Use import { rules, configs } from 'eslint-plugin-switch-case' instead of importing default.
affects: >=4.0.0
gotchaThe 'recommended' config enables all rules, which may be too strict for some projects.
fix
Manually select rules instead of extending recommended.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'eslint-plugin-switch-case'
ELSINT plugin not installed or misconfigured in plugins array.
fix
Run 'npm install eslint-plugin-switch-case --save-dev' and add 'switch-case' to plugins.
Failed to load config "plugin:switch-case/recommended"
Plugin not specified in plugins array before using config.
fix
Ensure plugins: ['switch-case'] is set in your ESLint config.
ESLint configuration error: The "switch-case" plugin does not support CommonJS. Use import() or ensure your project is ESM.
Using require() to load the plugin in a CommonJS context with v4.0.0.
fix
Switch to ESM or use dynamic import().
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
eslint-plugin-switch-case — npm install eslint-plugin-switch-case · libregistry