question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Comments not emitted in chaining calls

See original GitHub issue

before:

request
  .post('/version')  // comment 1
  .set('Prefer', 'plurality=singular') /* comment 2 */
  .send()
  .end((error, response) => {});

after:

request
  .post('/version')
  .set('Prefer', 'plurality=singular')
  .send()
  .end((error, response) => {});

Related issues:

https://github.com/jlongster/prettier/issues/31 https://github.com/jlongster/prettier/issues/87

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
vjeuxcommented, Jan 29, 2017

Thanks @dmnd, this is a known issue and there’s a fix in https://github.com/jlongster/prettier/pull/469

Also, awesome job on dedent package, it makes template literals usable!

1reaction
vjeuxcommented, Jan 31, 2017

@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) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

Method chaining - why is it a good practice, or not?
I think it's generally good practice to always write very short and concise lines. Every line should just make one method call. Prefer...
Read more >
Optional chaining is emitting not recognizable JavaScript code ...
In the TypeScript design goal it writes Emit clean, idiomatic, recognizable JavaScript code, but the optional chaining breaks this.
Read more >
Behavior Chain in ABA
A behavior chain (chaining) is a type of teaching procedure used to connect individual behaviors to form more complex responses.
Read more >
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called is ...
Read more >
RxJs Error Handling: Complete Practical Guide
As we can see, the stream emitted no value and it immediately errored out. After the error, no completion occurred. Limitations of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found