← Back

jsdoc/check-param-names warning

Ensures that parameter names in JSDoc match those in the function declaration.

Examples

❌  Incorrect

/**
 * @param Foo
 */
function quux1 (foo = 'FOO') {

}
// Message: Expected @param names to be "foo". Got "Foo".

/**
 * @param Foo
 */
function quux2 (foo) {

}
// Message: Expected @param names to be "foo". Got "Foo".

✅  Correct

/**
 *
 */
function quux1 (foo) {

}

/**
 * @param foo
 */
function quux2 (foo) {

}

/**
 * @param foo
 * @param bar
 */
function quux3 (foo, bar) {

}

/**
 * @param foo
 * @param bar
 */
function quux4 (foo, bar, baz) {

}

/**
 * @param foo
 * @param foo.foo
 * @param bar
 */
function quux5 (foo, bar) {

}

/**
 * @param args
 */
function quux6 (...args) {

}

/**
 * @param foo
 * @param foo.a
 * @param foo.b
 */
function quux7 ({a, b}) {

}

/**
 * @param foo
 * @param foo.bar
 * @param foo.baz
 * @param bar
 */
function quux8 (foo, bar) {

}

/**
 * @param args
 * @param args.a
 * @param args.b
 */
function quux9 ({a, b} = {}) {

}

/**
 * @param foo
 * @param foo.0
 * @param foo.1
 */
function quux10 ([a, b] = []) {

}

/**
 * Assign the project to a list of employees.
 * @param {object[]} employees - The employees who are responsible for the project.
 * @param {string} employees[].name - The name of an employee.
 * @param {string} employees[].department - The employee's department.
 */
function assign (employees) {

};

export class SomeClass {
    /**
     * @param property
     */
    constructor(property) {}
}

/**
 * @param {Error} error Exit code
 * @param {number} [code = 1] Exit code
 */
function quux11 (error, code = 1) {
};