|
1 | | -import { Rule } from 'eslint' |
2 | 1 | import ESTree from 'estree' |
3 | | -import { getParent, getStringValue, isIdentifier } from '../utils/ast.js' |
| 2 | +import { getStringValue, isIdentifier } from '../utils/ast.js' |
4 | 3 | import { createRule } from '../utils/createRule.js' |
5 | 4 | import { ParsedFnCall, parseFnCall } from '../utils/parseFnCall.js' |
| 5 | +import { NodeWithParent } from '../utils/types.js' |
6 | 6 |
|
7 | 7 | const validTypes = new Set([ |
8 | 8 | 'AwaitExpression', |
@@ -60,7 +60,7 @@ const playwrightTestMatchers = [ |
60 | 60 | ] |
61 | 61 |
|
62 | 62 | function getReportNode(node: ESTree.Node) { |
63 | | - const parent = getParent(node) |
| 63 | + const parent = (node as NodeWithParent).parent |
64 | 64 | return parent?.type === 'MemberExpression' ? parent : node |
65 | 65 | } |
66 | 66 |
|
@@ -95,7 +95,7 @@ export default createRule({ |
95 | 95 | ]) |
96 | 96 |
|
97 | 97 | function checkValidity(node: ESTree.Node, visited: Set<ESTree.Node>) { |
98 | | - const parent = getParent(node) |
| 98 | + const parent = (node as NodeWithParent).parent |
99 | 99 | if (!parent) return false |
100 | 100 |
|
101 | 101 | if (visited.has(parent)) return false |
@@ -129,7 +129,7 @@ export default createRule({ |
129 | 129 | const scope = context.sourceCode.getScope(parent.parent) |
130 | 130 |
|
131 | 131 | for (const ref of scope.references) { |
132 | | - const refParent = (ref.identifier as Rule.Node).parent |
| 132 | + const refParent = (ref.identifier as NodeWithParent).parent |
133 | 133 | if (visited.has(refParent)) continue |
134 | 134 | // If the parent of the reference is valid, we can immediately return |
135 | 135 | // true. Otherwise, we'll check the validity of the parent to continue |
|
0 commit comments