-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Break long member and method chain #15171
base: main
Are you sure you want to change the base?
Break long member and method chain #15171
Conversation
path.call((object) => rec(object), "object"); | ||
printedNodes.push({ |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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 reverted this change because objectDoc doesn't look necessary here.
path, | ||
options, | ||
print, | ||
printedNodes.at(-1)?.printed, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Outdated. This should be resolved.
expect(() => | ||
asyncRequest({ type: "foo", url: "/test-endpoint" }) | ||
).not.toThrowError(); | ||
expect(() => asyncRequest({ type: "foo", url: "/test-endpoint" })).not | ||
.toThrowError(); |
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.
It looks to get worse to read.
Currently, I consider this to be another issue.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
src/language-js/print/member.js
Outdated
|
||
/** | ||
* @param {AstPath} path | ||
* @param {*} objectDoc |
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 want to put "Doc" type here but it requires too redundant check like:
- objectDoc.label?.memberChain
+ typeof objectDoc === "object" && "label" in objectDoc && typeof objectDoc.label === "object" && "memberChain" in objectDoc.label && objectDoc.label?.memberChain
Adding @property {*} [label]
in Doc
(it should be right), it get a bit better:
- objectDoc.label?.memberChain
+ typeof objectDoc === "object" && "label" in objectDoc && objectDoc.label?.memberChain
But I think this might still make developers to avoid typing.
Defining @typedef {Partial<DocObject> & (string | DocObject | DocArray)} LooseDoc
, or just defining Doc
as it make just objectDoc.label?.memberChain
works.
I'd like to hear member's opinion
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 mean that I will open a discussion or an issue if it is worth to discuss, or open a PR if it looks better than the current one.
Maybe I accidentally hit another independent issue about idempotency... - .Even// comment<LF>
+ .Even // comment<LF> |
I consider it ready for review. |
Sorry for the long delay, I'll take a look ASAP. |
.Even // comment | ||
.if.Prettier.does.not.format.all.code["100%"].the.way["you’d"].like["it’s"] | ||
.worth.the.sacrifice.given.the.unique.benefits.of.Prettier["don’t"].you | ||
.think?.(); |
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.
Can you find some real world case? These tests doesn't make sense to me at all. Nobody write code like this.
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 see. I'll consider a more practical test case. This is just a test case that is so long chain and not likely to have a copyright / license issue.
"YAML", | ||
) | ||
.it.removes.all.original.styling.and.ensures.that.all.outputted.code.conforms | ||
.to.a.consistent.style(see, this, blogpost); |
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 indention seems unnessary.
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'll fix it.
Progress |
Finally it looks to "work". |
I give up to make it easier to read. |
Description
Fixes #2548.
Checklist
(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