@arabasta/eslint-plugin-report-caught-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@arabasta/eslint-plugin-report-caught-error

NPM Version NPM License

ESLint plugin that enforces caught errors in try/catches to be reported.

Installation

Assuming you already have ESLint installed, run:

# npm
npm install --save-dev @arabasta/eslint-plugin-report-caught-error

# yarn
yarn add --dev @arabasta/eslint-plugin-report-caught-error

# pnpm
pnpm add --save-dev @arabasta/eslint-plugin-report-caught-error

Usage

Flat config (eslint.config.js)

// ...
import reportCaughtError from '@arabasta/eslint-plugin-report-caught-error';

export default [
  // ...
  reportCaughtError.configs.recommended,
];

Legacy config (.eslintrc)

{
  "extends": [
    // ...
    "plugin:@arabasta/report-caught-error/recommended-legacy"
  ]
}

Rules

✅ Set in the recommended configuration
💡 Manually fixable by editor suggestions

Rule Description 💡
report-caught-error Enforce that caught errors are reported 💡

report-caught-error

Options

This rule has a string option. The string should be your report function.

  • console.error (default)

For example, in order to configure your report function to be reportUnknownError, you can use the following configuration:

"@arabasta/report-caught-error/report-caught-error": [<severity>, "reportUnknownError"]

Examples of incorrect code for this rule:

try {
} catch (error) {
  foo();
}

Examples of correct code for this rule:

try {
} catch (error) {
  console.error(error);
  foo();
}

License

MIT

Package Sidebar

Install

npm i @arabasta/eslint-plugin-report-caught-error

Weekly Downloads

18

Version

1.0.5

License

MIT

Unpacked Size

11.5 kB

Total Files

6

Last publish

Collaborators

  • stoyan.a.kolev