Skip to content

Kaishiyoku/eslint-plugin-no-switch-statements

Repository files navigation

eslint-plugin-no-switch-statements

Build Status npm version

ESLint rule for disallowing the switch statement

Install

$ npm install --save-dev eslint eslint-plugin-no-switch-statements

Usage

Configure it in package.json.

{
  "name": "my-awesome-project",
  "eslintConfig": {
    "plugins": [
      "no-switch-statements"
    ],
    "rules": {
      "no-switch-statements/no-switch": "error"
    }
  }
}

Rules

  • no-switch - prevent the usage of switch statements

Recommended configuration

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