-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathno-wait-for-selector.ts
42 lines (41 loc) · 1.21 KB
/
no-wait-for-selector.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { isPageMethod } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
export default createRule({
create(context) {
return {
CallExpression(node) {
if (isPageMethod(node, 'waitForSelector')) {
context.report({
messageId: 'noWaitForSelector',
node,
suggest: [
{
fix: (fixer) =>
fixer.remove(
node.parent && node.parent.type !== 'AwaitExpression'
? node.parent
: node.parent.parent,
),
messageId: 'removeWaitForSelector',
},
],
})
}
},
}
},
meta: {
docs: {
category: 'Best Practices',
description: 'Prevent usage of page.waitForSelector()',
recommended: true,
url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-wait-for-selector.md',
},
hasSuggestions: true,
messages: {
noWaitForSelector: 'Unexpected use of page.waitForSelector().',
removeWaitForSelector: 'Remove the page.waitForSelector() method.',
},
type: 'suggestion',
},
})