New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiline expressions in padding-line-between-statements rule #9491
Comments
Hey! Just want to make sure I understand. For the case of and for
would you expect the correction output to be:
You might have to write a custom rule to enforce this style. I couldn't find a particular rule that would do the exact thing you're looking for. |
Hi @SeanEire, thanks for the issue. It looks like there's not enough information for us to know how to help you. If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. Requesting a rule change? Please see Proposing a Rule Change for instructions. If it's something else, please just provide as much additional information as possible. Thanks! |
Thanks for getting back to me @VictorHom ! I'm actually looking to enforce a line break after a multi-line expression preceding a return statement. Now I can use this rule for single/multi line expressions This enforces:
But also for single line expressions:
The goal is something like: Which would only enforce line break after multiline expressions:
And not single line expressions:
|
@SeanEire I see. For the multiline blocks, are your typical cases with constructs like a ForEach? I'm look through the documentation for https://eslint.org/docs/rules/padding-line-between-statements and there is an option for {"blankLine": "never", "prev": "for", "next": "return"}], which doesn't work for a forEach statement. It states it only works for Wondering if My concern is around cases single line expressions that are on multiple lines in the multiline expression example that was posted earlier:
|
@VictorHom ForEach would be one example yes. My most typical case however is with the usage of promise chains. What I'd really like to do is enforce line breaks before/after the chain statement. Something like this:
|
It looks like this was also proposed in #8668 but no one on the team ended up championing the proposal. We can see if anyone is interested in supporting it this time around. |
@not-an-aardvark any chance of this being added in one form or another? |
@eslint/eslint-team It looks like this issue just needs a champion to move forward. |
great! I'll champion this, marked as |
closing, as #8668 get merged. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
AirBnb
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
Would it be or is it already possible to distinguish multiline from single line expressions in the padding-line-between-statements rule? For example:
Distinguish this:
From this:
What did you expect to happen?
I would like to be able to identify multiline expressions in order to enforce blank lines between them and certain other statements.
What actually happened? Please include the actual, raw output from ESLint.
No ability to distinguish multi line expressions from single line expressions.
The text was updated successfully, but these errors were encountered: