The ESLint implementation of the rule has a maximumStatements parameter (set to 1 by default), which skips the analysis if the number of statements inside the block does not exceed maximumStatements.
https://github.com/regru/eslint-plugin-prefer-early-return
We can also add an ignore-if-case parameter, similar to DCM (https://dcm.dev/docs/rules/common/prefer-early-return/#example-with-ignore-if-case), to ignore the rule for the if-case case.
I suggest adding these parameters to the prefer_early_return rule (maximum_statements: 1 and ignore_if_case: true by default).
We could also consider extending the rule to apply to loop bodies:
so instead of
for ... {
if ... {
a
b
...
}
}
it will propose
for ... {
if !... continue;
a
b
}
The ESLint implementation of the rule has a maximumStatements parameter (set to 1 by default), which skips the analysis if the number of statements inside the block does not exceed maximumStatements.
https://github.com/regru/eslint-plugin-prefer-early-return
We can also add an ignore-if-case parameter, similar to DCM (https://dcm.dev/docs/rules/common/prefer-early-return/#example-with-ignore-if-case), to ignore the rule for the if-case case.
I suggest adding these parameters to the prefer_early_return rule (maximum_statements: 1 and ignore_if_case: true by default).
We could also consider extending the rule to apply to loop bodies:
so instead of
it will propose