@eslint-react/core 2.7.4-beta.7 → 2.7.4-beta.8
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 +20 -3
- package/dist/index.js +35 -3
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ import * as typescript0 from "typescript";
|
|
|
9
9
|
|
|
10
10
|
//#region src/api/is-from-react.d.ts
|
|
11
11
|
/**
|
|
12
|
-
* Checks if a variable is initialized from React import
|
|
12
|
+
* Checks if a variable is initialized or derived from React import
|
|
13
13
|
* @param name The variable name
|
|
14
14
|
* @param initialScope The initial scope
|
|
15
15
|
* @param importSource Alternative import source of React (e.g., "preact/compat")
|
|
16
|
-
* @returns True if the variable is initialized from React import
|
|
16
|
+
* @returns True if the variable is initialized or derived from React import
|
|
17
17
|
*/
|
|
18
18
|
declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
|
|
19
19
|
//#endregion
|
|
@@ -842,4 +842,21 @@ declare function findParentJsxAttribute(node: TSESTree.Node, test?: (node: TSEST
|
|
|
842
842
|
*/
|
|
843
843
|
declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
|
|
844
844
|
//#endregion
|
|
845
|
-
|
|
845
|
+
//#region src/ref/is-from-ref.d.ts
|
|
846
|
+
/**
|
|
847
|
+
* Checks if the variable with the given name is initialized or derived from a ref
|
|
848
|
+
* @param name The variable name
|
|
849
|
+
* @param initialScope The initial scope
|
|
850
|
+
* @returns True if the variable is derived from a ref, false otherwise
|
|
851
|
+
*/
|
|
852
|
+
declare function isInitializedFromRef(name: string, initialScope: Scope): boolean;
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/ref/ref-name.d.ts
|
|
855
|
+
/**
|
|
856
|
+
* Checks if a given name corresponds to a ref name
|
|
857
|
+
* @param name The name to check
|
|
858
|
+
* @returns True if the name is "ref" or ends with "Ref"
|
|
859
|
+
*/
|
|
860
|
+
declare function isRefName(name: string): boolean;
|
|
861
|
+
//#endregion
|
|
862
|
+
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FindEnclosingComponentOrHookFilter, FunctionComponent, Hook, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, 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, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookId, isReactHookName, isRefName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, 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
|
@@ -10,11 +10,11 @@ import birecord from "birecord";
|
|
|
10
10
|
|
|
11
11
|
//#region src/api/is-from-react.ts
|
|
12
12
|
/**
|
|
13
|
-
* Checks if a variable is initialized from React import
|
|
13
|
+
* Checks if a variable is initialized or derived from React import
|
|
14
14
|
* @param name The variable name
|
|
15
15
|
* @param initialScope The initial scope
|
|
16
16
|
* @param importSource Alternative import source of React (e.g., "preact/compat")
|
|
17
|
-
* @returns True if the variable is initialized from React import
|
|
17
|
+
* @returns True if the variable is initialized or derived from React import
|
|
18
18
|
*/
|
|
19
19
|
function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
20
20
|
return name.toLowerCase() === "react" || Boolean(findImportSource(name, initialScope)?.startsWith(importSource));
|
|
@@ -1272,4 +1272,36 @@ function isInsideComponentOrHook(node) {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
|
|
1274
1274
|
//#endregion
|
|
1275
|
-
|
|
1275
|
+
//#region src/ref/ref-name.ts
|
|
1276
|
+
/**
|
|
1277
|
+
* Checks if a given name corresponds to a ref name
|
|
1278
|
+
* @param name The name to check
|
|
1279
|
+
* @returns True if the name is "ref" or ends with "Ref"
|
|
1280
|
+
*/
|
|
1281
|
+
function isRefName(name) {
|
|
1282
|
+
return name === "ref" || name.endsWith("Ref");
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
//#endregion
|
|
1286
|
+
//#region src/ref/is-from-ref.ts
|
|
1287
|
+
/**
|
|
1288
|
+
* Checks if the variable with the given name is initialized or derived from a ref
|
|
1289
|
+
* @param name The variable name
|
|
1290
|
+
* @param initialScope The initial scope
|
|
1291
|
+
* @returns True if the variable is derived from a ref, false otherwise
|
|
1292
|
+
*/
|
|
1293
|
+
function isInitializedFromRef(name, initialScope) {
|
|
1294
|
+
for (const { node } of findVariable(initialScope)(name)?.defs ?? []) {
|
|
1295
|
+
if (node.type !== AST_NODE_TYPES$1.VariableDeclarator) continue;
|
|
1296
|
+
const init = node.init;
|
|
1297
|
+
if (init == null) continue;
|
|
1298
|
+
switch (true) {
|
|
1299
|
+
case init.type === AST_NODE_TYPES$1.MemberExpression && init.object.type === AST_NODE_TYPES$1.Identifier && isRefName(init.object.name): return true;
|
|
1300
|
+
case init.type === AST_NODE_TYPES$1.CallExpression && isUseRefCall(init): return true;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
//#endregion
|
|
1307
|
+
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, 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, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookId, isReactHookName, isRefName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, 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": "2.7.4-beta.
|
|
3
|
+
"version": "2.7.4-beta.8",
|
|
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": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@typescript-eslint/utils": "^8.53.1",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.7.4-beta.
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/
|
|
38
|
+
"@eslint-react/ast": "2.7.4-beta.8",
|
|
39
|
+
"@eslint-react/shared": "2.7.4-beta.8",
|
|
40
|
+
"@eslint-react/var": "2.7.4-beta.8",
|
|
41
|
+
"@eslint-react/eff": "2.7.4-beta.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.20.1",
|