This rule enforces consistent position of line comments. Block comments are not affected by this rule. By default, this rule ignores comments starting with the following words: eslint, jshint, jslint, istanbul, global, exported, jscs, falls through.
This rule takes one argument, which can be a string or an object. The string settings are the same as those of the position property (explained below). The object option has the following properties:
By default this rule ignores comments starting with the following words: eslint, jshint, jslint, istanbul, global, exported, jscs, falls through. An alternative regular expression can be provided.
Examples of incorrect code for the ignorePattern option:
line-comment-position
Line comments can be positioned above or beside code. This rule helps teams maintain a consistent style.
Rule Details
This rule enforces consistent position of line comments. Block comments are not affected by this rule. By default, this rule ignores comments starting with the following words:
eslint,jshint,jslint,istanbul,global,exported,jscs,falls through.Options
This rule takes one argument, which can be a string or an object. The string settings are the same as those of the
positionproperty (explained below). The object option has the following properties:position
The
positionoption has two settings:above(default) enforces line comments only above code, in its own line.besideenforces line comments only at the end of code lines.above
Examples of incorrect code for the
{ "position": "above" }option:Examples of correct code for the
{ "position": "above" }option:beside
Examples of incorrect code for the
{ "position": "beside" }option:Examples of correct code for the
{ "position": "beside" }option:ignorePattern
By default this rule ignores comments starting with the following words:
eslint,jshint,jslint,istanbul,global,exported,jscs,falls through. An alternative regular expression can be provided.Examples of incorrect code for the
ignorePatternoption:Examples of correct code for the
ignorePatternoption:applyDefaultIgnorePatterns
Default ignore patterns are applied even when
ignorePatternis provided. If you want to omit default patterns, set this option tofalse.Examples of incorrect code for the
{ "applyDefaultIgnorePatterns": false }option:Examples of correct code for the
{ "applyDefaultIgnorePatterns": false }option:Deprecated: the object property
applyDefaultPatternsis deprecated. Please use the propertyapplyDefaultIgnorePatternsinstead.When Not To Use It
If you aren't concerned about having different line comment styles, then you can turn off this rule.
Compatibility
JSCS: validateCommentPosition