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.

Ignore comments option for indent rule

See original GitHub issue

What rule do you want to change?

indent

Does this change cause the rule to produce more or fewer warnings?

Potentially fewer warnings

How will the change be implemented? (New option, new default behavior, etc.)?

New option:

{
    "indent": ["error", 4, { "comments": "off" }]
}

This option will completely disregard lines beginning with comments and allow them to be at any indentation level.

Please provide some example code that this change will affect:

doSomething();  // This comment is fine
                           // This comment is reported, but shouldn't be

if (foo) {
    doBar();

// This comment is reported, but shouldn't be with new option
// (maybe comment should be easy to spot via outdenting?)
    doBaz();
}

What does the rule currently do for this code?

Reports all comments (except trailing comment on first line)

What will the rule do after it’s changed?

Reports none of the comments

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:30
  • Comments:27 (13 by maintainers)

github_iconTop GitHub Comments

6reactions
platinumazurecommented, Jul 26, 2017

@gyandeeps What you say makes sense. For what it’s worth, though, it could also be seen as a backward-compatibility enhancement for users that used to rely on indent ignoring comments.

4reactions
mcdohcommented, Jul 26, 2017

I use tabs and start my comments at column 0. This way I can comment out blocks of code without affecting the horizontal placement of the commented code (i.e. indenting with spaces would indent the commented code by two spaces). Personally I find this very readable and useful. The current eslint rules complain about my indent level and I have no way to turn that off short of changing my code style.

Ignoring indent levels on comments is exactly what I’m looking for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore the indentation in a template literal, with the ESLint ...
I want to ignore those lines from the rule, but I can't figure out the node that should apply. Node types are specified...
Read more >
indent - ESLint - Pluggable JavaScript Linter
This rule has an object option: "ignoredNodes" can be used to disable indentation checking for any AST node. This accepts an array of...
Read more >
indentation - Stylelint
Always indent at-rules, rules, comments, declarations, inside parentheses and multi-line values by 2 spaces. The following patterns are considered problems:.
Read more >
Rules — yamllint 1.28.0 documentation
This page describes the rules and their options. List of rules. braces; brackets; colons; commas; comments; comments-indentation; document-end; document-start ...
Read more >
Reformat and rearrange code - PhpStorm - JetBrains
In the editor, at the beginning of a region that you want to exclude, create a line comment Ctrl+/ and type @formatter:off ....
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