@eslint-react/var 5.17.3 → 5.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +29 -25
- package/dist/index.js +28 -22
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -5,58 +5,57 @@ import { RuleContext } from "@eslint-react/eslint";
|
|
|
5
5
|
/**
|
|
6
6
|
* Get the arguments of a require expression.
|
|
7
7
|
* @param node The node to match.
|
|
8
|
-
* @returns The require expression arguments or null if the node is not a require expression.
|
|
8
|
+
* @returns The require expression arguments or `null` if the node is not a require expression.
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
declare function getRequireExpressionArguments(node: TSESTree.Node): TSESTree.CallExpressionArgument[] | null;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/is-assignment-target-equal.d.ts
|
|
14
14
|
/**
|
|
15
|
-
* Check if two assignment targets are equal
|
|
16
|
-
* Compares nodes directly or by their values.
|
|
15
|
+
* Check if two assignment targets are equal, either directly or by their values.
|
|
17
16
|
* @param context The rule context.
|
|
18
17
|
* @param a The first node to compare.
|
|
19
18
|
* @param b The second node to compare.
|
|
20
|
-
* @returns
|
|
19
|
+
* @returns `true` if the assignment targets are equal.
|
|
21
20
|
* @internal
|
|
22
21
|
*/
|
|
23
22
|
declare function isAssignmentTargetEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
24
23
|
//#endregion
|
|
25
24
|
//#region src/is-initialized-from-react.d.ts
|
|
26
25
|
/**
|
|
27
|
-
* Check if a variable is initialized from React import.
|
|
28
|
-
* @internal
|
|
26
|
+
* Check if a variable is initialized from a React import.
|
|
29
27
|
* @param name The variable name.
|
|
30
28
|
* @param initialScope The initial scope.
|
|
31
29
|
* @param importSource Alternative import source of React (ex: "preact/compat").
|
|
32
|
-
* @returns
|
|
30
|
+
* @returns `true` if the variable is initialized or derived from a React import.
|
|
31
|
+
* @internal
|
|
33
32
|
*/
|
|
34
33
|
declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
|
|
35
34
|
//#endregion
|
|
36
35
|
//#region src/is-initialized-from-react-native.d.ts
|
|
37
36
|
/**
|
|
38
|
-
* if a variable is initialized from React Native import.
|
|
39
|
-
* @internal
|
|
37
|
+
* Check if a variable is initialized from a React Native import.
|
|
40
38
|
* @param name The variable name.
|
|
41
39
|
* @param initialScope The initial scope.
|
|
42
40
|
* @param importSource Alternative import source of React Native (ex: "react-native-web").
|
|
43
|
-
* @returns
|
|
41
|
+
* @returns `true` if the variable is initialized from a React Native import.
|
|
42
|
+
* @internal
|
|
44
43
|
*/
|
|
45
44
|
declare function isInitializedFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
|
|
46
45
|
//#endregion
|
|
47
46
|
//#region src/is-value-equal.d.ts
|
|
48
47
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param context rule context.
|
|
51
|
-
* @param a node to compare.
|
|
52
|
-
* @param b node to compare.
|
|
53
|
-
* @returns `true` if node
|
|
48
|
+
* Check if the value of a node equals the value of another node.
|
|
49
|
+
* @param context The rule context.
|
|
50
|
+
* @param a The first node to compare.
|
|
51
|
+
* @param b The second node to compare.
|
|
52
|
+
* @returns `true` if the node values are equal.
|
|
54
53
|
*/
|
|
55
54
|
declare function isValueEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
56
55
|
//#endregion
|
|
57
56
|
//#region src/resolve.d.ts
|
|
58
57
|
/**
|
|
59
|
-
*
|
|
58
|
+
* Resolve an identifier to the AST node that represents its value,
|
|
60
59
|
* suitable for use in ESLint rule analysis.
|
|
61
60
|
*
|
|
62
61
|
* The resolution follows these rules per definition type:
|
|
@@ -92,18 +91,23 @@ declare function resolve(context: RuleContext, node: TSESTree.Identifier, option
|
|
|
92
91
|
//#endregion
|
|
93
92
|
//#region src/resolve-enclosing-assignment-target.d.ts
|
|
94
93
|
/**
|
|
95
|
-
*
|
|
94
|
+
* Resolve the enclosing assignment target (variable, property, etc.) of a node.
|
|
96
95
|
*
|
|
97
96
|
* @param node The starting node.
|
|
98
|
-
* @returns The enclosing assignment target node, or null if not found.
|
|
97
|
+
* @returns The enclosing assignment target node, or `null` if not found.
|
|
99
98
|
*/
|
|
100
99
|
declare function resolveEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEnumDeclaration | TSESTree.TSInstantiationExpression | TSESTree.TSInterfaceDeclaration | TSESTree.TSModuleDeclarationGlobal | TSESTree.TSModuleDeclarationModuleWithIdentifierId | TSESTree.TSModuleDeclarationModuleWithStringIdDeclared | TSESTree.TSModuleDeclarationModuleWithStringIdNotDeclared | TSESTree.TSModuleDeclarationNamespace | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.ConstDeclaration | TSESTree.LetOrVarDeclaredDeclaration | TSESTree.LetOrVarNonDeclaredDeclaration | TSESTree.UsingInForOfDeclaration | TSESTree.UsingInNormalContextDeclaration | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
|
|
101
|
-
/**
|
|
102
|
-
* Type representing the possible assignment targets returned by `resolveEnclosingAssignmentTarget`.
|
|
103
|
-
*/
|
|
100
|
+
/** The possible assignment targets returned by {@link resolveEnclosingAssignmentTarget}. */
|
|
104
101
|
type AssignmentTarget = ReturnType<typeof resolveEnclosingAssignmentTarget>;
|
|
105
102
|
//#endregion
|
|
106
103
|
//#region src/resolve-import-source.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Resolve the import source of a variable by walking its latest definition.
|
|
106
|
+
* @param name The variable name.
|
|
107
|
+
* @param initialScope The initial scope.
|
|
108
|
+
* @param seen The set of already visited variable names (for cycle detection).
|
|
109
|
+
* @returns The import source, or `null` if it cannot be resolved.
|
|
110
|
+
*/
|
|
107
111
|
declare function resolveImportSource(name: string, initialScope: Scope, seen?: Set<string>): string | null;
|
|
108
112
|
//#endregion
|
|
109
113
|
//#region src/resolve-object-type.d.ts
|
|
@@ -137,10 +141,10 @@ type ObjectType = {
|
|
|
137
141
|
reason?: string;
|
|
138
142
|
};
|
|
139
143
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param context The context
|
|
142
|
-
* @param node The node to
|
|
143
|
-
* @returns The
|
|
144
|
+
* Resolve the object type of the given node.
|
|
145
|
+
* @param context The rule context.
|
|
146
|
+
* @param node The node to resolve.
|
|
147
|
+
* @returns The object type of the node, or `null` if it cannot be resolved.
|
|
144
148
|
*/
|
|
145
149
|
declare function resolveObjectType(context: RuleContext, node: TSESTree.Node | null): ObjectType | null;
|
|
146
150
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { P, isMatching } from "ts-pattern";
|
|
|
8
8
|
/**
|
|
9
9
|
* Get the arguments of a require expression.
|
|
10
10
|
* @param node The node to match.
|
|
11
|
-
* @returns The require expression arguments or null if the node is not a require expression.
|
|
11
|
+
* @returns The require expression arguments or `null` if the node is not a require expression.
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
function getRequireExpressionArguments(node) {
|
|
@@ -24,7 +24,7 @@ function getRequireExpressionArguments(node) {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/resolve.ts
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Resolve an identifier to the AST node that represents its value,
|
|
28
28
|
* suitable for use in ESLint rule analysis.
|
|
29
29
|
*
|
|
30
30
|
* The resolution follows these rules per definition type:
|
|
@@ -90,11 +90,11 @@ const thisBlockTypes = [
|
|
|
90
90
|
AST_NODE_TYPES.Program
|
|
91
91
|
];
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @param context rule context.
|
|
95
|
-
* @param a node to compare.
|
|
96
|
-
* @param b node to compare.
|
|
97
|
-
* @returns `true` if node
|
|
93
|
+
* Check if the value of a node equals the value of another node.
|
|
94
|
+
* @param context The rule context.
|
|
95
|
+
* @param a The first node to compare.
|
|
96
|
+
* @param b The second node to compare.
|
|
97
|
+
* @returns `true` if the node values are equal.
|
|
98
98
|
*/
|
|
99
99
|
function isValueEqual(context, a, b) {
|
|
100
100
|
a = Check.isTypeExpression(a) ? Extract.unwrap(a) : a;
|
|
@@ -152,12 +152,11 @@ function isValueEqual(context, a, b) {
|
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/is-assignment-target-equal.ts
|
|
154
154
|
/**
|
|
155
|
-
* Check if two assignment targets are equal
|
|
156
|
-
* Compares nodes directly or by their values.
|
|
155
|
+
* Check if two assignment targets are equal, either directly or by their values.
|
|
157
156
|
* @param context The rule context.
|
|
158
157
|
* @param a The first node to compare.
|
|
159
158
|
* @param b The second node to compare.
|
|
160
|
-
* @returns
|
|
159
|
+
* @returns `true` if the assignment targets are equal.
|
|
161
160
|
* @internal
|
|
162
161
|
*/
|
|
163
162
|
function isAssignmentTargetEqual(context, a, b) {
|
|
@@ -166,6 +165,13 @@ function isAssignmentTargetEqual(context, a, b) {
|
|
|
166
165
|
|
|
167
166
|
//#endregion
|
|
168
167
|
//#region src/resolve-import-source.ts
|
|
168
|
+
/**
|
|
169
|
+
* Resolve the import source of a variable by walking its latest definition.
|
|
170
|
+
* @param name The variable name.
|
|
171
|
+
* @param initialScope The initial scope.
|
|
172
|
+
* @param seen The set of already visited variable names (for cycle detection).
|
|
173
|
+
* @returns The import source, or `null` if it cannot be resolved.
|
|
174
|
+
*/
|
|
169
175
|
function resolveImportSource(name, initialScope, seen = /* @__PURE__ */ new Set()) {
|
|
170
176
|
if (seen.has(name)) return null;
|
|
171
177
|
seen.add(name);
|
|
@@ -190,12 +196,12 @@ function resolveImportSource(name, initialScope, seen = /* @__PURE__ */ new Set(
|
|
|
190
196
|
//#endregion
|
|
191
197
|
//#region src/is-initialized-from-react.ts
|
|
192
198
|
/**
|
|
193
|
-
* Check if a variable is initialized from React import.
|
|
194
|
-
* @internal
|
|
199
|
+
* Check if a variable is initialized from a React import.
|
|
195
200
|
* @param name The variable name.
|
|
196
201
|
* @param initialScope The initial scope.
|
|
197
202
|
* @param importSource Alternative import source of React (ex: "preact/compat").
|
|
198
|
-
* @returns
|
|
203
|
+
* @returns `true` if the variable is initialized or derived from a React import.
|
|
204
|
+
* @internal
|
|
199
205
|
*/
|
|
200
206
|
function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
201
207
|
return name.toLowerCase() === "react" || Boolean(resolveImportSource(name, initialScope)?.startsWith(importSource));
|
|
@@ -204,12 +210,12 @@ function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
|
204
210
|
//#endregion
|
|
205
211
|
//#region src/is-initialized-from-react-native.ts
|
|
206
212
|
/**
|
|
207
|
-
* if a variable is initialized from React Native import.
|
|
208
|
-
* @internal
|
|
213
|
+
* Check if a variable is initialized from a React Native import.
|
|
209
214
|
* @param name The variable name.
|
|
210
215
|
* @param initialScope The initial scope.
|
|
211
216
|
* @param importSource Alternative import source of React Native (ex: "react-native-web").
|
|
212
|
-
* @returns
|
|
217
|
+
* @returns `true` if the variable is initialized from a React Native import.
|
|
218
|
+
* @internal
|
|
213
219
|
*/
|
|
214
220
|
function isInitializedFromReactNative(name, initialScope, importSource = "react-native") {
|
|
215
221
|
return [
|
|
@@ -222,10 +228,10 @@ function isInitializedFromReactNative(name, initialScope, importSource = "react-
|
|
|
222
228
|
//#endregion
|
|
223
229
|
//#region src/resolve-enclosing-assignment-target.ts
|
|
224
230
|
/**
|
|
225
|
-
*
|
|
231
|
+
* Resolve the enclosing assignment target (variable, property, etc.) of a node.
|
|
226
232
|
*
|
|
227
233
|
* @param node The starting node.
|
|
228
|
-
* @returns The enclosing assignment target node, or null if not found.
|
|
234
|
+
* @returns The enclosing assignment target node, or `null` if not found.
|
|
229
235
|
*/
|
|
230
236
|
function resolveEnclosingAssignmentTarget(node) {
|
|
231
237
|
switch (true) {
|
|
@@ -241,10 +247,10 @@ function resolveEnclosingAssignmentTarget(node) {
|
|
|
241
247
|
//#endregion
|
|
242
248
|
//#region src/resolve-object-type.ts
|
|
243
249
|
/**
|
|
244
|
-
*
|
|
245
|
-
* @param context The context
|
|
246
|
-
* @param node The node to
|
|
247
|
-
* @returns The
|
|
250
|
+
* Resolve the object type of the given node.
|
|
251
|
+
* @param context The rule context.
|
|
252
|
+
* @param node The node to resolve.
|
|
253
|
+
* @returns The object type of the node, or `null` if it cannot be resolved.
|
|
248
254
|
*/
|
|
249
255
|
function resolveObjectType(context, node) {
|
|
250
256
|
if (node == null) return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module for static analysis of variables.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
33
|
-
"@typescript-eslint/types": "^8.
|
|
34
|
-
"@typescript-eslint/utils": "^8.
|
|
32
|
+
"@typescript-eslint/scope-manager": "^8.65.0",
|
|
33
|
+
"@typescript-eslint/types": "^8.65.0",
|
|
34
|
+
"@typescript-eslint/utils": "^8.65.0",
|
|
35
35
|
"ts-pattern": "^5.9.0",
|
|
36
|
-
"@eslint-react/
|
|
37
|
-
"@eslint-react/
|
|
36
|
+
"@eslint-react/ast": "5.18.0",
|
|
37
|
+
"@eslint-react/eslint": "5.18.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@typescript-eslint/parser": "^8.
|
|
41
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
40
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
41
|
+
"@typescript-eslint/typescript-estree": "^8.65.0",
|
|
42
42
|
"eslint": "^10.7.0",
|
|
43
|
-
"tsdown": "^0.22.
|
|
43
|
+
"tsdown": "^0.22.13",
|
|
44
44
|
"typescript": "6.0.3",
|
|
45
45
|
"vitest": "^4.1.10",
|
|
46
46
|
"@local/configs": "0.0.0",
|