ESLint plugin that enforces caught errors in try/catches to be reported.
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
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"
]
}
✅ Set in the recommended
configuration
💡 Manually fixable by editor suggestions
Rule | Description | ✅ | 💡 |
---|---|---|---|
report-caught-error | Enforce that caught errors are reported | ✅ | 💡 |
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();
}
MIT