Shell Dollars

ESLint rule to prevent shell code in Markdown fenced code blocks from being prefixed by dollar-characters in JSDoc descriptions.

Usage

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

rule

ESLint rule to prevent shell code in Markdown fenced code blocks from being prefixed by dollar-characters in JSDoc descriptions.

Bad:

/**
* Boop beep.
*
* ```bash
* $ echo a
* $ echo a > file
* ```
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

Good:

/**
* Boop beep.
*
* ```sh
* echo a
* echo a > file
* ```
*
* @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-shell-dollars' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep boop.',
    '*',
    '* ```bash',
    '* $ echo a',
    '* $ echo a > file',
    '* ```',
    '*',
    '* @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-shell-dollars', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-no-shell-dollars': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-no-shell-dollars',
            'severity': 2,
            'message': 'Do not use dollar signs before shell-commands',
            'line': 4,
            'column': 3,
            'nodeType': null,
            'source': '* ```bash',
            'endLine': 15,
            'endColumn': 3
        }
    ]
*/