-
Notifications
You must be signed in to change notification settings - Fork 2k
Allow linebreak/indent before param default #5081
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
Conversation
Doesn’t this allow for e.g. |
@vendethiel that appears not to work, I guess analogously to how |
The fix for that probably is at work here. Good :)! |
Agreed on the This is terribly ugly syntax: (
q =
a,
@p =
b
) -> q I assume Prettier isn’t going to output anything so atrocious? But back to the original point, this is invalid JavaScript: function foo(a; b) {} JavaScript of course allows linebreaks because it’s whitespace insignificant, but we aren’t. Our linebreaks are equivalent to JS’ semicolons. If a semicolon isn’t allowed here, shouldn’t our linebreak be similarly disallowed? |
@GeoffreyBooth it's not a syntax I've ever desired. The arguments I could see for allowing it are:
|
But we do allow a semicolon here: |
newlines also mean commas in array/object literals [
1
2
a: {
b
c
}
] btw the output for this looks a bit off atm |
@helixbass Do you want to resolve conflicts so we can finish this? After this, what remains before the |
@GeoffreyBooth this one didn't seem clear-cut as to whether there was support/need to allow it? But ya these have been most of the obvious "smaller chunks" towards AST support. I'm on a project right now so have been a bit less active but have been adding comments support to the Prettier plugin. Preserving herecomment spacing is one more small one that I haven't done. But then at that point it's probably time to start looking at how to land some of the bigger pieces of AST generation functionality that's currently on my Any interest in a call to discuss approaches to moving forward with that? I figured that once I feel like it's "feature complete" on that branch, I could start looking at its current state and trying to carve out individually reviewable chunks. Also not sure about approaches to testing AST generation, as I've effectively been using the Prettier plugin as my point of testing its accuracy/completeness |
@helixbass Sorry to not reply sooner.
Agreed. If it’s not needed for AST output or Prettier support, it’s best to leave it until after we get those features out the door I think. As for tests, I started working on some AST tests: https://github.com/GeoffreyBooth/coffeescript/blob/ast-tests/test/abstract_syntax_tree.coffee. The method I’ve been using so far has been to take a string of CoffeeScript code, send it through the compiler with A call would be great, I’ll contact you privately to set that up. If anyone else is interested in contributing to the AST/Prettier effort, please let me know and I’ll invite you. |
@GeoffreyBooth looking good, i'll try to find time for it later today / this weekend. |
Just an update to this conversation: |
@Inve1951 thanks, I've gotten my |
Reopened as #5278 |
@GeoffreyBooth this is a small Prettier-related one:
I've gotten basic comment printing working in Prettier so am now starting to go through their JS comment tests to try and match case-by-case. They have tests for comments preceding param default values (on their own lines). While we allow linebreak/indent after
=
for regular assignments, currently our grammar doesn't allow it for param default assignments. I don't see any reason why it shouldn't be allowed?This would be a good candidate to get targeted to eg an
ast
branch if you want to proceed that way?