Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 1.93 KB

File metadata and controls

92 lines (70 loc) · 1.93 KB

ts-prefer-function-type

Inspired by typescript-eslint's prefer-function-type rule.

Chooses the more succinct function property over a call signature if there are no other properties on the signature.

Options

A single options object has the following properties.

enableFixer

Whether to enable the fixer or not

Context everywhere
Tags ``
Recommended false
Settings
Options enableFixer

Failing examples

The following patterns are considered problems:

/**
 * @param {{
 *   (arg: string): void;
 * }} someName
 */
// Message: Call signature found; function type preferred.

/**
 * @param {{
 *   (arg: string): void;
 * }} someName
 */
// "jsdoc/ts-prefer-function-type": ["error"|"warn", {"enableFixer":false}]
// Message: Call signature found; function type preferred.

/**
 * @param {(string | {
 *   (arg: string): void;
 * })} someName
 */
// Message: Call signature found; function type preferred.

Passing examples

The following patterns are not considered problems:

/**
 * @param {() => number} someName
 */

/**
 * @param {{
 *   (arg: string): void;
 *   abc: number;
 * }} someName
 */

/**
 * @param {{
 *   (data: string): number;
 *   (id: number): string;
 * }} someName
 */

/**
 * @param {BadType<} someName
 */