Skip to content

Functions passed as parameters trigger no-await-sync-query #276

@jeblackburn

Description

@jeblackburn

Hello,

I have an async function that takes a query function as a parameter:

export const chooseElementFromSomewhere = async (
    text: string, 
    getAllByLabelText: (text: string | RegExp, options?: SelectorMatcherOptions) => HTMLElement[],
): Promise<void> => {
  const someElement = getAllByLabelText(text)[0].parentElement;
  ...
  await someOtherAsyncFunction();
};

(somewhere in my test code)
await chooseElementFromSomewhere('someTextToUseInAQuery', getAllByLabelText);

Calls to this function are triggering this eslint rule:
'getAllByLabelText' does not need 'await' operator testing-library/no-await-sync-query

I think it's a bug in the eslint parsing/interpreting rule. The expected behavior would be for eslint to pass my code as it is.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions