HTML

ESLint rule to prevent HTML from being used in JSDoc descriptions.

Usage

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

rule

ESLint rule to prevent HTML from being used in JSDoc descriptions.

Bad:

/**
* Boop beep.
*
* <h2>References</h2>
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Good:

/**
* Boop beep.
*
* ## References
*
* <!-- Comments are OK -->
*
* @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-html' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep boop.',
    '*',
    '* <h2>References</h2>',
    '*',
    '* @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-html', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-html': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-html',
            'severity': 2,
            'message': 'Do not use HTML in markdown',
            'line': 4,
            'column': 3,
            'nodeType': null,
            'source': '* <h2>References</h2>',
            'endLine': 12,
            'endColumn': 3
        }
    ]
*/