@eslint-react/core 5.28.8 → 5.30.0-beta.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 CHANGED
@@ -4,7 +4,6 @@ import { TSESTree } from "@typescript-eslint/types";
4
4
  import { RegExpLike } from "@eslint-react/shared";
5
5
  import ts from "typescript";
6
6
  import { ESLintUtils } from "@typescript-eslint/utils";
7
- //#region src/api.d.ts
8
7
  export declare namespace isAPI {
9
8
  /** The dual-signature predicate type returned by {@link isAPI}. */
10
9
  type ReturnType = {
@@ -165,16 +164,12 @@ export declare const isUseStateCall: isAPICall.ReturnType;
165
164
  export declare const isUseSyncExternalStoreCall: isAPICall.ReturnType;
166
165
  /** Check if the node is a call expression to the React `useTransition` API. */
167
166
  export declare const isUseTransitionCall: isAPICall.ReturnType;
168
- //#endregion
169
- //#region src/class.d.ts
170
167
  /**
171
168
  * Get the class identifier of a class node.
172
169
  * @param node The class node to get the identifier from.
173
170
  * @returns The class identifier or `null` if not found.
174
171
  */
175
172
  export declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | null;
176
- //#endregion
177
- //#region src/semantic.d.ts
178
173
  /**
179
174
  * Represents a semantic node in the AST.
180
175
  * This is the base interface for all semantic nodes in the React semantic analysis.
@@ -217,8 +212,6 @@ export interface SemanticFunc extends SemanticNode {
217
212
  /** The type parameters of the function. */
218
213
  typeParameters: TSESTree.TSTypeParameterDeclaration | null;
219
214
  }
220
- //#endregion
221
- //#region src/class-component.d.ts
222
215
  /**
223
216
  * @deprecated Class components are legacy. This type exists only to support legacy rules.
224
217
  */
@@ -250,7 +243,7 @@ export declare function isClassComponent(node: TSESTree.Node): node is TSESTreeC
250
243
  * @returns `true` if the node is a pure component.
251
244
  * @deprecated Class components are legacy. This function exists only to support legacy rules.
252
245
  */
253
- export declare function isPureComponent(node: TSESTree.Node): boolean;
246
+ export declare function isPureComponent(node: TSESTreeClass): boolean;
254
247
  /** @deprecated Class components are legacy. */
255
248
  export declare const isRender: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
256
249
  /** @deprecated Class components are legacy. */
@@ -315,8 +308,6 @@ export declare function isRenderMethodCallback(node: TSESTreeFunction): boolean;
315
308
  * @deprecated Class components are legacy. This function exists only to support legacy rules.
316
309
  */
317
310
  export declare function isThisSetStateCall(node: TSESTree.CallExpression): boolean;
318
- //#endregion
319
- //#region src/class-component-collector.d.ts
320
311
  /**
321
312
  * @deprecated Class components are legacy. This namespace exists only to support legacy rules.
322
313
  */
@@ -335,8 +326,6 @@ export declare namespace getClassComponentCollector {
335
326
  * @deprecated Class components are legacy. This function exists only to support legacy rules.
336
327
  */
337
328
  export declare function getClassComponentCollector(context: RuleContext): getClassComponentCollector.ReturnType;
338
- //#endregion
339
- //#region src/create-element.d.ts
340
329
  /**
341
330
  * Get the type argument (the first argument) of a `createElement` call.
342
331
  * @param context The ESLint rule context.
@@ -398,8 +387,6 @@ export declare function isCreateElementChildrenArgument(context: RuleContext, no
398
387
  * @returns `true` if the node is directly inside `createElement`'s props object.
399
388
  */
400
389
  export declare function isInsideCreateElementProps(context: RuleContext, node: TSESTree.Node): boolean;
401
- //#endregion
402
- //#region src/function.d.ts
403
390
  /** The return type of {@link getFunctionId}. */
404
391
  export type FunctionID = ReturnType<typeof getFunctionId>;
405
392
  /**
@@ -443,7 +430,7 @@ export type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSe
443
430
  * @param node The function node to analyze.
444
431
  * @returns The identifier node if found, `null` otherwise.
445
432
  */
446
- export declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | 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.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
433
+ export declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ClassExpression | TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.CallExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSTypeAssertion | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.ChainExpression | TSESTree.ConditionalExpression | TSESTree.ImportExpression | TSESTree.LogicalExpression | TSESTree.NewExpression | TSESTree.PrivateIdentifier | TSESTree.TSInstantiationExpression | TSESTree.TSSatisfiesExpression | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
447
434
  /**
448
435
  * Get the initialization path of a function node in the AST.
449
436
  *
@@ -499,8 +486,6 @@ export type FunctionDisplayNameAssignment = TSESTree.AssignmentExpression & {
499
486
  };
500
487
  /** The esquery selector matching `displayName` assignment expressions with a statically determinable property name. */
501
488
  export declare const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT: string;
502
- //#endregion
503
- //#region src/hook.d.ts
504
489
  /**
505
490
  * Represents a semantic hook node in the AST.
506
491
  */
@@ -538,54 +523,52 @@ export declare function isHookId(id: TSESTree.Node): id is TSESTree.Identifier |
538
523
  * @param tag The expression node to check.
539
524
  * @returns `true` if the expression is a hook identifier or member expression with hook name, `false` otherwise.
540
525
  */
541
- export declare function isHookTag(tag: TSESTree.Node | null): boolean;
526
+ export declare function isHookTag(tag: TSESTree.Node): boolean;
542
527
  /**
543
528
  * Check if the function node is a hook definition based on its name.
544
529
  * @param node The function node to check.
545
530
  * @returns `true` if the function is a hook definition.
546
531
  */
547
- export declare function isHookDefinition(node: TSESTreeFunction | null): boolean;
532
+ export declare function isHookDefinition(node: TSESTreeFunction): boolean;
548
533
  /**
549
534
  * Check if the node is a React Hook call by its name.
550
535
  * @param node The node to check.
551
536
  * @returns `true` if the node is a React Hook call, `false` otherwise.
552
537
  */
553
- export declare function isHookCall(node: TSESTree.Node | null): node is TSESTree.CallExpression;
538
+ export declare function isHookCall(node: TSESTree.CallExpression): boolean;
554
539
  /**
555
540
  * Check if the node is a useRef-like call (ex: `useRef` or a custom ref hook).
556
541
  * @param node The AST node to check.
557
542
  * @param additionalRefHooks Regex pattern matching custom hooks that should be treated as ref hooks.
558
543
  * @returns `true` if the node is a useRef-like call.
559
544
  */
560
- export declare function isUseRefLikeCall(node: TSESTree.Node | null, additionalRefHooks?: RegExpLike): node is TSESTree.CallExpression;
545
+ export declare function isUseRefLikeCall(node: TSESTree.CallExpression, additionalRefHooks?: RegExpLike): boolean;
561
546
  /**
562
547
  * Check if the node is a useState-like call (ex: `useState` or a custom state hook).
563
548
  * @param node The AST node to check.
564
549
  * @param additionalStateHooks Regex pattern matching custom hooks that should be treated as state hooks.
565
550
  * @returns `true` if the node is a useState-like call.
566
551
  */
567
- export declare function isUseStateLikeCall(node: TSESTree.Node | null, additionalStateHooks?: RegExpLike): node is TSESTree.CallExpression;
552
+ export declare function isUseStateLikeCall(node: TSESTree.CallExpression, additionalStateHooks?: RegExpLike): boolean;
568
553
  /**
569
554
  * Check if the node is a useEffect-like call (ex: `useEffect`, `useLayoutEffect`, or a custom effect hook).
570
555
  * @param node The AST node to check.
571
556
  * @param additionalEffectHooks Regex pattern matching custom hooks that should be treated as effect hooks.
572
557
  * @returns `true` if the node is a useEffect-like call.
573
558
  */
574
- export declare function isUseEffectLikeCall(node: TSESTree.Node | null, additionalEffectHooks?: RegExpLike): node is TSESTree.CallExpression;
559
+ export declare function isUseEffectLikeCall(node: TSESTree.CallExpression, additionalEffectHooks?: RegExpLike): boolean;
575
560
  /**
576
561
  * Check if the node is the setup callback passed to a useEffect-like call.
577
562
  * @param node The AST node to check.
578
563
  * @returns `true` if the node is a useEffect setup callback.
579
564
  */
580
- export declare function isUseEffectSetupCallback(node: TSESTree.Node | null): boolean;
565
+ export declare function isUseEffectSetupCallback(node: TSESTree.Node): boolean;
581
566
  /**
582
567
  * Check if the node is the cleanup callback returned by a useEffect-like setup callback.
583
568
  * @param node The AST node to check.
584
569
  * @returns `true` if the node is a useEffect cleanup callback.
585
570
  */
586
- export declare function isUseEffectCleanupCallback(node: TSESTree.Node | null): boolean;
587
- //#endregion
588
- //#region src/function-component.d.ts
571
+ export declare function isUseEffectCleanupCallback(node: TSESTree.Node): boolean;
589
572
  /**
590
573
  * Represents a React Function Component.
591
574
  */
@@ -649,14 +632,14 @@ export declare function getFunctionComponentFlagFromInitPath(initPath: FunctionC
649
632
  * @param node The node to check.
650
633
  * @returns `true` if the node is a call expression for a component wrapper.
651
634
  */
652
- export declare function isFunctionComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
635
+ export declare function isFunctionComponentWrapperCall(context: RuleContext, node: TSESTree.CallExpression): boolean;
653
636
  /**
654
637
  * Check if the node is a callback function passed to a component wrapper.
655
638
  * @param context The ESLint rule context.
656
639
  * @param node The node to check.
657
640
  * @returns `true` if the node is a callback function passed to a component wrapper.
658
641
  */
659
- export declare function isFunctionComponentWrapperCallback(context: RuleContext, node: TSESTree.Node): boolean;
642
+ export declare function isFunctionComponentWrapperCallback(context: RuleContext, node: TSESTreeFunction): boolean;
660
643
  /**
661
644
  * Get function component identifier from `const Component = memo(() => {});`.
662
645
  * @param context The rule context.
@@ -732,8 +715,6 @@ export declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
732
715
  * @returns `true` if the node is considered a component definition.
733
716
  */
734
717
  export declare function isFunctionComponentDefinition(context: RuleContext, node: TSESTreeFunction, hint: bigint): boolean;
735
- //#endregion
736
- //#region src/function-component-collector.d.ts
737
718
  export declare namespace getFunctionComponentCollector {
738
719
  /** The options for {@link getFunctionComponentCollector}. */
739
720
  type Options = {
@@ -755,8 +736,6 @@ export declare namespace getFunctionComponentCollector {
755
736
  * @returns The api and visitor of the collector.
756
737
  */
757
738
  export declare function getFunctionComponentCollector(context: RuleContext, options?: getFunctionComponentCollector.Options): getFunctionComponentCollector.ReturnType;
758
- //#endregion
759
- //#region src/hook-collector.d.ts
760
739
  export declare namespace getHookCollector {
761
740
  /** The api and visitor pair returned by {@link getHookCollector}. */
762
741
  type ReturnType = {
@@ -772,8 +751,6 @@ export declare namespace getHookCollector {
772
751
  * @returns The api and visitor of the collector.
773
752
  */
774
753
  export declare function getHookCollector(context: RuleContext): getHookCollector.ReturnType;
775
- //#endregion
776
- //#region src/jsx.d.ts
777
754
  /**
778
755
  * BitFlags for configuring JSX detection behavior.
779
756
  *
@@ -846,8 +823,6 @@ export declare const DEFAULT_JSX_DETECTION_HINT: JSXDetectionHint;
846
823
  * ```
847
824
  */
848
825
  export declare function isJSXLike(context: RuleContext, node: TSESTree.Node | null, hint?: JSXDetectionHint): boolean;
849
- //#endregion
850
- //#region src/jsx-config.d.ts
851
826
  /**
852
827
  * Resolved JSX configuration derived from compiler options and / or pragma
853
828
  * annotations found in the source file.
@@ -896,8 +871,6 @@ export declare function getJSXConfigFromAnnotation(context: RuleContext): JSXCon
896
871
  * @returns Fully‑populated, merged `JSXConfig`.
897
872
  */
898
873
  export declare function getJSXConfig(context: RuleContext): Required<JSXConfig>;
899
- //#endregion
900
- //#region src/type-is.d.ts
901
874
  /**
902
875
  * Check if the type is a boolean literal type.
903
876
  * @param type The type to check.
@@ -1063,8 +1036,6 @@ export declare const isTruthyStringType: (type: ts.Type) => boolean;
1063
1036
  * @internal
1064
1037
  */
1065
1038
  export declare const isUnknownType: (type: ts.Type) => boolean;
1066
- //#endregion
1067
- //#region src/type-name.d.ts
1068
1039
  /**
1069
1040
  * Get the fully qualified name of a symbol, handling cases that `ts.TypeChecker.getFullyQualifiedName` does not handle (ex: `export as namespace preact`).
1070
1041
  * @param checker The TypeScript type checker.
@@ -1072,8 +1043,6 @@ export declare const isUnknownType: (type: ts.Type) => boolean;
1072
1043
  * @returns The fully qualified name of the symbol.
1073
1044
  */
1074
1045
  export declare function getFullyQualifiedNameEx(checker: ts.TypeChecker, symbol: ts.Symbol): string;
1075
- //#endregion
1076
- //#region src/type-variant.d.ts
1077
1046
  /** Represents the variant of a type for boolean expression analysis. */
1078
1047
  export type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" | "number" | "object" | "string" | "unknown" | "falsy bigint" | "falsy boolean" | "falsy number" | "falsy string" | "truthy bigint" | "truthy boolean" | "truthy number" | "truthy string";
1079
1048
  /**
@@ -1083,5 +1052,4 @@ export type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nul
1083
1052
  * @remarks Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements.
1084
1053
  * @internal
1085
1054
  */
1086
- export declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
1087
- //#endregion
1055
+ export declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { resolve } from "@eslint-react/var";
6
6
  import { findVariable } from "@typescript-eslint/utils/ast-utils";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
8
  import ts from "typescript";
9
- //#region src/api.ts
9
+ // src/api.ts
10
10
  function isAPI(api) {
11
11
  function impl(context, node) {
12
12
  if (node == null) return false;
@@ -94,15 +94,13 @@ const isUseRefCall = isAPICall("useRef");
94
94
  const isUseStateCall = isAPICall("useState");
95
95
  const isUseSyncExternalStoreCall = isAPICall("useSyncExternalStore");
96
96
  const isUseTransitionCall = isAPICall("useTransition");
97
- //#endregion
98
- //#region src/class.ts
97
+ // src/class.ts
99
98
  function getClassId(node) {
100
99
  if (node.id != null) return node.id;
101
100
  if (node.parent.type === AST_NODE_TYPES.VariableDeclarator) return node.parent.id;
102
101
  return null;
103
102
  }
104
- //#endregion
105
- //#region ../../.pkgs/eff/dist/index.js
103
+ // ../../.pkgs/eff/dist/index.js
106
104
  const pipeArguments = (self, args) => {
107
105
  switch (args.length) {
108
106
  case 0: return self;
@@ -201,8 +199,7 @@ dual(2, (self, predicate) => {
201
199
  while (idx < len && predicate(input[idx], idx)) idx++;
202
200
  return input.slice(0, idx);
203
201
  });
204
- //#endregion
205
- //#region src/class-component.ts
202
+ // src/class-component.ts
206
203
  function getStaticKeyName(key, computed) {
207
204
  if (!computed && Check.isIdentifier(key)) return key.name;
208
205
  if (key.type === AST_NODE_TYPES.Literal && isString(key.value)) return key.value;
@@ -222,7 +219,7 @@ function isClassComponent(node) {
222
219
  return false;
223
220
  }
224
221
  function isPureComponent(node) {
225
- if (hasProperty(node, "superClass") && node.superClass != null) {
222
+ if (node.superClass != null) {
226
223
  const re = /^PureComponent$/u;
227
224
  switch (true) {
228
225
  case Check.isIdentifier(node.superClass): return re.test(node.superClass.name);
@@ -269,8 +266,7 @@ function isThisSetStateCall(node) {
269
266
  const callee = Extract.unwrap(node.callee);
270
267
  return callee.type === AST_NODE_TYPES.MemberExpression && Extract.unwrap(callee.object).type === AST_NODE_TYPES.ThisExpression && Extract.getCalleeName(node) === "setState";
271
268
  }
272
- //#endregion
273
- //#region src/class-component-collector.ts
269
+ // src/class-component-collector.ts
274
270
  function getClassComponentCollector(context) {
275
271
  const components = /* @__PURE__ */ new Map();
276
272
  const collect = (node) => {
@@ -300,8 +296,7 @@ function getClassComponentCollector(context) {
300
296
  }
301
297
  };
302
298
  }
303
- //#endregion
304
- //#region src/create-element.ts
299
+ // src/create-element.ts
305
300
  function getCreateElementTypeArgument(context, node) {
306
301
  if (!isCreateElementCall(context, node)) return null;
307
302
  return node.arguments[0] ?? null;
@@ -337,8 +332,7 @@ function isInsideCreateElementProps(context, node) {
337
332
  if (propsArg == null) return false;
338
333
  return prop === Extract.unwrap(propsArg);
339
334
  }
340
- //#endregion
341
- //#region src/function.ts
335
+ // src/function.ts
342
336
  function getFunctionId(node) {
343
337
  switch (true) {
344
338
  case hasProperty(node, "id") && node.id != null: return node.id;
@@ -438,8 +432,7 @@ const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT = [
438
432
  "[left.computed=true][left.property.type='Literal'][left.property.value='displayName']",
439
433
  ")"
440
434
  ].join("");
441
- //#endregion
442
- //#region src/jsx.ts
435
+ // src/jsx.ts
443
436
  const JSXDetectionHint = {
444
437
  None: 0n,
445
438
  DoNotIncludeJSXWithNullValue: 1n << 0n,
@@ -494,8 +487,7 @@ function isJSXLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
494
487
  }
495
488
  return visit(node);
496
489
  }
497
- //#endregion
498
- //#region src/function-component.ts
490
+ // src/function-component.ts
499
491
  const FunctionComponentFlag = {
500
492
  None: 0n,
501
493
  PureComponent: 1n << 0n,
@@ -510,11 +502,9 @@ function getFunctionComponentFlagFromInitPath(initPath) {
510
502
  return flag;
511
503
  }
512
504
  function isFunctionComponentWrapperCall(context, node) {
513
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
514
505
  return isMemoCall(context, node) || isForwardRefCall(context, node);
515
506
  }
516
507
  function isFunctionComponentWrapperCallback(context, node) {
517
- if (!Check.isFunction(node)) return false;
518
508
  let argument = node;
519
509
  let parent = node.parent;
520
510
  while (Check.isTypeExpression(parent)) {
@@ -602,8 +592,7 @@ function isFunctionComponentDefinition(context, node, hint) {
602
592
  if (significantParent == null) return true;
603
593
  return significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
604
594
  }
605
- //#endregion
606
- //#region src/hook.ts
595
+ // src/hook.ts
607
596
  function isHookName(name) {
608
597
  return name === "use" || /^use[A-Z0-9]/.test(name);
609
598
  }
@@ -615,11 +604,9 @@ function isHookId(id) {
615
604
  }
616
605
  }
617
606
  function isHookTag(tag) {
618
- if (tag == null) return false;
619
607
  return isHookId(Extract.unwrap(tag));
620
608
  }
621
609
  function isHookDefinition(node) {
622
- if (node == null) return false;
623
610
  const id = getFunctionId(node);
624
611
  switch (id?.type) {
625
612
  case AST_NODE_TYPES.Identifier: return isHookName(id.name);
@@ -628,35 +615,26 @@ function isHookDefinition(node) {
628
615
  }
629
616
  }
630
617
  function isHookCall(node) {
631
- if (node == null) return false;
632
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
633
618
  const name = Extract.getCalleeName(node);
634
619
  if (name == null) return false;
635
620
  return isHookName(name);
636
621
  }
637
622
  function isUseRefLikeCall(node, additionalRefHooks = { test: constFalse }) {
638
- if (node == null) return false;
639
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
640
623
  const name = Extract.getCalleeName(node);
641
624
  if (name == null) return false;
642
625
  return name === "useRef" || additionalRefHooks.test(name);
643
626
  }
644
627
  function isUseStateLikeCall(node, additionalStateHooks = { test: constFalse }) {
645
- if (node == null) return false;
646
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
647
628
  const name = Extract.getCalleeName(node);
648
629
  if (name == null) return false;
649
630
  return name === "useState" || additionalStateHooks.test(name);
650
631
  }
651
632
  function isUseEffectLikeCall(node, additionalEffectHooks = { test: constFalse }) {
652
- if (node == null) return false;
653
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
654
633
  const name = Extract.getCalleeName(node);
655
634
  if (name == null) return false;
656
635
  return /^use\w*Effect$/u.test(name) || additionalEffectHooks.test(name);
657
636
  }
658
637
  function isUseEffectSetupCallback(node) {
659
- if (node == null) return false;
660
638
  const expr = Extract.unwrap(node);
661
639
  const call = Traverse.findParent(expr, not(Check.isTypeOrChainExpression));
662
640
  if (call?.type !== AST_NODE_TYPES.CallExpression) return false;
@@ -665,7 +643,6 @@ function isUseEffectSetupCallback(node) {
665
643
  return Extract.unwrap(arg0) === expr && isUseEffectLikeCall(call);
666
644
  }
667
645
  function isUseEffectCleanupCallback(node) {
668
- if (node == null) return false;
669
646
  const expr = Extract.unwrap(node);
670
647
  const func = Traverse.findParent(expr, Check.isFunction);
671
648
  if (func == null || !isUseEffectSetupCallback(func)) return false;
@@ -673,8 +650,7 @@ function isUseEffectCleanupCallback(node) {
673
650
  if (stat != null) return stat.argument != null && Extract.unwrap(stat.argument) === expr;
674
651
  return Check.isFunction(expr) && func.type === AST_NODE_TYPES.ArrowFunctionExpression && Extract.unwrap(func.body) === expr;
675
652
  }
676
- //#endregion
677
- //#region src/function-component-collector.ts
653
+ // src/function-component-collector.ts
678
654
  function getFunctionComponentCollector(context, options = {}) {
679
655
  const { collectDisplayName = false, hint = DEFAULT_COMPONENT_DETECTION_HINT } = options;
680
656
  const functionEntries = [];
@@ -765,8 +741,7 @@ function getFunctionComponentCollector(context, options = {}) {
765
741
  }
766
742
  };
767
743
  }
768
- //#endregion
769
- //#region src/hook-collector.ts
744
+ // src/hook-collector.ts
770
745
  function getHookCollector(context) {
771
746
  const functionEntries = [];
772
747
  const hooks = /* @__PURE__ */ new Map();
@@ -828,8 +803,7 @@ function getHookCollector(context) {
828
803
  }
829
804
  };
830
805
  }
831
- //#endregion
832
- //#region src/jsx-config.ts
806
+ // src/jsx-config.ts
833
807
  const annotationCache = /* @__PURE__ */ new WeakMap();
834
808
  const mergedCache = /* @__PURE__ */ new WeakMap();
835
809
  function getJSXConfigFromCompilerOptions(context) {
@@ -875,8 +849,7 @@ function getJSXConfig(context) {
875
849
  mergedCache.set(context.sourceCode, merged);
876
850
  return merged;
877
851
  }
878
- //#endregion
879
- //#region src/type-is.ts
852
+ // src/type-is.ts
880
853
  function isFlagSet(allFlags, flag) {
881
854
  return (allFlags & flag) !== 0;
882
855
  }
@@ -903,8 +876,7 @@ const isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { b
903
876
  const isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
904
877
  const isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
905
878
  const isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
906
- //#endregion
907
- //#region src/type-name.ts
879
+ // src/type-name.ts
908
880
  function getFullyQualifiedNameEx(checker, symbol) {
909
881
  let name = symbol.name;
910
882
  let parent = symbol.declarations?.at(0)?.parent;
@@ -948,8 +920,7 @@ function getFullyQualifiedNameEx(checker, symbol) {
948
920
  if (name.startsWith(`${namespace}.`)) return name;
949
921
  return `${namespace}.${name}`;
950
922
  }
951
- //#endregion
952
- //#region src/type-variant.ts
923
+ // src/type-variant.ts
953
924
  function getTypeVariants(types) {
954
925
  const variants = /* @__PURE__ */ new Set();
955
926
  if (types.some(isUnknownType)) {
@@ -985,5 +956,4 @@ function getTypeVariants(types) {
985
956
  if (types.some(isNeverType)) variants.add("never");
986
957
  return variants;
987
958
  }
988
- //#endregion
989
959
  export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JSXDetectionHint, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getCreateElementChildrenArguments, getCreateElementProp, getCreateElementPropsObject, getCreateElementTypeArgument, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getJSXConfig, getJSXConfigFromAnnotation, getJSXConfigFromCompilerOptions, getTypeVariants, isAPI, isAPICall, isAnyType, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateElementChildrenArgument, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionEmpty, isFunctionHasCallInInitPath, isFunctionHasDirective, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isHookTag, isInsideCreateElementProps, isJSXLike, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseRefLikeCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.28.8",
3
+ "version": "5.30.0-beta.0",
4
4
  "description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.28.8",
33
- "@eslint-react/eslint": "5.28.8",
34
- "@eslint-react/shared": "5.28.8",
35
- "@eslint-react/var": "5.28.8",
32
+ "@eslint-react/ast": "5.30.0-beta.0",
33
+ "@eslint-react/eslint": "5.30.0-beta.0",
34
+ "@eslint-react/shared": "5.30.0-beta.0",
35
+ "@eslint-react/var": "5.30.0-beta.0",
36
36
  "@typescript-eslint/types": "^8.72.0",
37
37
  "@typescript-eslint/utils": "^8.72.0",
38
38
  "ts-pattern": "^5.9.2"
@@ -46,7 +46,7 @@
46
46
  "@typescript-eslint/typescript-estree": "^8.72.0",
47
47
  "dedent": "^1.7.2",
48
48
  "eslint": "^10.13.0",
49
- "tsdown": "^0.23.1",
49
+ "tsdown": "^0.23.2",
50
50
  "typescript": "6.0.3",
51
51
  "vitest": "^5.0.5"
52
52
  },