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

Bug: breaking assignment to class #54

Open
helixbass opened this issue Mar 24, 2019 · 2 comments
Open

Bug: breaking assignment to class #54

helixbass opened this issue Mar 24, 2019 · 2 comments

Comments

@helixbass
Copy link
Owner

This

exports.ExportNamedDeclaration = class ExportNamedDeclaration extends ExportDeclaration
  ...

is formatting like

exports
  .ExportNamedDeclaration = class ExportNamedDeclaration extends ExportDeclaration
  ...

so the class body doesn't parse as indented

@helixbass
Copy link
Owner Author

#55 fixed this specific case but there are other examples that would still break eg

exports().ExportNamedDeclaration = ...

This seems like part of a more general problem where nothing in a control line can do a simple indented break because then the indented body won't parse as indented

@helixbass
Copy link
Owner Author

I'm thinking that a short-term "solution" would be to disable the indentChain option for now (or advertise as USE AT YOUR OWN RISK), since all I can think of that would cause this is a member expression LHS of an assignment

Basically I think the question for whether an indented body could ever be not actually indented due to something like this can be broken into:

  1. Are there any cases where an element of the "control line" (non-indented line that precedes the indented body) could itself break in a way that's not "self-indent-closing"?

Hopefully this is already covered (eg if a for source or guard breaks, it gets parenthesized), and if there are any more cases that aren't covered then presumably they can be covered in a similar way (make sure it gets parenthesized if it needs to be) since for these we know that it's part of a structure that has an indented body

  1. The trickier cases (like this issue) are when there's something else preceding the "control line" on the same line/expression that could itself break in a non-self-indent-closing way (and it would presumably be hard to robustly guard against all arbitrarily nested variants of these from the perspective of the control structure or the enclosing expressions)

So the question is, what types of expressions are there that could have its first part break in a non-self-indent-closing way while not affecting the indent level of the control structure

Assignment (like in this issue) is one thing where the LHS can break separately (at least if the RHS is inlined like here for class). So what types of assignment LHS could non-self-indent-closing break?

I can only see non-computed member expressions

And not sure what if any other types of enclosing expressions could break that way? Eg this indents the whole control structure:

a +
  class B
    c: ->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant