Closed akx closed 4 months ago
function foo(): string | undefined { if (Math.random() > 0.5) { return 'hello'; } return; // Remove this redundant jump [sonarjs/no-redundant-jump] }
The last return; should preferably not be flagged; it's not a jump.
return;
Turning this into return undefined; quiesces the plugin, but return undefined; is uglier than return;.
return undefined;
Eliding the last return; is against the tsconfig noImplicitReturns rule, so that is not an option.
noImplicitReturns
eslint-plugin-sonarjs version: 0.23.0 eslint version: 8.55.0 Node.js version: 21.5.0 Rule key: sonarjs/no-redundant-jump
This issue has been migrated to Jira. ESLINTJS-31
Reproducer
Expected behavior
The last
return;
should preferably not be flagged; it's not a jump.Turning this into
return undefined;
quiesces the plugin, butreturn undefined;
is uglier thanreturn;
.Eliding the last
return;
is against the tsconfignoImplicitReturns
rule, so that is not an option.Environment.
eslint-plugin-sonarjs version: 0.23.0
eslint version: 8.55.0
Node.js version: 21.5.0
Rule key: sonarjs/no-redundant-jump