Link Protocol

ESLint rule to require angle-bracketed Markdown links to contain protocols in JSDoc descriptions.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-no-auto-link-without-protocol' );

rule

ESLint rule to require angle-bracketed Markdown links to contain protocols in JSDoc descriptions.

Bad:

/**
* Beep.
*
* <foo@bar.com>
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Good:

/**
* Beep.
*
* <mailto:foo@bar.com>
*
* @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-auto-link-without-protocol' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep boop.',
    '*',
    '* <foo@bar.com>',
    '*',
    '*',
    '* @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-auto-link-without-protocol', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-auto-link-without-protocol': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-auto-link-without-protocol',
            'severity': 2,
            'message': 'All automatic links must start with a protocol',
            'line': 4,
            'column': 3,
            'nodeType': null,
            'source': '* <foo@bar.com>',
            'endLine': 13,
            'endColumn': 3
        }
    ]
*/