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-jsdoc] : 'FunctionDeclaration' = arrow functions ignored #612

Closed
RichardFevrier opened this issue Jul 20, 2020 · 3 comments
Closed

Comments

@RichardFevrier
Copy link

Expected behavior

When using the rule jsdoc/require-jsdoc with require with FunctionDeclaration set to true, the plugin should trigger an error on arrow functions declarations.

Actual behavior

Arrow functions declarations are ignored.

ESLint Config

module.exports = {
  root: true,
  globals: {
    'console': false
  },
  parser: "babel-eslint",
  extends: ['eslint:recommended', 'plugin:jsdoc/recommended'],
  rules: {
    'jsdoc/require-jsdoc': ['error', {
      require: {
        ArrowFunctionExpression: true,
        ClassDeclaration: false,
        ClassExpression: true,
        FunctionDeclaration: true, // <- should not ignore arrow functions
        FunctionExpression: true,
        MethodDefinition: true
      }
    }],
  },
};

ESLint sample

class Test {
  aFunc = () => {} // not detected
  anotherFunc() {} // detected
}

CLI sample

eslint myfile.js

Environment

  • Node version: 12.16.3
  • ESLint version: 6.8.0
  • eslint-plugin-jsdoc version: 30.0.0
@gajus
Copy link
Owner

gajus commented Jul 20, 2020

🎉 This issue has been resolved in version 30.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

brettz9 commented Jul 20, 2020

Thanks for the helpful reports!

There was missing support here (now fixed), but I might mention ArrowFunctionExpression is what you can use (FunctionDeclaration does not apply here with the case of ClassProperty). See https://astexplorer.net/ after setting the parser to explore the AST. Also, if you want fine-tuned control (e.g., checking arrow functions within ClassProperty only or such), you can use contexts. See the README for more.

@RichardFevrier
Copy link
Author

Thank you for your answer 🙂

And for the tips with https://astexplorer.net/
I effectively didn't know if it was ArrowFunctionExpression or FunctionDeclaration which would be triggered in that case.

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