-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Comments not emitted in chaining calls #200
Comments
This most likely has to do with request
.post('/version') // comment 1
.set('Prefer', 'plurality=singular') /* comment 2 */
.send()
request
.post.version // comment 1
.set.Prefer.plurality.singular /* comment 2 */
.send() request.post("/version").set("Prefer", "plurality=singular").send();
// comment 1
request.post.version.set.Prefer.plurality.singular /* comment 2 */.send(); |
Moved to #275 to consolidate all the comment bugs |
Re-opening as I didn't fix this one in my comment overhaul. |
Related. Comments on their own lines really mess with the output. request
// handle escaped backticks
.post('/version')
/* comment 2 */
.set('Prefer', 'plurality=singular')
.send() request.// handle escaped backticks
post("/version")./* comment 2 */
set("Prefer", "plurality=singular").send(); I'm not sure if this belongs in here or in its own issue. |
Is this the same issue? str.replace(/\//g, '_')
// Remove ending '=' 15 bits doesn't have it but just to be safe
.replace(/=+$/, ''); prints: str
.replace(/\//g, "_")
.// Remove ending '=' 15 bits doesn't have it but just to be safe
replace(/=+$/, ""); |
Actually this reproduces on the prettier codebase:
|
@amasad for this, I have a fix that I need to properly extract out before we can release it. I want it in before I do the next release diff --git a/src/comments.js b/src/comments.js
index e05c7f5..d31122e 100644
--- a/src/comments.js
+++ b/src/comments.js
@@ -152,7 +152,10 @@ function attach(comments, ast, text) {
// If a comment exists on its own line, prefer a leading comment.
// We also need to check if it's the first line of the file.
- if (followingNode) {
+ if (enclosingNode.type === "MemberExpression" &&
+ followingNode.type === "Identifier") {
+ addLeadingComment(enclosingNode, comment);
+ } else if (followingNode) {
// Always a leading comment.
addLeadingComment(followingNode, comment);
} else if (precedingNode) { |
This is using the same technique as prettier#544 and will conflict with it when we try to merge both :) Fixes prettier#200
This is using the same technique as prettier#544 and will conflict with it when we try to merge both :) Fixes prettier#200
before:
after:
Related issues:
#31
#87
The text was updated successfully, but these errors were encountered: