Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 1.7 KB

File metadata and controls

75 lines (59 loc) · 1.7 KB

reject-function-type

Reports use of Function type within JSDoc tag types.

Context everywhere
Tags augments, class, constant, enum, implements, member, module, namespace, param, property, returns, throws, type, typedef, yields
Aliases constructor, const, extends, var, arg, argument, prop, return, exception, yield
Closure-only package, private, protected, public, static
Recommended true
Settings mode
Options

Failing examples

The following patterns are considered problems:

/**
 * @param {Function} fooBar
 */
function quux (fooBar) {
  console.log(fooBar(3));
}
// Message: Prefer a more specific type to `Function`

/**
 * @param {string|Array<Function>} abc
 */
function buzz (abc) {}
// Message: Prefer a more specific type to `Function`

Passing examples

The following patterns are not considered problems:

/**
 * @param {SomeType} abc
 */
function quux (abc) {}

// To avoid referencing a generic Function, define a callback
//   with its inputs/outputs and a name.
/**
 * @callback          FOOBAR
 * @param    {number} baz
 * @return   {number}
 */


// Then reference the callback name as the type.
/**
 * @param {FOOBAR} fooBar
 */
function quux (fooBar) {
  console.log(fooBar(3));
}

/**
 * @param {string|Array<FOOBAR>} abc
 */
function buzz (abc) {}