stylelint / eslint-config-stylelint

Stylelint org's shareable config for eslint
MIT License
62 stars 9 forks source link

Replace `padding-line-between-statements` with `@stylistic/padding-line-between-statements` #277

Closed ybiquitous closed 4 months ago

ybiquitous commented 4 months ago

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.

hudochenkov commented 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.

ybiquitous commented 4 months ago

@hudochenkov Thanks for the reply. That makes sense. Let's replace the deprecated rule with the plugin rule. 👍🏼

Mouvedia commented 4 months ago

I wish that single-line ifs 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.

ybiquitous commented 4 months ago

@Mouvedia Thanks for the feedback. I am not against the suggestion for single-line ifs.

But, I don't know how to exclude only single-line ifs 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.

hudochenkov commented 4 months ago

Personally, I find single line ifs 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.

ybiquitous commented 4 months ago

@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.