eslint-plugin-switch-statement
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

eslint-plugin-switch-statement

Rules for making switch/case expressions for union type values exhaustively checkable at compile time.

Installation

Install eslint-plugin-switch-statement. If you want to use the included assertUnreachable in your source code, make sure to save it as a dependency and not a devDependency.

npm install eslint-plugin-switch-statement --save-dev

Usage

import exhaustiveSwitch from "eslint-plugin-switch-statement";

// in your eslint flat config
{
  "plugins":  { "exhaustive-switch": exhaustiveSwitch }
}

Then configure the rule under the rules section.

{
  "rules": {
    "exhaustive-switch/require-unreachable-default-case": [
      2,
      { "unreachableDefaultCaseAssertionFunctionName": "assertNever" }
    ]
  }
}

Rules

🔧 Automatically fixable by the --fix CLI option.

Name Description 🔧
require-appropriate-default-case require unreachable default case 🔧

Package Sidebar

Install

npm i eslint-plugin-switch-statement

Weekly Downloads

4

Version

1.0.1

License

ISC

Unpacked Size

34.9 kB

Total Files

12

Last publish

Collaborators

  • ethanresnick