@eslint-react/ast 2.7.5-next.1 → 2.7.5-next.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.ts CHANGED
@@ -22,7 +22,7 @@ declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | unit;
22
22
  //#endregion
23
23
  //#region src/equal.d.ts
24
24
  /**
25
- * Determines whether node equals to another node
25
+ * Determine whether node equals to another node
26
26
  * @param a node to compare
27
27
  * @param b node to compare
28
28
  * @returns `true` if node equal
@@ -44,7 +44,7 @@ declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.
44
44
  //#endregion
45
45
  //#region src/expression-is.d.ts
46
46
  /**
47
- * Checks if the given expression is a 'this' expression.
47
+ * Check if the given expression is a 'this' expression.
48
48
  * Unwraps any type expressions before checking.
49
49
  *
50
50
  * @param node The expression node to check
@@ -106,14 +106,14 @@ type FunctionID = ReturnType<typeof getFunctionId>;
106
106
  type FunctionInitPath = readonly [TSESTree.FunctionDeclaration] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
107
107
  /**
108
108
  * Identifies the initialization path of a function node in the AST.
109
- * Determines what kind of component declaration pattern the function belongs to.
109
+ * Determine what kind of component declaration pattern the function belongs to.
110
110
  *
111
111
  * @param node The function node to analyze
112
112
  * @returns The function initialization path or unit if not identifiable
113
113
  */
114
114
  declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
115
115
  /**
116
- * Checks if a specific function call exists in the function initialization path.
116
+ * Check if a specific function call exists in the function initialization path.
117
117
  * Useful for detecting HOCs like React.memo, React.forwardRef, etc.
118
118
  *
119
119
  * @param callName The name of the call to check for (e.g., "memo", "forwardRef")
@@ -250,14 +250,14 @@ declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTre
250
250
  //#endregion
251
251
  //#region src/vitest-mock.d.ts
252
252
  /**
253
- * Checks if the given node is a `vi.mock`.
253
+ * Check if the given node is a `vi.mock`.
254
254
  * @param node The node to check
255
255
  * @returns `true` if the node is a `vi.mock`, otherwise `false`.
256
256
  * @internal
257
257
  */
258
258
  declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
259
259
  /**
260
- * Checks if the given node is a `vi.mock` callback.
260
+ * Check if the given node is a `vi.mock` callback.
261
261
  * @param node The node to check
262
262
  * @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
263
263
  * @internal
package/dist/index.js CHANGED
@@ -102,7 +102,7 @@ function getUnderlyingExpression(node) {
102
102
  //#endregion
103
103
  //#region src/equal.ts
104
104
  /**
105
- * Determines whether node equals to another node
105
+ * Determine whether node equals to another node
106
106
  * @param a node to compare
107
107
  * @param b node to compare
108
108
  * @returns `true` if node equal
@@ -143,7 +143,7 @@ const isNodeEqual = dual(2, (a, b) => {
143
143
  //#endregion
144
144
  //#region src/expression-is.ts
145
145
  /**
146
- * Checks if the given expression is a 'this' expression.
146
+ * Check if the given expression is a 'this' expression.
147
147
  * Unwraps any type expressions before checking.
148
148
  *
149
149
  * @param node The expression node to check
@@ -176,19 +176,19 @@ function getNestedIdentifiers(node) {
176
176
  const identifiers = [];
177
177
  if (node.type === AST_NODE_TYPES.Identifier) identifiers.push(node);
178
178
  if ("arguments" in node) {
179
- const chunk = node.arguments.map(getNestedIdentifiers).flat(1);
179
+ const chunk = node.arguments.flatMap(getNestedIdentifiers);
180
180
  identifiers.push(...chunk);
181
181
  }
182
182
  if ("elements" in node) {
183
- const chunk = node.elements.filter((x) => x != null).map(getNestedIdentifiers).flat(1);
183
+ const chunk = node.elements.filter((x) => x != null).flatMap(getNestedIdentifiers);
184
184
  identifiers.push(...chunk);
185
185
  }
186
186
  if ("properties" in node) {
187
- const chunk = node.properties.map(getNestedIdentifiers).flat(1);
187
+ const chunk = node.properties.flatMap(getNestedIdentifiers);
188
188
  identifiers.push(...chunk);
189
189
  }
190
190
  if ("expressions" in node) {
191
- const chunk = node.expressions.map(getNestedIdentifiers).flat(1);
191
+ const chunk = node.expressions.flatMap(getNestedIdentifiers);
192
192
  identifiers.push(...chunk);
193
193
  }
194
194
  if ("left" in node) {
@@ -256,12 +256,12 @@ function getNestedReturnStatements(node) {
256
256
  */
