prevent using non-exhaustive pattern matching in typescript
npm install eslint-plugin-strict-pattern-matchingprevent using non-exhaustive pattern matching in typescript
You'll first need to install ESLint:
``sh`
npm i eslint --save-dev
Next, install eslint-plugin-strict-pattern-matching:
`sh`
npm eslint-plugin-strict-pattern-matching --save-dev
Add strict-pattern-matching to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
`json`
{
"plugins": [
"strict-pattern-matching"
]
}
Then configure the rules you want to use under the rules section.
`json`
{
"rules": {
"strict-pattern-matching/strictPatternMatching": 2
}
}
š§ Automatically fixable by the --fix` CLI option.
| Name | Description | š§ |
| :----------------------------------------------------------------------------- | :------------------------------------------------------ | :- |
| noUnhandledExhaustiveException | no unhandled exhaustive's exception in pattern matching | |
| strictPatternMatching | no unexhaustive pattern matching | š§ |