Skip to content

[require-hook] Add option to allow class calls #1386

Open

Description

Hi,
I have a lot of tests that are really similar, so I built a class that scaffolds all the tests and invoke it in my test file like so:

new NodeExtensionTester(new ExtensionToTest())
  .shouldMatchUnistNode({ type: "thematicBreak" })
  .shouldNotMatchUnistNode({ type: "horizontal_rule" })
  .shouldNotMatchUnistNode({ type: "other" })
  .runTests();

However, this triggers jest/require-hook. In that rule, there is the allowedFunctionCalls option. However, when I printed getNodeName(node) here, I got

NodeExtensionTester.shouldMatchUnistNode.shouldNotMatchUnistNode.shouldNotMatchUnistNode.runTests

... which is ugly and depends on all the methods called, so there's not really any point to using allowedFunctionCalls for this (instead of disable comments or disabling the rule altogether)

Could we add something like allowedClasses?

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions