validateCommentPosition

This rule is for validating the positioning of line comments. Block comments are ignored.

Comments that start with the following keywords are also ignored: eslint, jshint, jslint, istanbul, global, exported, jscs, falls through eg. // jshint strict: true

Type: Object

Value:

  • Object:
    • position: above or beside
    • allExcept: array of quoted exceptions (comments that start with these values will be excepted)

Example

"validateCommentPosition": { position: `above`, allExcept: [`pragma`] }
Valid
// This is a valid comment
1 + 1;
Invalid
1 + 1; // This is an invalid comment
2 + 2; // pragma (this comment is fine)
"validateCommentPosition": { position: `beside` }
Valid
1 + 1; // This is a valid comment
Invalid
// This is an invalid comment
1 + 1;
Rule source
Test source