Expected 'undefined' and instead saw 'void'
348 phone: '',
349 cell: '',
350 });
351 void fetchClients();352 } catch (error) {
353 toast.error(t('msg.clientEmailError'));
354 setError('Error updating client');
Expected 'undefined' and instead saw 'void'
281 phone: '',
282 cell: '',
283 });
284 void fetchClients();285 } catch (error) {
286 toast.error(t('msg.clientEmailError'));
287 setError('Error creating client');
Description
A return;
statement with nothing after it is redundant, and has no effect on the runtime behavior of a function.
This can be confusing, so it's better to disallow these redundant statements.
Bad Practice
function foo() { return; }
function foo() {
doSomething();
return;
}
function foo() {
if (condition) {
bar();
return;
} else {
baz();
}
}
function foo() {
switch (bar) {
case 1:
doSomething();
default:
doSomethingElse();
return;
}
}
Recommended
function foo() { return 5; }
function foo() {
return doSomething();
}
function foo() {
if (condition) {
bar();
return;
} else {
baz();
}
qux();
}
function foo() {
switch (bar) {
case 1:
doSomething();
return;
default:
doSomethingElse();
}
}
function foo() {
for (const foo of bar) {
return;
}
}