I strongly believe that empty lines inside the body of a function are code smells indicating that we need to perform refactoring to break the function apart.
But among the existing rules in ESLint (no-multiple-empty-lines/lines-between-class-members, etc.), including those presented in popular plugins, I could not find a rule that will restrict me from the use of empty lines inside the body of a function. Has anyone encountered this problem before?
This is bad:
function add(a, b) {
const result = a + b;
return result;
}
const multiply = (a, b) => {
const result = a * b;
return result;
}
This is good:
function add(a, b) {
const result = a + b;
return result;
}
const multiply = (a, b) => {
const result = a * b;
return result;
}
I personally strongly believe that empty lines are of paramount importance to make code more readable.
Anyway: did you check out the padding-line-between-statements rule?
If your goal is preventing complex function rather use max-lines-per-function and complexity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With