@eslint-react/ast 1.52.3-beta.1 → 1.52.3-beta.11
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 +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +6 -6
- package/dist/index.mjs +7 -7
- package/package.json +5 -5
package/dist/index.d.mts
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;
|
|
@@ -25,7 +25,7 @@ type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TS
|
|
|
25
25
|
* @param node The AST node to check
|
|
26
26
|
* @returns class identifier or null
|
|
27
27
|
*/
|
|
28
|
-
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier
|
|
28
|
+
declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Recursively get the inner expression until it's not a TypeExpression
|
|
@@ -43,7 +43,7 @@ declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
|
43
43
|
* same AST nodes with some exceptions to better fit our use case.
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier
|
|
46
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): unit | TSESTree.Identifier;
|
|
47
47
|
|
|
48
48
|
type FunctionInitPath =
|
|
49
49
|
/**
|
|
@@ -143,7 +143,7 @@ readonly [TSESTree.FunctionDeclaration]
|
|
|
143
143
|
TSESTree.PropertyDefinition,
|
|
144
144
|
TSESTreeFunction
|
|
145
145
|
];
|
|
146
|
-
declare function getFunctionInitPath(node: TSESTreeFunction):
|
|
146
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
147
147
|
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
148
148
|
|
|
149
149
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
@@ -154,14 +154,14 @@ declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
|
154
154
|
* @param test The test function
|
|
155
155
|
* @returns The parent node that satisfies the test function or `_` if not found
|
|
156
156
|
*/
|
|
157
|
-
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node |
|
|
157
|
+
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
|
|
158
158
|
/**
|
|
159
159
|
* Find the parent node that satisfies the test function or `_` if not found
|
|
160
160
|
* @param node The AST node
|
|
161
161
|
* @param test The test function
|
|
162
162
|
* @returns The parent node that satisfies the test function
|
|
163
163
|
*/
|
|
164
|
-
declare function findParentNode(node: TSESTree.Node |
|
|
164
|
+
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Get all nested identifiers in a expression like node
|
|
@@ -260,7 +260,7 @@ declare const isNodeEqual: {
|
|
|
260
260
|
* @param node The AST node
|
|
261
261
|
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
262
262
|
*/
|
|
263
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null |
|
|
263
|
+
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
264
264
|
/**
|
|
265
265
|
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
|
|
266
266
|
* @param node The AST node
|
|
@@ -268,9 +268,9 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TS
|
|
|
268
268
|
* @param value The string literal value to compare against
|
|
269
269
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
270
270
|
*/
|
|
271
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null |
|
|
271
|
+
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
272
272
|
|
|
273
|
-
declare function getPropertyName(node: TSESTree.Node): string |
|
|
273
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
274
274
|
|
|
275
275
|
declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
276
276
|
/**
|
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;
|
|
@@ -25,7 +25,7 @@ type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TS
|
|
|
25
25
|
* @param node The AST node to check
|
|
26
26
|
* @returns class identifier or null
|
|
27
27
|
*/
|
|
28
|
-
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier
|
|
28
|
+
declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Recursively get the inner expression until it's not a TypeExpression
|
|
@@ -43,7 +43,7 @@ declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
|
43
43
|
* same AST nodes with some exceptions to better fit our use case.
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier
|
|
46
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): unit | TSESTree.Identifier;
|
|
47
47
|
|
|
48
48
|
type FunctionInitPath =
|
|
49
49
|
/**
|
|
@@ -143,7 +143,7 @@ readonly [TSESTree.FunctionDeclaration]
|
|
|
143
143
|
TSESTree.PropertyDefinition,
|
|
144
144
|
TSESTreeFunction
|
|
145
145
|
];
|
|
146
|
-
declare function getFunctionInitPath(node: TSESTreeFunction):
|
|
146
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
147
147
|
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
148
148
|
|
|
149
149
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
@@ -154,14 +154,14 @@ declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
|
154
154
|
* @param test The test function
|
|
155
155
|
* @returns The parent node that satisfies the test function or `_` if not found
|
|
156
156
|
*/
|
|
157
|
-
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node |
|
|
157
|
+
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
|
|
158
158
|
/**
|
|
159
159
|
* Find the parent node that satisfies the test function or `_` if not found
|
|
160
160
|
* @param node The AST node
|
|
161
161
|
* @param test The test function
|
|
162
162
|
* @returns The parent node that satisfies the test function
|
|
163
163
|
*/
|
|
164
|
-
declare function findParentNode(node: TSESTree.Node |
|
|
164
|
+
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Get all nested identifiers in a expression like node
|
|
@@ -260,7 +260,7 @@ declare const isNodeEqual: {
|
|
|
260
260
|
* @param node The AST node
|
|
261
261
|
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
262
262
|
*/
|
|
263
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null |
|
|
263
|
+
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
264
264
|
/**
|
|
265
265
|
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
|
|
266
266
|
* @param node The AST node
|
|
@@ -268,9 +268,9 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TS
|
|
|
268
268
|
* @param value The string literal value to compare against
|
|
269
269
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
270
270
|
*/
|
|
271
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null |
|
|
271
|
+
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
272
272
|
|
|
273
|
-
declare function getPropertyName(node: TSESTree.Node): string |
|
|
273
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
274
274
|
|
|
275
275
|
declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
276
276
|
/**
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function getClassId(node) {
|
|
|
45
45
|
if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
|
|
46
46
|
return node.parent.id;
|
|
47
47
|
}
|
|
48
|
-
return eff.
|
|
48
|
+
return eff.unit;
|
|
49
49
|
}
|
|
50
50
|
var is = utils.ASTUtils.isNodeOfType;
|
|
51
51
|
var isOneOf = utils.ASTUtils.isNodeOfTypes;
|
|
@@ -232,7 +232,7 @@ function getFunctionId(node) {
|
|
|
232
232
|
case isTypeAssertionExpression(node.parent):
|
|
233
233
|
return getFunctionId(node.parent);
|
|
234
234
|
}
|
|
235
|
-
return eff.
|
|
235
|
+
return eff.unit;
|
|
236
236
|
}
|
|
237
237
|
function getFunctionInitPath(node) {
|
|
238
238
|
if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) {
|
|
@@ -253,7 +253,7 @@ function getFunctionInitPath(node) {
|
|
|
253
253
|
case (parent.type === types.AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration):
|
|
254
254
|
return [parent.parent.parent, parent.parent, parent, node];
|
|
255
255
|
}
|
|
256
|
-
return eff.
|
|
256
|
+
return eff.unit;
|
|
257
257
|
}
|
|
258
258
|
function hasCallInFunctionInitPath(callName, initPath) {
|
|
259
259
|
return initPath.some((n) => {
|
|
@@ -274,7 +274,7 @@ function isEmptyFunction(node) {
|
|
|
274
274
|
return node.body.type === types.AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
|
|
275
275
|
}
|
|
276
276
|
function findParentNode(node, test) {
|
|
277
|
-
if (node == null) return eff.
|
|
277
|
+
if (node == null) return eff.unit;
|
|
278
278
|
let parent = node.parent;
|
|
279
279
|
while (parent != null && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
280
280
|
if (test(parent)) {
|
|
@@ -282,7 +282,7 @@ function findParentNode(node, test) {
|
|
|
282
282
|
}
|
|
283
283
|
parent = parent.parent;
|
|
284
284
|
}
|
|
285
|
-
return eff.
|
|
285
|
+
return eff.unit;
|
|
286
286
|
}
|
|
287
287
|
function getNestedIdentifiers(node) {
|
|
288
288
|
const identifiers = [];
|
|
@@ -550,7 +550,7 @@ function getPropertyName(node) {
|
|
|
550
550
|
if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
|
|
551
551
|
return node.quasis[0]?.value.raw;
|
|
552
552
|
}
|
|
553
|
-
return eff.
|
|
553
|
+
return eff.unit;
|
|
554
554
|
}
|
|
555
555
|
function getLiteralValueType(input) {
|
|
556
556
|
if (input === null) return "null";
|
package/dist/index.mjs
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) => {
|
|
@@ -272,7 +272,7 @@ function isEmptyFunction(node) {
|
|
|
272
272
|
return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
|
|
273
273
|
}
|
|
274
274
|
function findParentNode(node, test) {
|
|
275
|
-
if (node == null) return
|
|
275
|
+
if (node == null) return unit;
|
|
276
276
|
let parent = node.parent;
|
|
277
277
|
while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
|
|
278
278
|
if (test(parent)) {
|
|
@@ -280,7 +280,7 @@ function findParentNode(node, test) {
|
|
|
280
280
|
}
|
|
281
281
|
parent = parent.parent;
|
|
282
282
|
}
|
|
283
|
-
return
|
|
283
|
+
return unit;
|
|
284
284
|
}
|
|
285
285
|
function getNestedIdentifiers(node) {
|
|
286
286
|
const identifiers = [];
|
|
@@ -548,7 +548,7 @@ function getPropertyName(node) {
|
|
|
548
548
|
if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
|
|
549
549
|
return node.quasis[0]?.value.raw;
|
|
550
550
|
}
|
|
551
|
-
return
|
|
551
|
+
return unit;
|
|
552
552
|
}
|
|
553
553
|
function getLiteralValueType(input) {
|
|
554
554
|
if (input === null) return "null";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "1.52.3-beta.
|
|
3
|
+
"version": "1.52.3-beta.11",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/types": "^8.
|
|
39
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
40
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/types": "^8.35.1",
|
|
39
|
+
"@typescript-eslint/typescript-estree": "^8.35.1",
|
|
40
|
+
"@typescript-eslint/utils": "^8.35.1",
|
|
41
41
|
"string-ts": "^2.2.1",
|
|
42
42
|
"ts-pattern": "^5.7.1",
|
|
43
|
-
"@eslint-react/eff": "1.52.3-beta.
|
|
43
|
+
"@eslint-react/eff": "1.52.3-beta.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"tsup": "^8.5.0",
|