257
257
  function getNestedExpressionsOfType(type) {
258
258
  const isNodeOfType = is(type);
259
- return function(node) {
259
+ return (node) => {
260
260
  const boundGetNestedExpressionsOfType = getNestedExpressionsOfType(type);
261
261
  const expressions = [];
262
262
  if (isNodeOfType(node)) expressions.push(node);
263
263
  if ("arguments" in node) {
264
- const chunk = node.arguments.map(getNestedExpressionsOfType(type)).flat(1);
264
+ const chunk = node.arguments.flatMap(getNestedExpressionsOfType(type));
265
265
  expressions.push(...chunk);
266
266
  }
267
267
  if ("expression" in node && node.expression !== true && node.expression !== false) {
@@ -281,23 +281,23 @@ function getNestedExpressionsOfType(type) {
281
281
  expressions.push(...chunk);
282
282
  }
283
283
  if ("consequent" in node) {
284
- const chunk = Array.isArray(node.consequent) ? node.consequent.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.consequent);
284
+ const chunk = Array.isArray(node.consequent) ? node.consequent.flatMap(boundGetNestedExpressionsOfType) : boundGetNestedExpressionsOfType(node.consequent);
285
285
  expressions.push(...chunk);
286
286
  }
287
287
  if ("alternate" in node && node.alternate != null) {
288
- const chunk = Array.isArray(node.alternate) ? node.alternate.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.alternate);
288
+ const chunk = Array.isArray(node.alternate) ? node.alternate.flatMap(boundGetNestedExpressionsOfType) : boundGetNestedExpressionsOfType(node.alternate);
289
289
  expressions.push(...chunk);
290
290
  }
291
291
  if ("elements" in node) {
292
- const chunk = node.elements.filter((x) => x != null).map(getNestedExpressionsOfType(type)).flat(1);
292
+ const chunk = node.elements.filter((x) => x != null).flatMap(getNestedExpressionsOfType(type));
293
293
  expressions.push(...chunk);
294
294
  }
295
295
  if ("properties" in node) {
296
- const chunk = node.properties.map(boundGetNestedExpressionsOfType).flat(1);
296
+ const chunk = node.properties.flatMap(boundGetNestedExpressionsOfType);
297
297
  expressions.push(...chunk);
298
298
  }
299
299
  if ("expressions" in node) {
300
- const chunk = node.expressions.map(boundGetNestedExpressionsOfType).flat(1);
300
+ const chunk = node.expressions.flatMap(boundGetNestedExpressionsOfType);
301
301
  expressions.push(...chunk);
302
302
  }
303
303
  if (node.type === AST_NODE_TYPES.Property) {
@@ -374,7 +374,7 @@ function getFunctionId(node) {
374
374
  //#region src/function-init-path.ts
375
375
  /**
376
376
  * Identifies the initialization path of a function node in the AST.
377
- * Determines what kind of component declaration pattern the function belongs to.
377
+ * Determine what kind of component declaration pattern the function belongs to.
378
378
  *
379
379
  * @param node The function node to analyze
380
380
  * @returns The function initialization path or unit if not identifiable
@@ -424,7 +424,7 @@ function getFunctionInitPath(node) {
424
424
  return unit;
425
425
  }
426
426
  /**
427
- * Checks if a specific function call exists in the function initialization path.
427
+ * Check if a specific function call exists in the function initialization path.
428
428
  * Useful for detecting HOCs like React.memo, React.forwardRef, etc.
429
429
  *
430
430
  * @param callName The name of the call to check for (e.g., "memo", "forwardRef")
@@ -594,7 +594,7 @@ const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
594
594
  //#endregion
595
595
  //#region src/vitest-mock.ts
596
596
  /**
597
- * Checks if the given node is a `vi.mock`.
597
+ * Check if the given node is a `vi.mock`.
598
598
  * @param node The node to check
599
599
  * @returns `true` if the node is a `vi.mock`, otherwise `false`.
600
600
  * @internal
@@ -603,7 +603,7 @@ function isViMock(node) {
603
603
  return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.object.name === "vi" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "mock";
604
604
  }
605
605
  /**
606
- * Checks if the given node is a `vi.mock` callback.
606
+ * Check if the given node is a `vi.mock` callback.
607
607
  * @param node The node to check
608
608
  * @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
609
609
  * @internal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "2.7.5-next.1",
3
+ "version": "2.7.5-next.11",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -30,11 +30,11 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/types": "^8.53.1",
34
- "@typescript-eslint/typescript-estree": "^8.53.1",
35
- "@typescript-eslint/utils": "^8.53.1",
33
+ "@typescript-eslint/types": "^8.54.0",
34
+ "@typescript-eslint/typescript-estree": "^8.54.0",
35
+ "@typescript-eslint/utils": "^8.54.0",
36
36
  "string-ts": "^2.3.1",
37
- "@eslint-react/eff": "2.7.5-next.1"
37
+ "@eslint-react/eff": "2.7.5-next.11"
38
38
  },
39
39
  "devDependencies": {
40
40
  "tsdown": "^0.20.1",