Skip to content

New rule: no-wait-for-empty-cb #92

Closed
@Belco90

Description

@Belco90

New waitFor method added in dom-testing-library v7 introduces a new restriction on empty async utils: a callback must be passed as param. Empty callbacks are allowed but not recommended. Quoting changelog itself:

it's recommended to avoid an empty callback and instead insert an assertion in that callback function. This is because otherwise your test is relying on the "next tick of the event loop" before proceeding, and that's not consistent with the philosophy of the library:

Because of that, a new rule called no-wait-for-empty-cb could enforce to pass non-empty callbacks to waitFor.

What would be considered a non-empty callback tho? I would say any of these:

  • empty arrow function (i.e. () => {})
  • empty regular function (i.e. function () {})
  • a var referencing any of previously mentioned
  • a function or var called noop?
  • falsy values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needednew ruleNew rule to be included in the pluginreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions