Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsdoc/require-returns: Fails inside classes and interfaces #767

Closed
iliubinskii opened this issue Jul 13, 2021 · 2 comments
Closed

jsdoc/require-returns: Fails inside classes and interfaces #767

iliubinskii opened this issue Jul 13, 2021 · 2 comments

Comments

@iliubinskii
Copy link

Expected behavior

Should show error for class method, interface method, interface function-type property, and function.

NOTE:
I have checked that jsdoc/require-jsdoc works in all 4 cases. So, I expect jsdoc/require-returns to work where jsdoc/require-jsdoc works.

NOTE 2:
I see the lack of unification between rules.
I see that jsdoc/require-jsdoc has 4 options that determine where this rule is apply: checkConstructors, checkGetters, checkSetters, contexts.
I would expect all other rules to have these options.
However, some rules have none of the 4.
And some have only contexts option, but not the other 3.

Actual behavior

Shows error only for the function.

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
        }
      }
    ],
    "jsdoc/require-returns": [
      "warn",
      {
        contexts
      }
    ]
  }
};

ESLint sample

export class A {
  /**
   * Description.
   */
  public f(): string {
    return "";
  }
}

export interface B {
  /**
   * Description.
   */
  f(): string;

  /**
   * Description.
   */
  g: () => string;
}

/**
 * Description.
 */
export function f(): string {
  return "";
}

Environment

    "node": ">=14.0.0",
    "eslint": "^7.30.0",
    "eslint-plugin-jsdoc": "^35.4.3",
@gajus
Copy link
Owner

gajus commented Jul 20, 2021

🎉 This issue has been resolved in version 35.4.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jul 20, 2021
@brettz9
Copy link
Collaborator

brettz9 commented Jul 20, 2021

As per convention, I avoided treating void or undefined as triggering the error by default within the TS contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants