noPlaywrightUselessAwait
Summary
Section titled “Summary”- Rule available since:
v2.4.2 - Diagnostic Category:
lint/nursery/noPlaywrightUselessAwait - This rule has a safe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
playwright/no-useless-await
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noPlaywrightUselessAwait": "error" } } }}Description
Section titled “Description”Disallow unnecessary await for Playwright methods that don’t return promises.
Some Playwright methods are frequently, yet incorrectly, awaited when they return synchronous values. This includes locator methods, which return locators (not promises), and synchronous expect matchers.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”await page.locator('.my-element');code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unnecessary await expression.
> 1 │ await page.locator(‘.my-element’);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ This method does not return a Promise.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove unnecessary await
1 │ await·page.locator(‘.my-element’);
│ ------
await page.getByRole('button');code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unnecessary await expression.
> 1 │ await page.getByRole(‘button’);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ This method does not return a Promise.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove unnecessary await
1 │ await·page.getByRole(‘button’);
│ ------
await expect(1).toBe(1);code-block.js:1:1 lint/nursery/noPlaywrightUselessAwait FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unnecessary await expression.
> 1 │ await expect(1).toBe(1);
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ This method does not return a Promise.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove unnecessary await
1 │ await·expect(1).toBe(1);
│ ------
page.locator('.my-element');await page.locator('.my-element').click();page.getByRole('button');await page.getByRole('button').click();expect(1).toBe(1);await expect(page.locator('.foo')).toBeVisible();Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.