ESLint rule for disallowing the switch statement
$ npm install --save-dev eslint eslint-plugin-no-switch-statements
Configure it in package.json
.
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"no-switch-statements"
],
"rules": {
"no-switch-statements/no-switch": "error"
}
}
}
- no-switch - prevent the usage of switch statements
This plugin exports a recommended
configuration that enforces good practices.
To enable this configuration, use the extends
property in your package.json
.
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"no-switch-statements"
],
"extends": "plugin:no-switch-statements/recommended"
}
}
See ESLint documentation for more information about extending configuration files.
MIT © Andreas Wiedel