@eslint-react/core
Advanced tools
+53
-57
| import * as ast from "@eslint-react/ast"; | ||
| import { unit } from "@eslint-react/eff"; | ||
| import { TSESTree } from "@typescript-eslint/types"; | ||
@@ -14,5 +13,5 @@ import { RegExpLike, RuleContext } from "@eslint-react/shared"; | ||
| * @param initialScope The initial scope to search | ||
| * @returns The import source or undefined if not found | ||
| * @returns The import source or null if not found | ||
| */ | ||
| declare function findImportSource(name: string, initialScope: Scope): string | undefined; | ||
| declare function findImportSource(name: string, initialScope: Scope): string | null; | ||
| //#endregion | ||
@@ -42,4 +41,4 @@ //#region src/api/is-from-react.d.ts | ||
| type ReturnType = { | ||
| (context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression; | ||
| (context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier; | ||
| (context: RuleContext, node: null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression; | ||
| (context: RuleContext): (node: null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier; | ||
| }; | ||
@@ -55,4 +54,4 @@ } | ||
| type ReturnType = { | ||
| (context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression; | ||
| (context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression; | ||
| (context: RuleContext, node: null | TSESTree.Node): node is TSESTree.CallExpression; | ||
| (context: RuleContext): (node: null | TSESTree.Node) => node is TSESTree.CallExpression; | ||
| }; | ||
@@ -140,3 +139,3 @@ } | ||
| /** The identifier of the node */ | ||
| id: unit | TSESTree.Node; | ||
| id: null | TSESTree.Node; | ||
| /** The unique key of the node */ | ||
@@ -147,3 +146,3 @@ key: string; | ||
| /** The name of the node */ | ||
| name: unit | string; | ||
| name: null | string; | ||
| /** The flag of the node */ | ||
@@ -168,5 +167,5 @@ flag: bigint; | ||
| /** The name of the function */ | ||
| name: string | unit; | ||
| name: string | null; | ||
| /** The return type annotation of the function */ | ||
| type: TSESTree.TSTypeAnnotation | unit; | ||
| type: TSESTree.TSTypeAnnotation | null; | ||
| /** The body of the function */ | ||
@@ -179,3 +178,3 @@ body: TSESTree.BlockStatement | TSESTree.Expression; | ||
| /** The type parameters of the function */ | ||
| typeParameters: TSESTree.TSTypeParameterDeclaration | unit; | ||
| typeParameters: TSESTree.TSTypeParameterDeclaration | null; | ||
| } | ||
@@ -215,3 +214,3 @@ //#endregion | ||
| */ | ||
| initPath: unit | ast.FunctionInitPath; | ||
| initPath: null | ast.FunctionInitPath; | ||
| /** | ||
@@ -232,3 +231,3 @@ * Indicates if the component is inside an export default declaration | ||
| */ | ||
| displayName: unit | TSESTree.Expression; | ||
| displayName: null | TSESTree.Expression; | ||
| /** | ||
@@ -246,3 +245,3 @@ * The directives used in the function (e.g., "use strict", "use client", etc.) | ||
| */ | ||
| id: unit | TSESTree.BindingName; | ||
| id: null | TSESTree.BindingName; | ||
| /** | ||
@@ -271,3 +270,3 @@ * The kind of component | ||
| */ | ||
| displayName: unit | TSESTree.Expression; | ||
| displayName: null | TSESTree.Expression; | ||
| } | ||
@@ -292,3 +291,3 @@ /** | ||
| getCurrentEntries: () => FunctionEntry$1[]; | ||
| getCurrentEntry: () => FunctionEntry$1 | unit; | ||
| getCurrentEntry: () => FunctionEntry$1 | null; | ||
| }; | ||
@@ -428,3 +427,3 @@ visitor: ESLintUtils.RuleListener; | ||
| * @param node The function node to analyze | ||
| * @returns The function identifier or `unit` if not found | ||
| * @returns The function identifier or `null` if not found | ||
| */ | ||
@@ -518,3 +517,3 @@ declare function getFunctionComponentId(context: RuleContext, node: ast.TSESTreeFunction): ast.FunctionID; | ||
| */ | ||
| declare function isUseEffectSetupCallback(node: TSESTree.Node | unit): boolean; | ||
| declare function isUseEffectSetupCallback(node: TSESTree.Node | null): boolean; | ||
| /** | ||
@@ -524,3 +523,3 @@ * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function | ||
| */ | ||
| declare function isUseEffectCleanupCallback(node: TSESTree.Node | unit): boolean; | ||
| declare function isUseEffectCleanupCallback(node: TSESTree.Node | null): boolean; | ||
| //#endregion | ||
@@ -555,3 +554,3 @@ //#region src/hook/hook-semantic-node.d.ts | ||
| getCurrentEntries(): FunctionEntry[]; | ||
| getCurrentEntry(): FunctionEntry | unit; | ||
| getCurrentEntry(): FunctionEntry | null; | ||
| }; | ||
@@ -582,3 +581,3 @@ visitor: ESLintUtils.RuleListener; | ||
| */ | ||
| declare function isHook(node: ast.TSESTreeFunction | unit): boolean; | ||
| declare function isHook(node: ast.TSESTreeFunction | null): boolean; | ||
| /** | ||
@@ -589,3 +588,3 @@ * Check if the given node is a React Hook call by its name. | ||
| */ | ||
| declare function isHookCall(node: TSESTree.Node | unit): node is TSESTree.CallExpression; | ||
| declare function isHookCall(node: TSESTree.Node | null): node is TSESTree.CallExpression; | ||
| /** | ||
@@ -597,3 +596,3 @@ * Check if a node is a call to a specific React hook. | ||
| */ | ||
| declare function isHookCallWithName(node: TSESTree.Node | unit): (name: string) => boolean; | ||
| declare function isHookCallWithName(node: TSESTree.Node | null): (name: string) => boolean; | ||
| /** | ||
@@ -605,3 +604,3 @@ * Detect useEffect calls and variations (useLayoutEffect, etc.) using a regex pattern | ||
| */ | ||
| declare function isUseEffectLikeCall(node: TSESTree.Node | unit, additionalEffectHooks?: RegExpLike): node is TSESTree.CallExpression; | ||
| declare function isUseEffectLikeCall(node: TSESTree.Node | null, additionalEffectHooks?: RegExpLike): node is TSESTree.CallExpression; | ||
| /** | ||
@@ -613,22 +612,22 @@ * Detect useState calls and variations (useCustomState, etc.) using a regex pattern | ||
| */ | ||
| declare function isUseStateLikeCall(node: TSESTree.Node | unit, additionalStateHooks?: RegExpLike): node is TSESTree.CallExpression; | ||
| declare const isUseCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseActionStateCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseCallbackCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseContextCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseDebugValueCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseDeferredValueCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseEffectCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseFormStatusCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseIdCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseImperativeHandleCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseInsertionEffectCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseLayoutEffectCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseMemoCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseOptimisticCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseReducerCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseRefCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseStateCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseSyncExternalStoreCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare const isUseTransitionCall: (node: TSESTree.Node | undefined) => boolean; | ||
| declare function isUseStateLikeCall(node: TSESTree.Node | null, additionalStateHooks?: RegExpLike): node is TSESTree.CallExpression; | ||
| declare const isUseCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseActionStateCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseCallbackCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseContextCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseDebugValueCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseDeferredValueCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseEffectCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseFormStatusCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseIdCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseImperativeHandleCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseInsertionEffectCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseLayoutEffectCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseMemoCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseOptimisticCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseReducerCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseRefCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseStateCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseSyncExternalStoreCall: (node: TSESTree.Node | null) => boolean; | ||
| declare const isUseTransitionCall: (node: TSESTree.Node | null) => boolean; | ||
| //#endregion | ||
@@ -714,7 +713,7 @@ //#region src/hook/hook-name.d.ts | ||
| readonly node: TSESTree.JSXElement; | ||
| readonly toStatic: () => undefined; | ||
| readonly toStatic: () => null; | ||
| } | { | ||
| readonly kind: "spreadChild"; | ||
| readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression; | ||
| readonly toStatic: () => undefined; | ||
| readonly toStatic: () => null; | ||
| } | { | ||
@@ -788,3 +787,3 @@ readonly kind: "spreadProps"; | ||
| */ | ||
| declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal; | ||
| declare function isJsxText(node: TSESTree$1.Node | null): node is TSESTree$1.JSXText | TSESTree$1.Literal; | ||
| /** | ||
@@ -794,4 +793,3 @@ * Determine if a node represents JSX-like content based on heuristics | ||
| * | ||
| * @param code The source code with scope lookup capability | ||
| * @param code.getScope The function to get the scope of a node | ||
| * @param context The rule context with scope lookup capability | ||
| * @param node The AST node to analyze | ||
@@ -801,5 +799,3 @@ * @param hint The configuration flags to adjust detection behavior | ||
| */ | ||
| declare function isJsxLike(code: { | ||
| getScope: (node: TSESTree$1.Node) => Scope; | ||
| }, node: TSESTree$1.Node | unit | null, hint?: JsxDetectionHint): boolean; | ||
| declare function isJsxLike(context: RuleContext, node: TSESTree$1.Node | null, hint?: JsxDetectionHint): boolean; | ||
| //#endregion | ||
@@ -847,5 +843,5 @@ //#region src/jsx/jsx-element-is.d.ts | ||
| * Defaults to always returning true (matches any attribute) | ||
| * @returns The first matching JSX attribute node found when traversing upwards, or undefined | ||
| * @returns The first matching JSX attribute node found when traversing upwards, or null | ||
| */ | ||
| declare function findParentJsxAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit; | ||
| declare function findParentJsxAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | null; | ||
| //#endregion | ||
@@ -876,5 +872,5 @@ //#region src/jsx/jsx-stringify.d.ts | ||
| * @param initialScope The initial scope | ||
| * @returns The init expression node if the variable is derived from a ref, or undefined otherwise | ||
| * @returns The init expression node if the variable is derived from a ref, or null otherwise | ||
| */ | ||
| declare function getRefInit(name: string, initialScope: Scope): TSESTree$1.Expression | unit; | ||
| declare function getRefInit(name: string, initialScope: Scope): TSESTree$1.Expression | null; | ||
| //#endregion | ||
@@ -881,0 +877,0 @@ //#region src/ref/ref-name.d.ts |
+41
-58
| import * as ast from "@eslint-react/ast"; | ||
| import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff"; | ||
| import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity } from "@eslint-react/eff"; | ||
| import { AST_NODE_TYPES } from "@typescript-eslint/types"; | ||
@@ -7,2 +7,3 @@ import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils"; | ||
| 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 { resolve } from "@eslint-react/var"; | ||
| import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils"; | ||
@@ -14,3 +15,3 @@ | ||
| * @param node The node to match | ||
| * @returns The require expression arguments or undefined if the node is not a require expression | ||
| * @returns The require expression arguments or null if the node is not a require expression | ||
| * @internal | ||
@@ -35,7 +36,7 @@ */ | ||
| * @param initialScope The initial scope to search | ||
| * @returns The import source or undefined if not found | ||
| * @returns The import source or null if not found | ||
| */ | ||
| function findImportSource(name, initialScope) { | ||
| const latestDef = findVariable(initialScope, name)?.defs.at(-1); | ||
| if (latestDef == null) return unit; | ||
| if (latestDef == null) return null; | ||
| const { node, parent } = latestDef; | ||
@@ -47,7 +48,7 @@ if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) { | ||
| const arg0 = getRequireExpressionArguments(init)?.[0]; | ||
| if (arg0 == null || !ast.isLiteral(arg0, "string")) return unit; | ||
| if (arg0 == null || !ast.isLiteral(arg0, "string")) return null; | ||
| return arg0.value; | ||
| } | ||
| if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value; | ||
| return unit; | ||
| return null; | ||
| } | ||
@@ -319,3 +320,3 @@ | ||
| const getText = (n) => context.sourceCode.getText(n); | ||
| const getCurrentEntry = () => functionEntries.at(-1); | ||
| const getCurrentEntry = () => functionEntries.at(-1) ?? null; | ||
| const onFunctionEnter = (node) => { | ||
@@ -408,3 +409,3 @@ const id = ast.getFunctionId(node); | ||
| function getJsxAttribute(context, node, initialScope) { | ||
| const scope = initialScope ?? context.sourceCode.getScope(node); | ||
| initialScope ?? context.sourceCode.getScope(node); | ||
| const attributes = node.openingElement.attributes; | ||
@@ -420,11 +421,3 @@ /** | ||
| case AST_NODE_TYPES.Identifier: { | ||
| const variable = findVariable(scope, attr.argument.name); | ||
| function resolve(v) { | ||
| if (v == null) return unit; | ||
| const def = v.defs.at(0); | ||
| if (def == null) return unit; | ||
| if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init; | ||
| return unit; | ||
| } | ||
| const initNode = resolve(variable); | ||
| const initNode = resolve(context, attr.argument); | ||
| if (initNode?.type === AST_NODE_TYPES.ObjectExpression) return ast.findProperty(initNode.properties, name) != null; | ||
@@ -487,3 +480,3 @@ return false; | ||
| toStatic() { | ||
| return unit; | ||
| return null; | ||
| } | ||
@@ -495,3 +488,3 @@ }; | ||
| toStatic() { | ||
| return unit; | ||
| return null; | ||
| } | ||
@@ -510,4 +503,4 @@ }; | ||
| toStatic(name) { | ||
| if (name == null) return unit; | ||
| return match(getStaticValue(node.argument, initialScope)?.value).with({ [name]: P.select(P.any) }, identity).otherwise(() => unit); | ||
| if (name == null) return null; | ||
| return match(getStaticValue(node.argument, initialScope)?.value).with({ [name]: P.select(P.any) }, identity).otherwise(() => null); | ||
| } | ||
@@ -606,4 +599,3 @@ }; | ||
| * | ||
| * @param code The source code with scope lookup capability | ||
| * @param code.getScope The function to get the scope of a node | ||
| * @param context The rule context with scope lookup capability | ||
| * @param node The AST node to analyze | ||
@@ -613,3 +605,3 @@ * @param hint The configuration flags to adjust detection behavior | ||
| */ | ||
| function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) { | ||
| function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) { | ||
| if (node == null) return false; | ||
@@ -630,7 +622,7 @@ if (ast.isJSX(node)) return true; | ||
| if (node.elements.length === 0) return !(hint & JsxDetectionHint.DoNotIncludeJsxWithEmptyArrayValue); | ||
| if (hint & JsxDetectionHint.RequireAllArrayElementsToBeJsx) return node.elements.every((n) => isJsxLike(code, n, hint)); | ||
| return node.elements.some((n) => isJsxLike(code, n, hint)); | ||
| if (hint & JsxDetectionHint.RequireAllArrayElementsToBeJsx) return node.elements.every((n) => isJsxLike(context, n, hint)); | ||
| return node.elements.some((n) => isJsxLike(context, n, hint)); | ||
| case AST_NODE_TYPES.LogicalExpression: | ||
| if (hint & JsxDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx) return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint); | ||
| return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint); | ||
| if (hint & JsxDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx) return isJsxLike(context, node.left, hint) && isJsxLike(context, node.right, hint); | ||
| return isJsxLike(context, node.left, hint) || isJsxLike(context, node.right, hint); | ||
| case AST_NODE_TYPES.ConditionalExpression: { | ||
@@ -640,9 +632,9 @@ function leftHasJSX(node) { | ||
| if (node.consequent.length === 0) return !(hint & JsxDetectionHint.DoNotIncludeJsxWithEmptyArrayValue); | ||
| if (hint & JsxDetectionHint.RequireAllArrayElementsToBeJsx) return node.consequent.every((n) => isJsxLike(code, n, hint)); | ||
| return node.consequent.some((n) => isJsxLike(code, n, hint)); | ||
| if (hint & JsxDetectionHint.RequireAllArrayElementsToBeJsx) return node.consequent.every((n) => isJsxLike(context, n, hint)); | ||
| return node.consequent.some((n) => isJsxLike(context, n, hint)); | ||
| } | ||
| return isJsxLike(code, node.consequent, hint); | ||
| return isJsxLike(context, node.consequent, hint); | ||
| } | ||
| function rightHasJSX(node) { | ||
| return isJsxLike(code, node.alternate, hint); | ||
| return isJsxLike(context, node.alternate, hint); | ||
| } | ||
@@ -652,3 +644,3 @@ if (hint & JsxDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx) return leftHasJSX(node) && rightHasJSX(node); | ||
| } | ||
| case AST_NODE_TYPES.SequenceExpression: return isJsxLike(code, node.expressions.at(-1), hint); | ||
| case AST_NODE_TYPES.SequenceExpression: return isJsxLike(context, node.expressions.at(-1) ?? null, hint); | ||
| case AST_NODE_TYPES.CallExpression: | ||
@@ -661,15 +653,6 @@ if (hint & JsxDetectionHint.DoNotIncludeJsxWithCreateElementValue) return false; | ||
| return false; | ||
| case AST_NODE_TYPES.Identifier: { | ||
| const { name } = node; | ||
| if (name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue); | ||
| case AST_NODE_TYPES.Identifier: | ||
| if (node.name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue); | ||
| if (ast.isJSXTagNameExpression(node)) return true; | ||
| function resolve(v) { | ||
| if (v == null) return unit; | ||
| const def = v.defs.at(0); | ||
| if (def == null) return unit; | ||
| if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init; | ||
| return unit; | ||
| } | ||
| return isJsxLike(code, resolve(findVariable(code.getScope(node), name)), hint); | ||
| } | ||
| return isJsxLike(context, resolve(context, node), hint); | ||
| } | ||
@@ -732,3 +715,3 @@ return false; | ||
| * Defaults to always returning true (matches any attribute) | ||
| * @returns The first matching JSX attribute node found when traversing upwards, or undefined | ||
| * @returns The first matching JSX attribute node found when traversing upwards, or null | ||
| */ | ||
@@ -921,3 +904,3 @@ function findParentJsxAttribute(node, test = constTrue) { | ||
| * @param node The function node to analyze | ||
| * @returns The function identifier or `unit` if not found | ||
| * @returns The function identifier or `null` if not found | ||
| */ | ||
@@ -930,3 +913,3 @@ function getFunctionComponentId(context, node) { | ||
| if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator) return parent.parent.parent.id; | ||
| return unit; | ||
| return null; | ||
| } | ||
@@ -1071,3 +1054,3 @@ | ||
| const getText = (n) => context.sourceCode.getText(n); | ||
| const getCurrentEntry = () => functionEntries.at(-1); | ||
| const getCurrentEntry = () => functionEntries.at(-1) ?? null; | ||
| const onFunctionEnter = (node) => { | ||
@@ -1079,3 +1062,3 @@ const key = idGen$1.next(); | ||
| const id = getFunctionComponentId(context, node); | ||
| const name = id == null ? unit : ast.getFullyQualifiedName(id, getText); | ||
| const name = id == null ? null : ast.getFullyQualifiedName(id, getText); | ||
| const initPath = ast.getFunctionInitPath(node); | ||
@@ -1089,3 +1072,3 @@ const directives = ast.getFunctionDirectives(node); | ||
| directives, | ||
| displayName: unit, | ||
| displayName: null, | ||
| flag: getComponentFlagFromInitPath(initPath), | ||
@@ -1128,3 +1111,3 @@ hint, | ||
| if (!entry.isComponentDefinition) return; | ||
| if (!components.has(entry.key) && !isJsxLike(context.sourceCode, body, hint)) return; | ||
| if (!components.has(entry.key) && !isJsxLike(context, body, hint)) return; | ||
| components.set(entry.key, entry); | ||
@@ -1135,3 +1118,3 @@ }, | ||
| if (left.type !== AST_NODE_TYPES.MemberExpression) return; | ||
| const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : unit; | ||
| const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : null; | ||
| const component = [...components.values()].findLast(({ name }) => name != null && name === componentName); | ||
@@ -1155,3 +1138,3 @@ if (component == null) return; | ||
| const { argument } = node; | ||
| if (!components.has(entry.key) && !isJsxLike(context.sourceCode, argument, hint)) return; | ||
| if (!components.has(entry.key) && !isJsxLike(context, argument, hint)) return; | ||
| components.set(entry.key, entry); | ||
@@ -1181,3 +1164,3 @@ } | ||
| const key = idGen.next(); | ||
| const name = id == null ? unit : ast.getFullyQualifiedName(id, getText); | ||
| const name = id == null ? null : ast.getFullyQualifiedName(id, getText); | ||
| const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None; | ||
@@ -1189,3 +1172,3 @@ components.set(key, { | ||
| name, | ||
| displayName: unit, | ||
| displayName: null, | ||
| flag, | ||
@@ -1238,3 +1221,3 @@ hint: 0n, | ||
| * @param initialScope The initial scope | ||
| * @returns The init expression node if the variable is derived from a ref, or undefined otherwise | ||
| * @returns The init expression node if the variable is derived from a ref, or null otherwise | ||
| */ | ||
@@ -1251,3 +1234,3 @@ function getRefInit(name, initialScope) { | ||
| } | ||
| return unit; | ||
| return null; | ||
| } | ||
@@ -1254,0 +1237,0 @@ |
+5
-5
| { | ||
| "name": "@eslint-react/core", | ||
| "version": "3.0.0-next.63", | ||
| "version": "3.0.0-next.64", | ||
| "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/shared": "3.0.0-next.63", | ||
| "@eslint-react/ast": "3.0.0-next.63", | ||
| "@eslint-react/var": "3.0.0-next.63", | ||
| "@eslint-react/eff": "3.0.0-next.63" | ||
| "@eslint-react/ast": "3.0.0-next.64", | ||
| "@eslint-react/shared": "3.0.0-next.64", | ||
| "@eslint-react/eff": "3.0.0-next.64", | ||
| "@eslint-react/var": "3.0.0-next.64" | ||
| }, | ||
@@ -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
90267
-1.04%2042
-1.02%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed