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.

Indent comment indentation: Comments can align with previous/next lines of code even if whitespace in between

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.13.1 (via online demo)
  • Node Version: N/A
  • npm Version: N/A

What parser (default, Babel-ESLint, etc.) are you using?

Default parser

Please show your full configuration:

Configuration
{
    "rules": {
        "indent": ["error", 4]
    }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

if (foo) {

// blah
    statement();

}

What did you expect to happen?

3:1 - Expected indentation of 4 spaces but found 0. (indent)

What actually happened? Please include the actual, raw output from ESLint.

No lint error.


The bug (as I see it) is that the indent rule has a tolerance for comments to match the indentation of the previous line, that of the next line, or the “actual correct location”. However, I think this should only apply if there actually is code on the immediately previous or next lines, rather than code that is separated by one or more lines of whitespace.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, May 20, 2018

Thanks for following up! I haven’t had a chance to look into this; please take a look if you are interested.

On Sat, May 19, 2018, 19:54 Scott Stern notifications@github.com wrote:

@platinumazure https://github.com/platinumazure was wondering if you were still looking into this one? Wouldnt mind taking a crack at it. If youre still looking into it though no worries.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eslint/eslint/issues/9733#issuecomment-390446911, or mute the thread https://github.com/notifications/unsubscribe-auth/AARWeqdcb4Mjl-a4FXHHkF7sOK8VCYDZks5t0L63gaJpZM4RGB2- .

0reactions
platinumazurecommented, Jul 21, 2018

Working on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Indent and Format C Program Source - The indent Program
The indent program changes the appearance of a C program by inserting or deleting whitespace. It can be used to make code easier...
Read more >
Comments (indent: Indent and Format C Program Source)
indent attempts to distinguish between comments which follow statements, comments which follow declarations, comments following preprocessor directives, and ...
Read more >
HTML Indentation, Spacing, and Comments
When you are writing HTML (or any other programming language), well-written code follows consistent indentation and spacing patterns.
Read more >
comment indentation can break code indentation
I feel that single line comments that are ALONE on their line should be indented to match the start of the previous line....
Read more >
GNU Emacs Manual - Comment Commands
M-; can also be used to align an existing comment. If a line already contains the string that starts comments, then M-; just...
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