1.0.6 ⢠Published 1 year ago
@arabasta/eslint-plugin-report-caught-error v1.0.6
@arabasta/eslint-plugin-report-caught-error
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