The rule name may be called unicorn/try-maximum-statements
.
The idea is to avoid try
on whole code blocks and encourage the developer to target the exact line statement of code that is expecting to throw.
Should we add a parameter to customize the maximum number of line statement or hardcode it to 1 line of code? π€
Note that I'm not a native english speaker so please fix the rule/option names.
Applies to try
clauses.
The maximum number of triable lines statements of code configurable, but defaults to 1.
This rule is not fixable.
try {
doSomething();
doSomethingElse();
} catch (err) {
// β¦
}
try {
doSingleThing();
} catch (err) {
// β¦
}
maximumNumberOfStatement
Type: number
You can set the maximum number of statements like this:
"unicorn/try-maximum-statement": [
"error",
{
"maximumNumberOfStatement": 2
}
]
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too