Closed ybiquitous closed 4 months ago
This rule prevents this:
const asdf = 'dfsdf';
function xxcv() {
const sdfsdf = 'sdfsdf';
return sdfsdf;
}
for (let i = 0; i < 10; i++) {
console.log(i);
}
const asdfsfd = 'sdfsdf';
if (true) {
console.log('true');
}
Some people tend to ignore adding empty lines to improve readability and they jam every line together into one blob of text.
This rule automatically adds empty lines and separate things. Unfortunately, Prettier doesn't do this.
const asdf = 'dfsdf';
function xxcv() {
const sdfsdf = 'sdfsdf';
return sdfsdf;
}
for (let i = 0; i < 10; i++) {
console.log(i);
}
const asdfsfd = 'sdfsdf';
if (true) {
console.log('true');
}
I would add a plugin.
@hudochenkov Thanks for the reply. That makes sense. Let's replace the deprecated rule with the plugin rule. 👍🏼
I wish that single-line if
s could be exempt of the new line before.
It can be achieved using multiline-block-like
as a statement type.
Not a big deal though.
@Mouvedia Thanks for the feedback. I am not against the suggestion for single-line if
s.
But, I don't know how to exclude only single-line if
s with the new rule. 🤔 If you know, please let us know.
See https://eslint.style/rules/default/padding-line-between-statements
@hudochenkov I'd be happy if you could comment on this idea.
Personally, I find single line if
s less readable, then multiline ones. Mentally there is a clear expectation, when reading a if
statement: first line is condition, inside the block {}
whatever to happens in condition is true
. Never have to expect that the first line could have something more than condition.
@hudochenkov Thanks for the reply.
It's a matter of preference and needs more customization for the rule. So, let's keep it as-is.
What is the problem you're trying to solve?
We have the
padding-line-between-statements
rule, but this rule has been deprecated since ESLint v8.53.0.https://github.com/stylelint/eslint-config-stylelint/blob/6079dd110ff0fc2e315e8e4d3b5f9576c01499cb/index.js#L60-L103
What solution would you like to see?
So, we should remove it or replace it with the plugin rule
@stylistic/padding-line-between-statements
.I lean toward removing it because:
However, they're not strong opinions. I'd like to hear other thoughts.
Note: This rule was added in #55. @hudochenkov, please let us know if you have any opinions.