[Comments] Trailing single-line comments are wrapped to the next line
See original GitHub issueI had a bit of code where a trailing comment was moved to the next line when there’s another statement after the function. This can cause confusion since it requires you to read the comment to know whether it applies to the line before or after and it looks like it would actually cause things like // eslint-disable-line
to apply to a different statement.
function foobar() {
var foo = bar;
var bar = fooBarBaaz(); // foo all the bars
var baaz = 'quux';
}
becomes:
function foobar() {
var foo = bar;
var bar = fooBarBaaz();
// foo all the bars
var baaz = "quux";
}
This does not happen if the comment is on the last line of a function.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:6 (4 by maintainers)
Top Results From Across the Web
NeoVim: Single-Line Comments Also Format the Next Line
How to disable auto insertion of comment header when pressing enter, but keep auto insertion of header when auto wrapping comment? 3 ·...
Read more >4.7 Trailing comments - C Style
Trailing comments describe the action or use of a single line of code. They are usually start (and end) on the same line...
Read more >How do I create multiline comments in Python? - Stack Overflow
Use arrow keys to select all the lines to be commented. Press Shift+I. Press # (or Shift+3). Press Esc. Share.
Read more >Single-line and Multi-line Comments in C# | Pluralsight
Single-line comments allow narrative on only one line at a time. Single-line comments can begin in any column of a given line and...
Read more >Options - Prettier
(If you don't want line wrapping when formatting Markdown, ... This effectively allows using the json5 parser for “JSON with comments and trailing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Comments are probably where most of the subtle bugs are right now. They’re pretty difficult to get right, but this is definitely problematic. I think it’ll take a few weeks to sort out these kinds of bugs, but we’ll get there.
See above PR