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 can cause inconsistent output

See original GitHub issue

In a project I work on, there is a common stanza at the top of most files that has been implemented inconsistently. If there are comments, the prettier output is also inconsistent:

angular.module('foo').directive('bar', function() {});

angular
  .module('foo').directive('bar', function() {});

angular
  .module('foo')
  .directive('bar', function() {});

angular
  .module('foo')
  // the directive
  .directive('bar', function() {});


angular
  // the mod
  .module('foo')
  // the directive
  .directive('bar', function() {});

Output:

angular.module('foo').directive('bar', function() {});

angular.module('foo').directive('bar', function() {});

angular.module('foo').directive('bar', function() {});

angular.module('foo')// the directive
.directive('bar', function() {});

angular
  // the mod
  .module('foo')
  // the directive
  .directive('bar', function() {});

I probably would have expected consistently either of these:

angular.module('foo').directive('bar', function() {});
// or
angular
  .module('foo')
  .directive('bar', function() {});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alekhurstcommented, Feb 15, 2017

I have a project where prettier consistently produces inconsistent output…

code looks like:

  ...
  /*eslint-enable */
}

and every time I run prettier, the format changes (adds and removes a newline)

0reactions
benjaminapetersencommented, Mar 6, 2017

@vjeux the first and second versions are just there for reference, the 3rd and 4th illustrate how the comments alter the output.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Comments make code formatting inconsistent #4209 - GitHub
After recent changes to the way we format multiline code, comments are now providing weird/inconsistent formatting results depending on how ...
Read more >
Comment.Add in Word VBA (2019) is inconsistent in adding ...
Problem: The comment balloon is always added, but it is frequently left blank. On some documents, every comment will work (1/10 maybe). On ......
Read more >
Reducing outdated and inconsistent code comments during ...
comments make the code easier to read and maintain, code comments can become outdated and inconsistent with their corresponding code.
Read more >
Excel 2016 bug/inconsistent behaviour when pasting comments
I've encountered an issue when copying and pasting cells containing comments in Excel 2016. The problem is repeatable and can be duplicated ...
Read more >
What To Say In A Performance Review [Comments, Phrases ...
Below we'll outline exactly what to say in a performance review—including performance review comments, phrases, and questions—so you can ...
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