eslint-plugin-handle-errors
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

ESLint Plugin Handle Errors

npm

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 handleErrors from 'eslint-plugin-handle-errors';

export default [
    {
        ...handleErrors.configs['flat/recommended'],
        files: ['src/**'],
    },
];

Legacy config (.eslintrc)

{
    "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.

{
    "settings": {
        "handleErrors": {
            "loggerFunctions": [
                "console.error", 
                "console.warn", 
                "Sentry.captureException", 
                "logError"
            ]
        }
    }
}

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

Package Sidebar

Install

npm i eslint-plugin-handle-errors

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

62.7 kB

Total Files

9

Last publish

Collaborators

  • nodge