-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,80 @@ | ||
# eslint-plugin-handle-errors | ||
# ESLint Plugin Handle Errors | ||
|
||
ESLint rules for handling errors | ||
[![npm](https://img.shields.io/npm/v/eslint-plugin-handle-errors)](https://www.npmjs.com/package/eslint-plugin-handle-errors) | ||
|
||
ESLint rules for handling errors. | ||
|
||
## Installation | ||
|
||
npm | ||
|
||
```bash | ||
npm install -D eslint-plugin-handle-errors | ||
``` | ||
|
||
Yarn | ||
|
||
```bash | ||
yarn add -D eslint-plugin-handle-errors | ||
``` | ||
|
||
pnpm | ||
|
||
```bash | ||
pnpm add -D eslint-plugin-handle-errors | ||
``` | ||
|
||
## Usage | ||
|
||
[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) | ||
(**eslint.config.js**) | ||
|
||
```javascript | ||
import handleErrors from 'eslint-plugin-handle-errors'; | ||
|
||
export default [ | ||
{ | ||
...handleErrors.configs['flat/recommended'], | ||
files: ['src/**'], | ||
}, | ||
]; | ||
``` | ||
|
||
[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files) | ||
(**.eslintrc**) | ||
|
||
```json | ||
{ | ||
"extends": ["plugin:handle-errors/recommended"], | ||
"plugins": ["handle-errors"] | ||
} | ||
``` | ||
|
||
## Settings | ||
|
||
### Logger functions | ||
|
||
You can customize the logger functions that are used to log errors in your project. | ||
|
||
```json | ||
{ | ||
"settings": { | ||
"handle-errors": { | ||
"loggerFunctions": ["console.error", "console.warn", "Sentry.captureException", "logError"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Rules | ||
|
||
✅ Set in the `recommended` configuration\ | ||
🔧 Automatically fixable by the [`--fix`](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) | ||
CLI option\ | ||
💡 Manually fixable by | ||
[editor suggestions](https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions) | ||
|
||
| Rule | Description | ✅ | 🔧 | 💡 | | ||
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | :-: | :-: | :-: | | ||
| [log-error-in-trycatch](https://github.com/Nodge/eslint-plugin-handle-errors/blob/main/src/rules/log-error-in-trycatch.ts) | Enforce error logging in Try-Catch blocks | ✅ | | | | ||
| [log-error-in-promises](https://github.com/Nodge/eslint-plugin-handle-errors/blob/main/src/rules/log-error-in-promises.ts) | Enforces error logging in Promise.catch handlers | ✅ | | | |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters