@eslint-react/var 1.52.9 → 1.52.10-beta.1
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.mts +60 -55
- package/dist/index.d.ts +60 -55
- package/dist/index.js +264 -253
- package/dist/index.mjs +242 -231
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { unit } from
|
|
2
|
-
import { Scope, Variable } from
|
|
3
|
-
import { TSESTree } from
|
|
1
|
+
import { unit } from "@eslint-react/eff";
|
|
2
|
+
import { Scope, Variable } from "@typescript-eslint/scope-manager";
|
|
3
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
4
|
+
|
|
5
|
+
//#region src/var-collect.d.ts
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Get all variables from the given scope up to the global scope
|
|
@@ -9,42 +11,43 @@ import { TSESTree } from '@typescript-eslint/types';
|
|
|
9
11
|
*/
|
|
10
12
|
declare function getVariables(initialScope: Scope): Variable[];
|
|
11
13
|
declare const findVariable: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
(initialScope: Scope): (nameOrNode: string | TSESTree.Identifier | unit) => Variable | unit;
|
|
15
|
+
(nameOrNode: string | TSESTree.Identifier | unit, initialScope: Scope): Variable | unit;
|
|
14
16
|
};
|
|
15
17
|
declare function findPropertyInProperties(name: string, properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[], initialScope: Scope, seen?: Set<string>): (typeof properties)[number] | unit;
|
|
16
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/var-construction.d.ts
|
|
17
20
|
declare const ConstructionDetectionHint: {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
None: bigint;
|
|
22
|
+
StrictCallExpression: bigint;
|
|
20
23
|
};
|
|
21
24
|
type Construction = {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
kind: "ArrayExpression";
|
|
26
|
+
node: TSESTree.ArrayExpression;
|
|
24
27
|
} | {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
kind: "CallExpression";
|
|
29
|
+
node: TSESTree.CallExpression;
|
|
27
30
|
} | {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
kind: "ClassExpression";
|
|
32
|
+
node: TSESTree.ClassExpression;
|
|
30
33
|
} | {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
kind: "FunctionDeclaration";
|
|
35
|
+
node: TSESTree.FunctionDeclaration;
|
|
33
36
|
} | {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
kind: "FunctionExpression";
|
|
38
|
+
node: TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression;
|
|
36
39
|
} | {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
kind: "JSXElement";
|
|
41
|
+
node: TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
39
42
|
} | {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
kind: "NewExpression";
|
|
44
|
+
node: TSESTree.NewExpression;
|
|
42
45
|
} | {
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
kind: "ObjectExpression";
|
|
47
|
+
node: TSESTree.ObjectExpression;
|
|
45
48
|
} | {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
kind: "RegExpLiteral";
|
|
50
|
+
node: TSESTree.RegExpLiteral;
|
|
48
51
|
};
|
|
49
52
|
/**
|
|
50
53
|
* Detects the construction type of a given node.
|
|
@@ -54,39 +57,44 @@ type Construction = {
|
|
|
54
57
|
* @returns The construction type of the node, or `_` if not found.
|
|
55
58
|
*/
|
|
56
59
|
declare function getConstruction(node: TSESTree.Node | unit, initialScope: Scope, hint?: bigint): Construction | unit;
|
|
57
|
-
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/var-declarator-id.d.ts
|
|
58
62
|
declare function getVariableDeclaratorId(node: TSESTree.Node | unit, prev?: TSESTree.Node): TSESTree.BindingName | TSESTree.Expression | unit;
|
|
59
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/var-init-node.d.ts
|
|
60
65
|
declare function getVariableInitNode(variable: Variable | unit, at: number): unit | TSESTree.ClassDeclaration | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.Expression | TSESTree.FunctionDeclaration | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;
|
|
61
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/var-scope.d.ts
|
|
62
68
|
declare function getChidScopes(scope: Scope): readonly Scope[];
|
|
63
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/var-value.d.ts
|
|
64
71
|
type LazyValue = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
kind: "lazy";
|
|
73
|
+
node: TSESTree.Node;
|
|
74
|
+
initialScope: Scope | unit;
|
|
68
75
|
} | {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
kind: "none";
|
|
77
|
+
node: TSESTree.Node;
|
|
78
|
+
initialScope: Scope | unit;
|
|
72
79
|
} | {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
kind: "some";
|
|
81
|
+
node: TSESTree.Node;
|
|
82
|
+
value: unknown;
|
|
83
|
+
initialScope: Scope | unit;
|
|
77
84
|
};
|
|
78
85
|
declare function toStaticValue(lazyValue: LazyValue): {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
readonly kind: "none";
|
|
87
|
+
readonly node: TSESTree.Node;
|
|
88
|
+
readonly initialScope: Scope | undefined;
|
|
89
|
+
readonly value?: never;
|
|
83
90
|
} | {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
readonly kind: "some";
|
|
92
|
+
readonly node: TSESTree.Node;
|
|
93
|
+
readonly initialScope: Scope | undefined;
|
|
94
|
+
readonly value: unknown;
|
|
88
95
|
};
|
|
89
|
-
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/var-value-equal.d.ts
|
|
90
98
|
/**
|
|
91
99
|
* Determines whether node value equals to another node value
|
|
92
100
|
* @param a node to compare
|
|
@@ -94,9 +102,6 @@ declare function toStaticValue(lazyValue: LazyValue): {
|
|
|
94
102
|
* @param initialScopes initial scopes of the two nodes
|
|
95
103
|
* @returns `true` if node value equal
|
|
96
104
|
*/
|
|
97
|
-
declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
]): boolean;
|
|
101
|
-
|
|
102
|
-
export { type Construction, ConstructionDetectionHint, type LazyValue, findPropertyInProperties, findVariable, getChidScopes, getConstruction, getVariableDeclaratorId, getVariableInitNode, getVariables, isNodeValueEqual, toStaticValue };
|
|
105
|
+
declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [aScope: Scope, bScope: Scope]): boolean;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { Construction, ConstructionDetectionHint, LazyValue, findPropertyInProperties, findVariable, getChidScopes, getConstruction, getVariableDeclaratorId, getVariableInitNode, getVariables, isNodeValueEqual, toStaticValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { unit } from
|
|
2
|
-
import { Scope, Variable } from
|
|
3
|
-
import { TSESTree } from
|
|
1
|
+
import { unit } from "@eslint-react/eff";
|
|
2
|
+
import { Scope, Variable } from "@typescript-eslint/scope-manager";
|
|
3
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
4
|
+
|
|
5
|
+
//#region src/var-collect.d.ts
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Get all variables from the given scope up to the global scope
|
|
@@ -9,42 +11,43 @@ import { TSESTree } from '@typescript-eslint/types';
|
|
|
9
11
|
*/
|
|
10
12
|
declare function getVariables(initialScope: Scope): Variable[];
|
|
11
13
|
declare const findVariable: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
(initialScope: Scope): (nameOrNode: string | TSESTree.Identifier | unit) => Variable | unit;
|
|
15
|
+
(nameOrNode: string | TSESTree.Identifier | unit, initialScope: Scope): Variable | unit;
|
|
14
16
|
};
|
|
15
17
|
declare function findPropertyInProperties(name: string, properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[], initialScope: Scope, seen?: Set<string>): (typeof properties)[number] | unit;
|
|
16
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/var-construction.d.ts
|
|
17
20
|
declare const ConstructionDetectionHint: {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
None: bigint;
|
|
22
|
+
StrictCallExpression: bigint;
|
|
20
23
|
};
|
|
21
24
|
type Construction = {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
kind: "ArrayExpression";
|
|
26
|
+
node: TSESTree.ArrayExpression;
|
|
24
27
|
} | {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
kind: "CallExpression";
|
|
29
|
+
node: TSESTree.CallExpression;
|
|
27
30
|
} | {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
kind: "ClassExpression";
|
|
32
|
+
node: TSESTree.ClassExpression;
|
|
30
33
|
} | {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
kind: "FunctionDeclaration";
|
|
35
|
+
node: TSESTree.FunctionDeclaration;
|
|
33
36
|
} | {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
kind: "FunctionExpression";
|
|
38
|
+
node: TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression;
|
|
36
39
|
} | {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
kind: "JSXElement";
|
|
41
|
+
node: TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
39
42
|
} | {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
kind: "NewExpression";
|
|
44
|
+
node: TSESTree.NewExpression;
|
|
42
45
|
} | {
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
kind: "ObjectExpression";
|
|
47
|
+
node: TSESTree.ObjectExpression;
|
|
45
48
|
} | {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
kind: "RegExpLiteral";
|
|
50
|
+
node: TSESTree.RegExpLiteral;
|
|
48
51
|
};
|
|
49
52
|
/**
|
|
50
53
|
* Detects the construction type of a given node.
|
|
@@ -54,39 +57,44 @@ type Construction = {
|
|
|
54
57
|
* @returns The construction type of the node, or `_` if not found.
|
|
55
58
|
*/
|
|
56
59
|
declare function getConstruction(node: TSESTree.Node | unit, initialScope: Scope, hint?: bigint): Construction | unit;
|
|
57
|
-
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/var-declarator-id.d.ts
|
|
58
62
|
declare function getVariableDeclaratorId(node: TSESTree.Node | unit, prev?: TSESTree.Node): TSESTree.BindingName | TSESTree.Expression | unit;
|
|
59
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/var-init-node.d.ts
|
|
60
65
|
declare function getVariableInitNode(variable: Variable | unit, at: number): unit | TSESTree.ClassDeclaration | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.Expression | TSESTree.FunctionDeclaration | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;
|
|
61
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/var-scope.d.ts
|
|
62
68
|
declare function getChidScopes(scope: Scope): readonly Scope[];
|
|
63
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/var-value.d.ts
|
|
64
71
|
type LazyValue = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
kind: "lazy";
|
|
73
|
+
node: TSESTree.Node;
|
|
74
|
+
initialScope: Scope | unit;
|
|
68
75
|
} | {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
kind: "none";
|
|
77
|
+
node: TSESTree.Node;
|
|
78
|
+
initialScope: Scope | unit;
|
|
72
79
|
} | {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
kind: "some";
|
|
81
|
+
node: TSESTree.Node;
|
|
82
|
+
value: unknown;
|
|
83
|
+
initialScope: Scope | unit;
|
|
77
84
|
};
|
|
78
85
|
declare function toStaticValue(lazyValue: LazyValue): {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
readonly kind: "none";
|
|
87
|
+
readonly node: TSESTree.Node;
|
|
88
|
+
readonly initialScope: Scope | undefined;
|
|
89
|
+
readonly value?: never;
|
|
83
90
|
} | {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
readonly kind: "some";
|
|
92
|
+
readonly node: TSESTree.Node;
|
|
93
|
+
readonly initialScope: Scope | undefined;
|
|
94
|
+
readonly value: unknown;
|
|
88
95
|
};
|
|
89
|
-
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/var-value-equal.d.ts
|
|
90
98
|
/**
|
|
91
99
|
* Determines whether node value equals to another node value
|
|
92
100
|
* @param a node to compare
|
|
@@ -94,9 +102,6 @@ declare function toStaticValue(lazyValue: LazyValue): {
|
|
|
94
102
|
* @param initialScopes initial scopes of the two nodes
|
|
95
103
|
* @returns `true` if node value equal
|
|
96
104
|
*/
|
|
97
|
-
declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
]): boolean;
|
|
101
|
-
|
|
102
|
-
export { type Construction, ConstructionDetectionHint, type LazyValue, findPropertyInProperties, findVariable, getChidScopes, getConstruction, getVariableDeclaratorId, getVariableInitNode, getVariables, isNodeValueEqual, toStaticValue };
|
|
105
|
+
declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [aScope: Scope, bScope: Scope]): boolean;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { Construction, ConstructionDetectionHint, LazyValue, findPropertyInProperties, findVariable, getChidScopes, getConstruction, getVariableDeclaratorId, getVariableInitNode, getVariables, isNodeValueEqual, toStaticValue };
|