Skip to content

Return checks are matched against a bodyless type signature, not the function body implementation #903

@remcohaszing

Description

@remcohaszing

Expected behavior

@returns is allowed when a function has multiple type signatures, but the implementation has a return statement.

Actual behavior

jsdoc/require-returns-check disallows the @returns

ESLint Config

module.exports = {
  rules: {
    'jsdoc/require-returns-check': 'error'
  }
}

ESLint sample

/**
 * Read a test fixture.
 *
 * @param path The path to resolve relative to the fixture base. It will be normalized for the
 * operating system.
 * @param encoding The text encoding of the file.
 * @returns The file contents as a string or buffer.
 */
export function readFixture(path: string): Promise<Buffer>;
export function readFixture(path: string, encoding: BufferEncoding): Promise<string>;
export function readFixture(path: string, encoding?: BufferEncoding): Promise<Buffer | string> {
  return readFile(resolveFixture(path), encoding);
}

This also affects jsdoc/check-param-names.

Environment

  • Node version: 18.7.0
  • ESLint version: 8.22.0
  • eslint-plugin-jsdoc version: 39.3.6 (It worked fine in version 39.3.5)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions