Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-switch-statement

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-switch-statement

Rules for properly handling switch statements, including ensuring that appropriate exhaustive case handling.

  • 0.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
155
decreased by-71.19%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-exhaustive-switch

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

Installation

You'll first need to install ESLint and its dependency, espree:

npm i eslint espree --save-dev

Next, install eslint-plugin-exhaustive-switch. 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-exhaustive-switch --save-dev

Usage

Add exhaustive-switch to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["@ethanresnick/exhaustive-switch"]
}

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.
💭 Requires type information.

NameDescription🔧💭
require-appropriate-default-caserequire unreachable default case🔧💭

Keywords

FAQs

Package last updated on 31 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc