Paragraph Content Indentation

ESLint rule to prevent indentation of Markdown paragraph content in JSDoc descriptions.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-no-paragraph-content-indent' );

rule

ESLint rule to prevent indentation of Markdown paragraph content in JSDoc descriptions.

Bad:

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

Good:

/**
* Boop beep.
*
* ## Boop
*
* Beep.
*
* @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-paragraph-content-indent' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep boop.',
    '*',
    '* ## Beep',
    '*',
    '*    boop',
    '*',
    '*  ## Beep',
    '*',
    '*  beep',
    '*',
    '*',
    '* @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-paragraph-content-indent', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-paragraph-content-indent': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-paragraph-content-indent',
            'severity': 2,
            'message': 'Expected no indentation in paragraph content',
            'line': 6,
            'column': 3,
            'nodeType': null,
            'source': '*    boop',
            'endLine': 18,
            'endColumn': 3
        },
        {
            'ruleId': 'jsdoc-no-paragraph-content-indent',
            'severity': 2,
            'message': 'Expected no indentation in paragraph content',
            'line': 10,
            'column': 3,
            'nodeType': null,
            'source': '*  beep',
            'endLine': 18,
            'endColumn': 3
        }
    ]
*/