gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.09k stars 157 forks source link

Add require option for `require-jsdoc` to support constant exports for HoC #1144

Closed tarngerine closed 1 year ago

tarngerine commented 1 year ago

Motivation

Our codebase uses HoC (i.e. mobx observer) exports for our components, and we'd like require-jsdoc to properly flag a component export with no jsdoc comments:

image

Current behavior

It doesn't trigger for this HoC pattern with these options:

  "jsdoc/require-jsdoc": [
    "warn",
    {
      publicOnly: true,
      require: {
        ArrowFunctionExpression: true,
        FunctionDeclaration: true,
        FunctionExpression: true,
        ClassDeclaration: true,
        ClassExpression: true,
        MethodDefinition: true,
      },
      enableFixer: false,
    },
  ],

Desired behavior

require-jsdoc should have an option for supporting regular assignment expressions with HoC

brettz9 commented 1 year ago

You can add to the contexts option something like the following:

          contexts: [
            'CallExpression[callee.name="observer"]',
          ],

To tweak the CallExpression further, you can introspect, using the @typescript-eslint/parser, on sample AST using https://astexplorer.net .

Closing as this should resolve, though feel free to comment further as needed

tarngerine commented 1 year ago

Perfect, thank you! On Aug 16, 2023 at 1:19 PM -0500, Brett Zamir @.***>, wrote:

Closed #1144 as completed. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>