-
Notifications
You must be signed in to change notification settings - Fork 73
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
Splitting and indenting variable declarations when necesary #230
Conversation
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
========================================
Coverage ? 99.2%
========================================
Files ? 78
Lines ? 632
Branches ? 102
========================================
Hits ? 627
Misses ? 5
Partials ? 0
Continue to review full report at Codecov.
|
embrace ? concat(['(', doc, ')']) : doc; | ||
|
||
const variables = (node, path, print) => | ||
group( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can (and if we should) make a helper for this pattern, since we use it a lot. I guess something like this:
const printList = (node, path, print, key, separator = ',') =>
group(
concat([
indent(
concat([
softline,
join(
concat([separator, line]),
path.map(statementPath => print(statementPath), key)
)
])
),
softline
])
);
(with better names for the function and the parameters).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tricky one.
The pattern is used a lot but with small differences.
Sometimes times is a softline
and sometimes is a line
, the separator and the content also changes I’ll see how it looks having a function with many variables in one go vs a step by step declaration.
The system is already modular and there aren’t many files bigger than a screen.
I’ll give it a thought and play with the idea a little but probably for another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Just for the record: I'm fine with merging this as it is, I was just thinking out loud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too, I already got over my phase of having the driest possible code without really thinking of maintainability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes #225
Before PR:
After PR: