Skip to content

Fix double await #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
14 changes: 8 additions & 6 deletions lib/rules/missing-playwright-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ function getMemberExpressionNode(node, matchers) {
return matchers.has(propertyName) ? { node, type: 'expect' } : undefined;
}

function isValid(node) {
const grandparentType =
node.parent && node.parent.parent && node.parent.parent.type;
const validTypes = new Set([
'AwaitExpression',
'ReturnStatement',
'ArrowFunctionExpression',
]);

function isValid(node) {
return (
grandparentType === 'AwaitExpression' ||
grandparentType === 'ReturnStatement' ||
grandparentType === 'ArrowFunctionExpression'
validTypes.has(node.parent?.type) ||
validTypes.has(node.parent?.parent?.type)
);
}

Expand Down
28 changes: 17 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/missing-playwright-await.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ runRuleTester('missing-playwright-await', rule, {
),
],
valid: [
valid('await expect(page).toBeEditable'),
valid('await expect(page).toEqualTitle("text")'),
valid('await expect(page).not.toHaveText("text")'),

Expand Down