@eslint-react/core 3.0.0-next.47 → 3.0.0-next.48
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 +1 -50
- package/dist/index.js +1 -72
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -108,55 +108,6 @@ declare const ComponentDetectionHint: {
|
|
|
108
108
|
* Default component detection hint
|
|
109
109
|
*/
|
|
110
110
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
111
|
-
/**
|
|
112
|
-
* Unsafe check whether given node is a render function
|
|
113
|
-
* ```tsx
|
|
114
|
-
* const renderRow = () => <div />
|
|
115
|
-
* ` ^^^^^^^^^^^^`
|
|
116
|
-
* _ = <Component renderRow={() => <div />} />
|
|
117
|
-
* ` ^^^^^^^^^^^^^ `
|
|
118
|
-
* ```
|
|
119
|
-
* @param context The rule context
|
|
120
|
-
* @param node The AST node to check
|
|
121
|
-
* @returns `true` if node is a render function, `false` if not
|
|
122
|
-
*/
|
|
123
|
-
declare function isRenderFunctionLoose(context: RuleContext, node: TSESTree.Node): node is ast.TSESTreeFunction;
|
|
124
|
-
/**
|
|
125
|
-
* Unsafe check whether given JSXAttribute is a render prop
|
|
126
|
-
* ```tsx
|
|
127
|
-
* _ = <Component renderRow={() => <div />} />
|
|
128
|
-
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
129
|
-
* ```
|
|
130
|
-
* @param context The rule context
|
|
131
|
-
* @param node The AST node to check
|
|
132
|
-
* @returns `true` if node is a render prop, `false` if not
|
|
133
|
-
*/
|
|
134
|
-
declare function isRenderPropLoose(context: RuleContext, node: TSESTree.JSXAttribute): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Unsafe check whether given node is declared directly inside a render property
|
|
137
|
-
* ```tsx
|
|
138
|
-
* const rows = { render: () => <div /> }
|
|
139
|
-
* ` ^^^^^^^^^^^^^ `
|
|
140
|
-
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
141
|
-
* ` ^^^^^^^^^^^^^ `
|
|
142
|
-
* ```
|
|
143
|
-
* @internal
|
|
144
|
-
* @param node The AST node to check
|
|
145
|
-
* @returns `true` if component is declared inside a render property, `false` if not
|
|
146
|
-
*/
|
|
147
|
-
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Unsafe check whether given node is declared inside a render prop
|
|
150
|
-
* ```tsx
|
|
151
|
-
* _ = <Component renderRow={"node"} />
|
|
152
|
-
* ` ^^^^^^ `
|
|
153
|
-
* _ = <Component rows={ [{ render: "node" }] } />
|
|
154
|
-
* ` ^^^^^^ `
|
|
155
|
-
* ```
|
|
156
|
-
* @param node The AST node to check
|
|
157
|
-
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
158
|
-
*/
|
|
159
|
-
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
160
111
|
/**
|
|
161
112
|
* Determine if a function node represents a valid React component definition
|
|
162
113
|
*
|
|
@@ -920,4 +871,4 @@ declare function getRefInit(name: string, initialScope: Scope): TSESTree$1.Expre
|
|
|
920
871
|
*/
|
|
921
872
|
declare function isRefLikeName(name: string): boolean;
|
|
922
873
|
//#endregion
|
|
923
|
-
export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentFlag, ComponentKind, 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,
|
|
874
|
+
export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentFlag, ComponentKind, 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 };
|
package/dist/index.js
CHANGED
|
@@ -909,77 +909,6 @@ const ComponentDetectionHint = {
|
|
|
909
909
|
*/
|
|
910
910
|
const DEFAULT_COMPONENT_DETECTION_HINT = 0n | ComponentDetectionHint.DoNotIncludeJsxWithBigIntValue | ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | ComponentDetectionHint.DoNotIncludeJsxWithStringValue | ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | ComponentDetectionHint.RequireAllArrayElementsToBeJsx | ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx;
|
|
911
911
|
/**
|
|
912
|
-
* Unsafe check whether given node is a render function
|
|
913
|
-
* ```tsx
|
|
914
|
-
* const renderRow = () => <div />
|
|
915
|
-
* ` ^^^^^^^^^^^^`
|
|
916
|
-
* _ = <Component renderRow={() => <div />} />
|
|
917
|
-
* ` ^^^^^^^^^^^^^ `
|
|
918
|
-
* ```
|
|
919
|
-
* @param context The rule context
|
|
920
|
-
* @param node The AST node to check
|
|
921
|
-
* @returns `true` if node is a render function, `false` if not
|
|
922
|
-
*/
|
|
923
|
-
function isRenderFunctionLoose(context, node) {
|
|
924
|
-
if (!ast.isFunction(node)) return false;
|
|
925
|
-
const id = ast.getFunctionId(node);
|
|
926
|
-
switch (true) {
|
|
927
|
-
case id?.type === AST_NODE_TYPES.Identifier: return id.name.startsWith("render");
|
|
928
|
-
case id?.type === AST_NODE_TYPES.MemberExpression && id.property.type === AST_NODE_TYPES.Identifier: return id.property.name.startsWith("render");
|
|
929
|
-
case node.parent.type === AST_NODE_TYPES.JSXExpressionContainer && node.parent.parent.type === AST_NODE_TYPES.JSXAttribute && node.parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier: return node.parent.parent.name.name.startsWith("render");
|
|
930
|
-
}
|
|
931
|
-
return false;
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* Unsafe check whether given JSXAttribute is a render prop
|
|
935
|
-
* ```tsx
|
|
936
|
-
* _ = <Component renderRow={() => <div />} />
|
|
937
|
-
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
938
|
-
* ```
|
|
939
|
-
* @param context The rule context
|
|
940
|
-
* @param node The AST node to check
|
|
941
|
-
* @returns `true` if node is a render prop, `false` if not
|
|
942
|
-
*/
|
|
943
|
-
function isRenderPropLoose(context, node) {
|
|
944
|
-
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) return false;
|
|
945
|
-
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && isRenderFunctionLoose(context, node.value.expression);
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Unsafe check whether given node is declared directly inside a render property
|
|
949
|
-
* ```tsx
|
|
950
|
-
* const rows = { render: () => <div /> }
|
|
951
|
-
* ` ^^^^^^^^^^^^^ `
|
|
952
|
-
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
953
|
-
* ` ^^^^^^^^^^^^^ `
|
|
954
|
-
* ```
|
|
955
|
-
* @internal
|
|
956
|
-
* @param node The AST node to check
|
|
957
|
-
* @returns `true` if component is declared inside a render property, `false` if not
|
|
958
|
-
*/
|
|
959
|
-
function isDirectValueOfRenderPropertyLoose(node) {
|
|
960
|
-
const matching = (node) => {
|
|
961
|
-
return node.type === AST_NODE_TYPES.Property && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render");
|
|
962
|
-
};
|
|
963
|
-
return matching(node) || node.parent != null && matching(node.parent);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Unsafe check whether given node is declared inside a render prop
|
|
967
|
-
* ```tsx
|
|
968
|
-
* _ = <Component renderRow={"node"} />
|
|
969
|
-
* ` ^^^^^^ `
|
|
970
|
-
* _ = <Component rows={ [{ render: "node" }] } />
|
|
971
|
-
* ` ^^^^^^ `
|
|
972
|
-
* ```
|
|
973
|
-
* @param node The AST node to check
|
|
974
|
-
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
975
|
-
*/
|
|
976
|
-
function isDeclaredInRenderPropLoose(node) {
|
|
977
|
-
if (isDirectValueOfRenderPropertyLoose(node)) return true;
|
|
978
|
-
const parent = ast.findParentNode(node, ast.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
979
|
-
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) return false;
|
|
980
|
-
return parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
912
|
* Check if a function node should be excluded based on provided detection hints
|
|
984
913
|
*
|
|
985
914
|
* @param node The function node to check
|
|
@@ -1281,4 +1210,4 @@ function getRefInit(name, initialScope) {
|
|
|
1281
1210
|
}
|
|
1282
1211
|
|
|
1283
1212
|
//#endregion
|
|
1284
|
-
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,
|
|
1213
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.48",
|
|
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": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@typescript-eslint/types": "canary",
|
|
35
35
|
"@typescript-eslint/utils": "canary",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/shared": "3.0.0-next.
|
|
40
|
-
"@eslint-react/var": "3.0.0-next.
|
|
37
|
+
"@eslint-react/eff": "3.0.0-next.48",
|
|
38
|
+
"@eslint-react/ast": "3.0.0-next.48",
|
|
39
|
+
"@eslint-react/shared": "3.0.0-next.48",
|
|
40
|
+
"@eslint-react/var": "3.0.0-next.48"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"tsdown": "^0.20.3",
|