When the includePageLocatorMethods: true option is enabled, the missing-playwright-await rule correctly flags missing awaits on page.* and locator.* methods. However, it fails to recognise the await keyword if the method is called using optional chaining (?.), leading to a false positive.
Reproduction:
import { test } from '@playwright/test';
test('missing await test', async ({ page }) => {
// ❌ This incorrectly throws: "'unrouteAll' must be awaited or returned"
await page?.unrouteAll();
// ✅ This passes fine
await page.unrouteAll();
});
ESLint Config:
{
"rules": {
"playwright/missing-playwright-await": ["error", { "includePageLocatorMethods": true }]
}
}
Expected Behavior: The rule should recognize that await page?.unrouteAll() is correctly awaited and not throw an error.
Cause: This appears to happen because the AST node for optional chaining (ChainExpression containing a CallExpression) is structured differently than a standard CallExpression, causing the rule's await traversal to miss it.
When the includePageLocatorMethods: true option is enabled, the missing-playwright-await rule correctly flags missing awaits on page.* and locator.* methods. However, it fails to recognise the await keyword if the method is called using optional chaining (?.), leading to a false positive.
Reproduction:
ESLint Config:
Expected Behavior: The rule should recognize that await page?.unrouteAll() is correctly awaited and not throw an error.
Cause: This appears to happen because the AST node for optional chaining (ChainExpression containing a CallExpression) is structured differently than a standard CallExpression, causing the rule's await traversal to miss it.