0.3.1 ⢠Published 12 months ago
eslint-plugin-handle-errors v0.3.1
ESLint Plugin Handle Errors
ESLint rules for handling errors.
Installation
npm
npm install -D eslint-plugin-handle-errors
Yarn
yarn add -D eslint-plugin-handle-errors
pnpm
pnpm add -D eslint-plugin-handle-errors
Usage
Flat config (eslint.config.js)
import eslint from '@eslint/js';
import handleErrors from 'eslint-plugin-handle-errors';
export default [
eslint.configs.recommended, // optional
handleErrors.configs.recommended,
];
Legacy config (.eslintrc)
{
"extends": ["plugin:handle-errors/legacy-recommended"]
}
Settings
Logger functions
You can customize the logger functions that are used to log errors in your project.
import eslint from '@eslint/js';
import handleErrors from 'eslint-plugin-handle-errors';
export default [
{
settings: {
handleErrors: {
loggerFunctions: ['Sentry.captureException', 'reportError'],
},
},
},
eslint.configs.recommended,
handleErrors.configs.recommended,
];
Rules
ā
Set in the recommended
configuration\
š§ Automatically fixable by the --fix
CLI option\
š” Manually fixable by
editor suggestions
Rule | Description | ā | š§ | š” |
---|---|---|---|---|
log-error-in-trycatch | Enforce error logging in Try-Catch blocks | ā | ||
log-error-in-promises | Enforces error logging in Promise.catch handlers | ā |