jsdoc-leading-description-sentence

ESLint rule to enforce that JSDoc descriptions start with an uppercase letter or number and end with a period.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-leading-description-sentence' );

rule

ESLint rule to enforce that JSDoc descriptions start with an uppercase letter or number and end with a period. To supply an array of words to be allowed at the beginning of a JSDoc description without being capitalized, set the whitelist option of the rule.

Bad:

/**
* returns a pseudo-random number on `[0,1]`
*
* @returns {number} uniform random number
*
* @example
* var y = rand();
* // e.g., returns 0.5363925252089496
*/
function rand() {
    return Math.random();
}

Good:

/**
* Returns a pseudo-random number on `[0,1]`.
*
* @returns {number} uniform random number
*
* @example
* var y = rand();
* // e.g., returns 0.5363925252089496
*/
function rand() {
    return Math.random();
}

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-leading-description-sentence' );

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

code = [
    '/**',
    '* squares a number.',
    '* ',
    '* @param {number} x - input number',
    '* @returns {number} x squared',
    '*',
    '* @example',
    '* var y = square( 2.0 );',
    '* // returns 4.0',
    '*/',
    'function square( x ) {',
    '  return x*x;',
    '}'
].join( '\n' );

linter.defineRule( 'jsdoc-leading-description-sentence', rule );

result = linter.verify( code, {
    'rules': {
        'jsdoc-leading-description-sentence': 'error'
    }
});
console.log( result );
/* =>
    [
        {
            'ruleId': 'jsdoc-leading-description-sentence',
            'severity': 2,
            'message': 'Description must start with an uppercase letter or number and end with a period',
            'line': 1,
            'column': 1,
            'nodeType': null,
            'source': '/**',
            'endLine': 10,
            'endColumn': 3
        }
    ]
*/