@eslint-react/ast 2.0.0-next.40 → 2.0.0-next.44
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 +9 -9
- package/dist/index.js +7 -7
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
2
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { unit } from '@eslint-react/eff';
|
|
4
4
|
|
|
5
5
|
declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
6
6
|
declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
@@ -20,7 +20,7 @@ type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TS
|
|
|
20
20
|
type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
|
|
21
21
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
22
22
|
|
|
23
|
-
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier |
|
|
23
|
+
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Recursively get the inner expression until it's not a TypeExpression
|
|
@@ -37,7 +37,7 @@ declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
|
37
37
|
* where JS gives anonymous function expressions names. We roughly detect the
|
|
38
38
|
* same AST nodes with some exceptions to better fit our use case.
|
|
39
39
|
*/
|
|
40
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier |
|
|
40
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
|
|
41
41
|
|
|
42
42
|
type FunctionInitPath =
|
|
43
43
|
/**
|
|
@@ -137,7 +137,7 @@ readonly [TSESTree.FunctionDeclaration]
|
|
|
137
137
|
TSESTree.PropertyDefinition,
|
|
138
138
|
TSESTreeFunction
|
|
139
139
|
];
|
|
140
|
-
declare function getFunctionInitPath(node: TSESTreeFunction):
|
|
140
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
141
141
|
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
142
142
|
|
|
143
143
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
@@ -149,14 +149,14 @@ declare function isImmediatelyInvokedFunction(node: TSESTreeFunction): boolean;
|
|
|
149
149
|
* @param test The test function
|
|
150
150
|
* @returns The parent node that satisfies the test function or `_` if not found
|
|
151
151
|
*/
|
|
152
|
-
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node |
|
|
152
|
+
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
|
|
153
153
|
/**
|
|
154
154
|
* Find the parent node that satisfies the test function or `_` if not found
|
|
155
155
|
* @param node The AST node
|
|
156
156
|
* @param test The test function
|
|
157
157
|
* @returns The parent node that satisfies the test function
|
|
158
158
|
*/
|
|
159
|
-
declare function findParentNode(node: TSESTree.Node |
|
|
159
|
+
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Get all nested identifiers in a expression like node
|
|
@@ -264,7 +264,7 @@ declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined
|
|
|
264
264
|
* @param node The AST node
|
|
265
265
|
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
266
266
|
*/
|
|
267
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null |
|
|
267
|
+
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
268
268
|
/**
|
|
269
269
|
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
|
|
270
270
|
* @param node The AST node
|
|
@@ -272,9 +272,9 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TS
|
|
|
272
272
|
* @param value The string literal value to compare against
|
|
273
273
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
274
274
|
*/
|
|
275
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null |
|
|
275
|
+
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
276
276
|
|
|
277
|
-
declare function getPropertyName(node: TSESTree.Node): string |
|
|
277
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
278
278
|
|
|
279
279
|
declare function isThenCall(node: TSESTree.CallExpression): boolean;
|
|
280
280
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
|
-
import { or, dual,
|
|
2
|
+
import { or, dual, unit } from '@eslint-react/eff';
|
|
3
3
|
import { ASTUtils } from '@typescript-eslint/utils';
|
|
4
4
|
import { simpleTraverse } from '@typescript-eslint/typescript-estree';
|
|
5
5
|
import { toLowerCase, delimiterCase, replace } from 'string-ts';
|
|
@@ -43,7 +43,7 @@ function getClassId(node) {
|
|
|
43
43
|
if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
44
44
|
return node.parent.id;
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return unit;
|
|
47
47
|
}
|
|
48
48
|
var is = ASTUtils.isNodeOfType;
|
|
49
49
|
var isOneOf = ASTUtils.isNodeOfTypes;
|
|
@@ -230,7 +230,7 @@ function getFunctionId(node) {
|
|
|
230
230
|
case isTypeAssertionExpression(node.parent):
|
|
231
231
|
return getFunctionId(node.parent);
|
|
232
232
|
}
|
|
233
|
-
return
|
|
233
|
+
return unit;
|
|
234
234
|
}
|
|
235
235
|
function getFunctionInitPath(node) {
|
|
236
236
|
if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
|
|
@@ -251,7 +251,7 @@ function getFunctionInitPath(node) {
|
|
|
251
251
|
case (parent.type === AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === AST_NODE_TYPES.ClassDeclaration):
|
|
252
252
|
return [parent.parent.parent, parent.parent, parent, node];
|
|
253
253
|
}
|
|
254
|
-
return
|
|
254
|
+
return unit;
|
|
255
255
|
}
|
|
256
256
|
function hasCallInFunctionInitPath(callName, initPath) {
|
|
257
257
|
return initPath.some((n) => {
|
|
@@ -275,7 +275,7 @@ function isImmediatelyInvokedFunction(node) {
|
|
|
275
275
|
return node.type !== AST_NODE_TYPES.FunctionDeclaration && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
276
276
|
}
|
|
277
277
|
function findParentNode(node, test) {
|
|
278
|
-
if (node == null) return
|
|
278
|
+
if (node == null) return unit;
|
|
279
279
|
let parent = node.parent;
|
|
280
280
|
while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
|
|
281
281
|
if (test(parent)) {
|
|
@@ -283,7 +283,7 @@ function findParentNode(node, test) {
|
|
|
283
283
|
}
|
|
284
284
|
parent = parent.parent;
|
|
285
285
|
}
|
|
286
|
-
return
|
|
286
|
+
return unit;
|
|
287
287
|
}
|
|
288
288
|
function getNestedIdentifiers(node) {
|
|
289
289
|
const identifiers = [];
|
|
@@ -586,7 +586,7 @@ function getPropertyName(node) {
|
|
|
586
586
|
if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
|
|
587
587
|
return node.quasis[0]?.value.raw;
|
|
588
588
|
}
|
|
589
|
-
return
|
|
589
|
+
return unit;
|
|
590
590
|
}
|
|
591
591
|
function isThenCall(node) {
|
|
592
592
|
return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "then";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.44",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"./package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@typescript-eslint/types": "^8.
|
|
31
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
32
|
-
"@typescript-eslint/utils": "^8.
|
|
30
|
+
"@typescript-eslint/types": "^8.34.0",
|
|
31
|
+
"@typescript-eslint/typescript-estree": "^8.34.0",
|
|
32
|
+
"@typescript-eslint/utils": "^8.34.0",
|
|
33
33
|
"string-ts": "^2.2.1",
|
|
34
34
|
"ts-pattern": "^5.7.1",
|
|
35
|
-
"@eslint-react/eff": "2.0.0-next.
|
|
35
|
+
"@eslint-react/eff": "2.0.0-next.44"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsup": "^8.5.0",
|