Reference-like URLs

ESLint rule to prevent Markdown references from being used like URLs in JSDoc descriptions.

Usage

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

rule

ESLint rule to prevent Markdown references from being used like URLs in JSDoc descriptions.

Bad:

/**
* Beep [boop](baz).
*
* [baz]: http://foo.bar/baz
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Good:

/**
* Beep [boop][baz].
*
* [baz]: http://foo.bar/baz
*
* @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-reference-like-url' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep [boop](beep).',
    '*',
    '* [beep]: https://example.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-reference-like-url', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-reference-like-url': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-reference-like-url',
            'severity': 2,
            'message': 'Did you mean to use `[beep]` instead of `(beep)`, a reference?',
            'line': 2,
            'column': 8,
            'nodeType': null,
            'source': '* Beep [boop](beep).',
            'endLine': 12,
            'endColumn': 3
        }
    ]
*/