Eslint-plugin-jsdoc: [jsdoc/require-jsdoc] : 'FunctionDeclaration' = arrow functions ignored

Created on 20 Jul 2020  路  3Comments  路  Source: gajus/eslint-plugin-jsdoc

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
bug released

All 3 comments

:tada: This issue has been resolved in version 30.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

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.

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.

Was this page helpful?
0 / 5 - 0 ratings