@eslint-react/core 2.4.0-next.9 → 2.4.1-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
@@ -729,24 +729,23 @@ declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSEST
729
729
  //#endregion
730
730
  //#region src/utils/is-from-react.d.ts
731
731
  /**
732
- * Check if an identifier name is initialized from react
733
- * @param name The top-level identifier's name
734
- * @param importSource The import source to check against
735
- * @param initialScope Initial scope to search for the identifier
736
- * @returns Whether the identifier name is initialized from react
732
+ * Checks if a variable is initialized from React import
733
+ * @param name The variable name
734
+ * @param initialScope The initial scope
735
+ * @param importSource Alternative import source of React (e.g., "preact/compat")
736
+ * @returns True if the variable is initialized from React import
737
737
  */
738
- declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
738
+ declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
739
739
  //#endregion
740
- //#region src/utils/is-from-source.d.ts
740
+ //#region src/utils/is-from-react-native.d.ts
741
741
  /**
742
- * Check if an identifier name is initialized from source
743
- * @param name The top-level identifier's name
744
- * @param source The import source to check against
745
- * @param initialScope Initial scope to search for the identifier
746
- * @returns Whether the identifier name is initialized from source
747
- * @internal
742
+ * Checks if a variable is initialized from React Native import
743
+ * @param name The variable name
744
+ * @param initialScope The initial scope
745
+ * @param importSource Alternative import source of React Native (e.g., "react-native-web")
746
+ * @returns True if the variable is initialized from React Native import
748
747
  */
749
- declare function isInitializedFromSource(name: string, source: string, initialScope: Scope): boolean;
748
+ declare function isInitializedFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
750
749
  //#endregion
751
750
  //#region src/utils/is-instance-id-equal.d.ts
752
751
  /** @internal */
@@ -804,4 +803,4 @@ declare const isForwardRefCall: isReactAPICall.ReturnType;
804
803
  declare const isMemoCall: isReactAPICall.ReturnType;
805
804
  declare const isLazyCall: isReactAPICall.ReturnType;
806
805
  //#endregion
807
- export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponent, Hook, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, findParentJsxAttribute, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromSource, isInstanceIdEqual, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookId, isReactHookName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectLikeCall, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
806
+ export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponent, Hook, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, findParentJsxAttribute, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromReactNative, isInstanceIdEqual, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookId, isReactHookName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectLikeCall, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import * as AST from "@eslint-react/ast";
2
2
  import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
