Skip to content

jsdoc/require-jsdoc: False positive when documentation is inherited from interface #768

@iliubinskii

Description

@iliubinskii

Expected behavior

Method without documentation should pass when there is a documentation for it in an interface located in "implements" section.

I have checked that this situation is correctly handled by typedoc (https://www.npmjs.com/package/typedoc) and vscode editor.
Both extract documentation from interface.

See that vscode undestands this situation:
Sample

Actual behavior

The rule shows error in the situation described above.

ESLint Config

const contexts = [
  ":not(BlockStatement) > FunctionDeclaration",
  "MethodDefinition",
  "TSMethodSignature",
  "TSPropertySignature > TSTypeAnnotation > TSFunctionType"
];

module.exports = {
  rules: {
    "jsdoc/require-jsdoc": [
      "warn",
      {
        checkConstructors: true,
        checkGetters: true,
        checkSetters: true,
        contexts,
        require: {
          ArrowFunctionExpression: false,
          ClassDeclaration: false,
          ClassExpression: false,
          FunctionDeclaration: false,
          FunctionExpression: false,
          MethodDefinition: false
        }
      }
    ]
  }
};

ESLint sample

export interface A {
  /**
   * Documentation.
   */
  f(): void;
}

export class B implements A {
  public f(): void {
    //
  }
}

new B().f();

Environment

    "node": ">=14.0.0",
    "eslint": "^7.30.0",
    "eslint-plugin-jsdoc": "^35.4.3",

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions