Ignore comments option for indent rule
See original GitHub issueWhat 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:
- Created 6 years ago
- Reactions:30
- Comments:27 (13 by maintainers)
Top 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 >
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
@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.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.