3
3
  import { IdGenerator, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
4
4
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
5
- import { findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
5
+ import { findImportSource, findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
6
6
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
8
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils";
@@ -585,59 +585,33 @@ function getInstanceId(node, prev) {
585
585
  }
586
586
 
587
587
  //#endregion
588
- //#region src/utils/is-from-source.ts
589
- /**
590
- * Get the arguments of a require expression
591
- * @param node The node to match
592
- * @returns The require expression arguments or undefined if the node is not a require expression
593
- */
594
- function getRequireExpressionArguments(node) {
595
- return match(node).with({
596
- type: AST_NODE_TYPES.CallExpression,
597
- arguments: P.select(),
598
- callee: {
599
- type: AST_NODE_TYPES.Identifier,
600
- name: "require"
601
- }
602
- }, identity).with({
603
- type: AST_NODE_TYPES.MemberExpression,
604
- object: P.select()
605
- }, getRequireExpressionArguments).otherwise(() => null);
606
- }
588
+ //#region src/utils/is-from-react.ts
607
589
  /**
608
- * Check if an identifier name is initialized from source
609
- * @param name The top-level identifier's name
610
- * @param source The import source to check against
611
- * @param initialScope Initial scope to search for the identifier
612
- * @returns Whether the identifier name is initialized from source
613
- * @internal
590
+ * Checks if a variable is initialized from React import
591
+ * @param name The variable name
592
+ * @param initialScope The initial scope
593
+ * @param importSource Alternative import source of React (e.g., "preact/compat")
594
+ * @returns True if the variable is initialized from React import
614
595
  */
615
- function isInitializedFromSource(name, source, initialScope) {
616
- const latestDef = findVariable(name, initialScope)?.defs.at(-1);
617
- if (latestDef == null) return false;
618
- const { node, parent } = latestDef;
619
- if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
620
- const { init } = node;
621
- if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return isInitializedFromSource(init.object.name, source, initialScope);
622
- if (init.type === AST_NODE_TYPES.Identifier) return isInitializedFromSource(init.name, source, initialScope);
623
- const arg0 = getRequireExpressionArguments(init)?.[0];
624
- if (arg0 == null || !AST.isLiteral(arg0, "string")) return false;
625
- return arg0.value === source || arg0.value.startsWith(`${source}/`);
626
- }
627
- return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === source;
596
+ function isInitializedFromReact(name, initialScope, importSource = "react") {
597
+ return name.toLowerCase() === "react" || Boolean(findImportSource(name, initialScope)?.startsWith(importSource));
628
598
  }
629
599
 
630
600
  //#endregion
631
- //#region src/utils/is-from-react.ts
601
+ //#region src/utils/is-from-react-native.ts
632
602
  /**
633
- * Check if an identifier name is initialized from react
634
- * @param name The top-level identifier's name
635
- * @param importSource The import source to check against
636
- * @param initialScope Initial scope to search for the identifier
637
- * @returns Whether the identifier name is initialized from react
603
+ * Checks if a variable is initialized from React Native import
604
+ * @param name The variable name
605
+ * @param initialScope The initial scope
606
+ * @param importSource Alternative import source of React Native (e.g., "react-native-web")
607
+ * @returns True if the variable is initialized from React Native import
638
608
  */
639
- function isInitializedFromReact(name, importSource, initialScope) {
640
- return name.toLowerCase() === "react" || isInitializedFromSource(name, importSource, initialScope);
609
+ function isInitializedFromReactNative(name, initialScope, importSource = "react-native") {
610
+ return [
611
+ "react_native",
612
+ "reactnative",
613
+ "rn"
614
+ ].includes(name.toLowerCase()) || Boolean(findImportSource(name, initialScope)?.startsWith(importSource));
641
615
  }
642
616
 
643
617
  //#endregion
@@ -1245,4 +1219,4 @@ function isDeclaredInRenderPropLoose(node) {
1245
1219
  }
1246
1220
 
1247
1221
  //#endregion
1248
- export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findParentJsxAttribute, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromSource, isInstanceIdEqual, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookId, isReactHookName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectLikeCall, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
1222
+ export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findParentJsxAttribute, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromReactNative, isInstanceIdEqual, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookId, isReactHookName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectLikeCall, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.4.0-next.9",
3
+ "version": "2.4.1-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": {
@@ -30,18 +30,18 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/scope-manager": "^8.50.0",
34
- "@typescript-eslint/types": "^8.50.0",
35
- "@typescript-eslint/utils": "^8.50.0",
33
+ "@typescript-eslint/scope-manager": "^8.50.1",
34
+ "@typescript-eslint/types": "^8.50.1",
35
+ "@typescript-eslint/utils": "^8.50.1",
36
36
  "birecord": "^0.1.1",
37
37
  "ts-pattern": "^5.9.0",
38
- "@eslint-react/shared": "2.4.0-next.9",
39
- "@eslint-react/var": "2.4.0-next.9",
40
- "@eslint-react/eff": "2.4.0-next.9",
41
- "@eslint-react/ast": "2.4.0-next.9"
38
+ "@eslint-react/ast": "2.4.1-beta.0",
39
+ "@eslint-react/shared": "2.4.1-beta.0",
40
+ "@eslint-react/var": "2.4.1-beta.0",
41
+ "@eslint-react/eff": "2.4.1-beta.0"
42
42
  },
43
43
  "devDependencies": {
44
- "tsdown": "^0.18.0",
44
+ "tsdown": "^0.18.2",
45
45
  "@local/configs": "0.0.0"
46
46
  },
47
47
  "peerDependencies": {