empty-line-before-comment

ESLint rule to enforce empty lines before comments.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/empty-line-before-comment' );

rule

ESLint rule to enforce empty lines before comments.

Bad:

function square( x ) {
    var out;
    // Square the number:
    out = x*x;
    return out;
}

Good:

function square( x ) {
    var out;

    // Square the number:
    out = x*x;
    return out;
}

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/empty-line-before-comment' );

var linter = new Linter();
var result;
var code;

code = [
    'function square( x ) {',
    '  var out;',
    '  // Square the number:',
    '  out = x*x;',
    '  return out;',
    '}'
].join( '\n' );

linter.defineRule( 'empty-line-before-comment', rule );

result = linter.verify( code, {
    'rules': {
        'empty-line-before-comment': 'error'
    }
});
/* returns
    [
        {
            ruleId: 'empty-line-before-comment',
            severity: 2,
            message: 'Missing empty line before comment',
            line: 3,
            column: 3,
            nodeType: null,
            source: '  // Square the number:',
            endLine: 3,
            endColumn: 24
        }
    ]
*/