eslint-stylistic / eslint-stylistic

Monorepo for ESLint Stylistic plugins and configs
https://eslint.style
MIT License
1.2k stars 84 forks source link

Collapsing completely empty lines in arrays, if statements, etc. #420

Open Ericlm opened 2 weeks ago

Ericlm commented 2 weeks ago

Clear and concise description of the problem

I would like Stylistic to erase more of those useless lines that Prettier use to collapse, like :

// Valid with Stylistic
const val = [

  'app',

  'hello',
]

// Formatted with Prettier
const val = ['app', 'coucou']

The issue is not that Prettier made this one-line (because it simply has a sense of line-length, instead of the AST), but more that Prettier is able to collapse those completely empty lines.

The same is true for IfStatement for example, and I think many more statements.

Suggested solution

The idea is not just about erasing empty lines, because we need padding around when we code, but about erasing empty lines inside of declarations or statements where it has no value to have empty lines.

Alternative

It's not a big deal so I didn't look for an alternative way. It will be a "best practice" to handle manually for now 😄

Additional context

I was simply playing around with Stylistic and realized that I could make empty lines pop-up from anywhere, without auto-collapsing those while they are useless (until no-multiple-empty-lines catches me).

Validations

Contributes