Ordered List Marker Value

ESLint rule to enforce a specified Markdown ordered list marker style in JSDoc descriptions.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-value' );

rule

ESLint rule to enforce a specified Markdown ordered list marker style in JSDoc descriptions.

Bad:

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

Good:

/**
* Beep boop.
*
* 1.  Foo
* 2.  Bar
*
* @returns {string} a value
*
* @example
* var str = beep();
* // returns 'boop'
*/
function beep() {
    return 'boop';
}

The rule may be configured using the same options as supported by remark.

  • ordered: increment list item markers by one (default).
  • single: list item markers should all have the same starting value.
  • one: list item markers should always be equal to 1.

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-value' );

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

// Generate our source code:
code = [
    '/**',
    '* Beep *boop*.',
    '*',
    '* 1.  Foo',
    '* 1.  Bar',
    '*',
    '* @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-ordered-list-marker-value', rule );

// Lint the code:
result = linter.verify( code, {
    'rules': {
        'jsdoc-ordered-list-marker-value': [ 'error', 'ordered' ]
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-ordered-list-marker-value',
            'severity': 2,
            'message': 'Marker should be `2`, was `1`',
            'line': 5,
            'column': 3,
            'nodeType': null,
            'source': '* 1.  Bar',
            'endLine': 13,
            'endColumn': 3
        }
    ]
*/