@eslint-react/core
Advanced tools
+10
-19
@@ -9,2 +9,11 @@ import * as ast from "@eslint-react/ast"; | ||
| //#region src/api/find-import-source.d.ts | ||
| /** | ||
| * Find the import source of a variable | ||
| * @param name The variable name | ||
| * @param initialScope The initial scope to search | ||
| * @returns The import source or undefined if not found | ||
| */ | ||
| declare function findImportSource(name: string, initialScope: Scope): string | undefined; | ||
| //#endregion | ||
| //#region src/api/is-from-react.d.ts | ||
@@ -492,20 +501,2 @@ /** | ||
| //#endregion | ||
| //#region src/hierarchy/find-enclosing-component-or-hook.d.ts | ||
| type FindEnclosingComponentOrHookFilter = (n: TSESTree.Node, name: string | null) => boolean; | ||
| /** | ||
| * Find the enclosing React component or hook for a given AST node | ||
| * @param node The AST node to start the search from | ||
| * @param test Optional test function to customize component or hook identification | ||
| * @returns The enclosing component or hook node, or `null` if none is ASAST. | ||
| */ | ||
| declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | undefined; | ||
| //#endregion | ||
| //#region src/hierarchy/is-inside-component-or-hook.d.ts | ||
| /** | ||
| * Check if a given AST node is inside a React component or hook | ||
| * @param node The AST node to check | ||
| * @returns True if the node is inside a component or hook, false otherwise | ||
| */ | ||
| declare function isInsideComponentOrHook(node: TSESTree.Node | unit): boolean; | ||
| //#endregion | ||
| //#region src/hook/hook-callback.d.ts | ||
@@ -873,2 +864,2 @@ /** | ||
| //#endregion | ||
| export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentFlag, ComponentSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FindEnclosingComponentOrHookFilter, FunctionComponentSemanticNode, FunctionKind, FunctionSemanticNode, HookSemanticNode, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getRefInit, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isForwardRef, isForwardRefCall, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefId, isRefLikeName, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; | ||
| export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentFlag, ComponentSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentSemanticNode, FunctionKind, FunctionSemanticNode, HookSemanticNode, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, findImportSource, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getRefInit, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isForwardRef, isForwardRefCall, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefId, isRefLikeName, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; |
+46
-36
@@ -1,10 +0,53 @@ | ||
| import { findImportSource, findVariable, getVariableInitializer } from "@eslint-react/var"; | ||
| import * as ast from "@eslint-react/ast"; | ||
| import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff"; | ||
| import { findVariable, getVariableInitializer } from "@eslint-react/var"; | ||
| import { AST_NODE_TYPES } from "@typescript-eslint/types"; | ||
| import { P, match } from "ts-pattern"; | ||
| 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"; | ||
| import { getStaticValue } from "@typescript-eslint/utils/ast-utils"; | ||
| import { P, match } from "ts-pattern"; | ||
| import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils"; | ||
| //#region src/api/find-import-source.ts | ||
| /** | ||
| * Get the arguments of a require expression | ||
| * @param node The node to match | ||
| * @returns The require expression arguments or undefined if the node is not a require expression | ||
| * @internal | ||
| */ | ||
| function getRequireExpressionArguments(node) { | ||
| return match(node).with({ | ||
| type: AST_NODE_TYPES.CallExpression, | ||
| arguments: P.select(), | ||
| callee: { | ||
| type: AST_NODE_TYPES.Identifier, | ||
| name: "require" | ||
| } | ||
| }, identity).with({ | ||
| type: AST_NODE_TYPES.MemberExpression, | ||
| object: P.select() | ||
| }, getRequireExpressionArguments).otherwise(() => null); | ||
| } | ||
| /** | ||
| * Find the import source of a variable | ||
| * @param name The variable name | ||
| * @param initialScope The initial scope to search | ||
| * @returns The import source or undefined if not found | ||
| */ | ||
| function findImportSource(name, initialScope) { | ||
| const latestDef = findVariable(name, initialScope)?.defs.at(-1); | ||
| if (latestDef == null) return unit; | ||
| const { node, parent } = latestDef; | ||
| if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) { | ||
| const { init } = node; | ||
| if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return findImportSource(init.object.name, initialScope); | ||
| if (init.type === AST_NODE_TYPES.Identifier) return findImportSource(init.name, initialScope); | ||
| const arg0 = getRequireExpressionArguments(init)?.[0]; | ||
| if (arg0 == null || !ast.isLiteral(arg0, "string")) return unit; | ||
| return arg0.value; | ||
| } | ||
| if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value; | ||
| return unit; | ||
| } | ||
| //#endregion | ||
| //#region src/api/is-from-react.ts | ||
@@ -1123,35 +1166,2 @@ /** | ||
| //#endregion | ||
| //#region src/hierarchy/find-enclosing-component-or-hook.ts | ||
| /** | ||
| * Find the enclosing React component or hook for a given AST node | ||
| * @param node The AST node to start the search from | ||
| * @param test Optional test function to customize component or hook identification | ||
| * @returns The enclosing component or hook node, or `null` if none is ASAST. | ||
| */ | ||
| function findEnclosingComponentOrHook(node, test = (n, name) => { | ||
| if (name == null) return false; | ||
| return isComponentNameLoose(name) || isHookName(name); | ||
| }) { | ||
| const enclosingNode = ast.findParentNode(node, (n) => { | ||
| if (!ast.isFunction(n)) return false; | ||
| return test(n, match(ast.getFunctionId(n)).with({ type: AST_NODE_TYPES.Identifier }, (id) => id.name).with({ | ||
| type: AST_NODE_TYPES.MemberExpression, | ||
| property: { type: AST_NODE_TYPES.Identifier } | ||
| }, (me) => me.property.name).otherwise(() => null)); | ||
| }); | ||
| return ast.isFunction(enclosingNode) ? enclosingNode : unit; | ||
| } | ||
| //#endregion | ||
| //#region src/hierarchy/is-inside-component-or-hook.ts | ||
| /** | ||
| * Check if a given AST node is inside a React component or hook | ||
| * @param node The AST node to check | ||
| * @returns True if the node is inside a component or hook, false otherwise | ||
| */ | ||
| function isInsideComponentOrHook(node) { | ||
| return findEnclosingComponentOrHook(node) != null; | ||
| } | ||
| //#endregion | ||
| //#region src/ref/ref-name.ts | ||
@@ -1204,2 +1214,2 @@ /** | ||
| //#endregion | ||
| export { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getRefInit, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isForwardRef, isForwardRefCall, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefId, isRefLikeName, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; | ||
| export { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findImportSource, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getRefInit, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isForwardRef, isForwardRefCall, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefId, isRefLikeName, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; |
+5
-5
| { | ||
| "name": "@eslint-react/core", | ||
| "version": "3.0.0-next.59", | ||
| "version": "3.0.0-next.60", | ||
| "description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.", | ||
@@ -37,6 +37,6 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
| "ts-pattern": "^5.9.0", | ||
| "@eslint-react/ast": "3.0.0-next.59", | ||
| "@eslint-react/eff": "3.0.0-next.59", | ||
| "@eslint-react/var": "3.0.0-next.59", | ||
| "@eslint-react/shared": "3.0.0-next.59" | ||
| "@eslint-react/ast": "3.0.0-next.60", | ||
| "@eslint-react/eff": "3.0.0-next.60", | ||
| "@eslint-react/shared": "3.0.0-next.60", | ||
| "@eslint-react/var": "3.0.0-next.60" | ||
| }, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2049
0.05%90750
-0.64%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed