|
1 | | -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -- ignore |
2 | | -/* eslint-disable @typescript-eslint/no-explicit-any -- ignore */ |
3 | | -import type { AST } from "vue-eslint-parser"; |
4 | | -import type { RuleContext } from "../../../types"; |
5 | | -// @ts-expect-error -- no type def |
6 | 1 | import * as eslintUtils from "@eslint-community/eslint-utils"; |
7 | 2 | import type { Variable } from "eslint-scope"; |
| 3 | +import type { AST } from "vue-eslint-parser"; |
| 4 | + |
| 5 | +import type { RuleContext } from "../../../types"; |
8 | 6 | import { getSourceCode } from "../../compat"; |
9 | 7 |
|
10 | 8 | /** |
@@ -58,8 +56,8 @@ export function getStringLiteralValue( |
58 | 56 | ): string | null { |
59 | 57 | if (node.type === "Literal") { |
60 | 58 | if (node.value == null) { |
61 | | - if ((node as any).bigint != null) { |
62 | | - return String((node as any).bigint); |
| 59 | + if (node.bigint != null) { |
| 60 | + return String(node.bigint); |
63 | 61 | } |
64 | 62 | } |
65 | 63 | return String(node.value); |
@@ -88,8 +86,12 @@ function findVariable( |
88 | 86 | export function getStaticValue( |
89 | 87 | context: RuleContext, |
90 | 88 | node: AST.ESLintNode, |
91 | | -): { value: any } | null { |
92 | | - return eslintUtils.getStaticValue(node, getScope(context, node)); |
| 89 | +): { value?: unknown; optional?: boolean } | null { |
| 90 | + return eslintUtils.getStaticValue( |
| 91 | + // @ts-expect-error -- `eslintUtils` is typed now but incompatible with Vue AST typings |
| 92 | + node, |
| 93 | + getScope(context, node), |
| 94 | + ); |
93 | 95 | } |
94 | 96 |
|
95 | 97 | /** |
@@ -140,9 +142,13 @@ function getScope(context: RuleContext, currentNode: AST.ESLintNode) { |
140 | 142 | const inner = currentNode.type !== "Program"; |
141 | 143 | const scopeManager = getSourceCode(context).scopeManager; |
142 | 144 |
|
143 | | - let node: any = currentNode; |
| 145 | + let node: AST.Node | null = currentNode; |
144 | 146 | for (; node; node = node.parent || null) { |
145 | | - const scope = scopeManager.acquire(node, inner); |
| 147 | + const scope = scopeManager.acquire( |
| 148 | + // @ts-expect-error -- incompatible with Vue AST typings |
| 149 | + node, |
| 150 | + inner, |
| 151 | + ); |
146 | 152 |
|
147 | 153 | if (scope) { |
148 | 154 | if (scope.type === "function-expression-name") { |
|
0 commit comments