Consecutive Blank Lines

ESLint rule to prevent too many consecutive blank lines in JSDoc descriptions.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-no-consecutive-blank-lines' );

rule

ESLint rule to prevent too many consecutive blank lines in JSDoc descriptions. Specifically, the rule allows only one blank line between Markdown elements, except if two lists follow each other or a list is followed by indented code, in which case two blank lines are required.

Bad:

/**
* Boop beep.
*
* ## Beep
*
*
* Boop.
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Good:

/**
* Boop beep.
*
* ## Beep
*
* Boop.
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-no-consecutive-blank-lines' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep boop.',
    '*',
    '* ## Beep',
    '*',
    '*',
    '* boop',
    '*',
    '* @param {string} str - input value',
    '* @returns {string} output value',
    '*',
    '* @example',
    '* var out = beep( "boop" );',
    '* // returns "beepboop"',
    '*/',
    'function beep( str ) {',
    '\treturn "beep" + str;',
    '}'
].join( '\n' );

// Register the ESLint rule:
linter.defineRule( 'jsdoc-no-consecutive-blank-lines', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-consecutive-blank-lines': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-consecutive-blank-lines',
            'severity': 2,
            'message': 'Remove 1 line before node',
            'line': 7,
            'column': 3,
            'nodeType': null,
            'source': '* boop',
            'endLine': 15,
            'endColumn': 3
        }
    ]
*/