Skip to content
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

paren-newline: consistent parenthesis new lines #375

Open
4 tasks done
guilhermetod opened this issue Apr 29, 2024 · 0 comments
Open
4 tasks done

paren-newline: consistent parenthesis new lines #375

guilhermetod opened this issue Apr 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@guilhermetod
Copy link

guilhermetod commented Apr 29, 2024

Clear and concise description of the problem

Currently, we have rules for array-bracket-newline and object-curly-newline to ensure consistency in line breaks on open and closing brackets for creating arrays and objects.

We also have function-paren-newline which is something similar for functions and parenthesis, but that is limited to this scope. With that, it's possible to have codes like this that have no way to be consistent (as far as I have researched):

    if (someLongLongVariable
        ?? other
    ) {
      return;
    }

Suggested solution

For the code above, I suggested we have paren-newline, which can apply to function paren and all other scopes (if statements, functions and other expressions, as examples below). For the if statement example, using paren-newline with consistent: true, I expect the following output:

    if (
      someLongLongLongVariable
      ?? other
    ) {
      return;
    }

Similarly, here are some other pairs of inputs and expected outputs:

// Input
function foo(bar,
  baz
) {}

// Output
function foo(
  bar,
  baz,
) {}
// Input
const myVariable = (someLongVariable
  ?? other
)

// Output
const myVariable = (
  someLongVariable
  ?? other
)

Alternative

No response

Additional context

No response

Validations

Contributes

  • If this feature request is accepted, I am willing to submit a PR to fix this issue
@guilhermetod guilhermetod added the enhancement New feature or request label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant