ESLint rules for handling errors.
npm
npm install -D eslint-plugin-handle-errorsYarn
yarn add -D eslint-plugin-handle-errorspnpm
pnpm add -D eslint-plugin-handle-errorsFlat 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"]
}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,
];✅ 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 | ✅ |