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

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

Closed
tarngerine opened this issue Aug 16, 2023 · 2 comments
Closed
Labels

Comments

@tarngerine
Copy link

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

@tarngerine tarngerine changed the title Add require option for require-jsdoc to support constant exports Add require option for require-jsdoc to support constant exports for HoC Aug 16, 2023
@brettz9
Copy link
Collaborator

brettz9 commented Aug 16, 2023

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

@brettz9 brettz9 closed this as completed Aug 16, 2023
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 16, 2023
@tarngerine
Copy link
Author

tarngerine commented Aug 16, 2023 via email

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

No branches or pull requests

2 participants