@eslint-react/core 2.0.5-next.1 → 2.0.5-next.3
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 +7 -10
- package/dist/index.js +19 -18
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -431,17 +431,14 @@ declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit): boolean
|
|
|
431
431
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boolean;
|
|
432
432
|
//#endregion
|
|
433
433
|
//#region src/jsx/jsx-attribute.d.ts
|
|
434
|
-
declare function getJsxAttribute(context: RuleContext, attributes: AST.TSESTreeJSXAttributeLike[], initialScope?: Scope): (name: string) => AST.TSESTreeJSXAttributeLike | undefined;
|
|
435
434
|
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* @param
|
|
439
|
-
* @param
|
|
440
|
-
* @
|
|
441
|
-
* @param initialScope - Optional scope for resolving variables in spread attributes
|
|
442
|
-
* @returns boolean indicating whether the attribute exists
|
|
435
|
+
* Get a function to find JSX attributes by name, considering direct attributes and spread attributes.
|
|
436
|
+
* @param context The ESLint rule context
|
|
437
|
+
* @param node The JSX element node
|
|
438
|
+
* @param initialScope Optional initial scope for variable resolution
|
|
439
|
+
* @returns A function that takes an attribute name and returns the corresponding JSX attribute node or undefined
|
|
443
440
|
*/
|
|
444
|
-
declare function
|
|
441
|
+
declare function getJsxAttribute(context: RuleContext, node: TSESTree.JSXElement, initialScope?: Scope): (name: string) => TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined;
|
|
445
442
|
//#endregion
|
|
446
443
|
//#region src/jsx/jsx-attribute-name.d.ts
|
|
447
444
|
/**
|
|
@@ -708,4 +705,4 @@ declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
|
708
705
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
709
706
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
710
707
|
//#endregion
|
|
711
|
-
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, EffectKind, FunctionComponent, Hook, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, findParentJsxAttribute, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction,
|
|
708
|
+
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, EffectKind, 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, isChildrenOfCreateElement, 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, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, 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
|
@@ -307,36 +307,37 @@ function getJsxAttributeName(context, node) {
|
|
|
307
307
|
|
|
308
308
|
//#endregion
|
|
309
309
|
//#region src/jsx/jsx-attribute.ts
|
|
310
|
-
|
|
310
|
+
/**
|
|
311
|
+
* Get a function to find JSX attributes by name, considering direct attributes and spread attributes.
|
|
312
|
+
* @param context The ESLint rule context
|
|
313
|
+
* @param node The JSX element node
|
|
314
|
+
* @param initialScope Optional initial scope for variable resolution
|
|
315
|
+
* @returns A function that takes an attribute name and returns the corresponding JSX attribute node or undefined
|
|
316
|
+
*/
|
|
317
|
+
function getJsxAttribute(context, node, initialScope) {
|
|
318
|
+
const scope = initialScope ?? context.sourceCode.getScope(node);
|
|
319
|
+
const attributes = node.openingElement.attributes;
|
|
320
|
+
/**
|
|
321
|
+
* Find a JSX attribute by name, considering both direct attributes and spread attributes.
|
|
322
|
+
* @param name The name of the attribute to find
|
|
323
|
+
* @returns The JSX attribute node if found, otherwise undefined
|
|
324
|
+
*/
|
|
311
325
|
return (name) => {
|
|
312
326
|
return attributes.findLast((attr) => {
|
|
313
327
|
if (attr.type === AST_NODE_TYPES.JSXAttribute) return getJsxAttributeName(context, attr) === name;
|
|
314
|
-
if (initialScope == null) return false;
|
|
315
328
|
switch (attr.argument.type) {
|
|
316
329
|
case AST_NODE_TYPES.Identifier: {
|
|
317
|
-
const variable = findVariable(attr.argument.name,
|
|
330
|
+
const variable = findVariable(attr.argument.name, scope);
|
|
318
331
|
const variableNode = getVariableDefinitionNode(variable, 0);
|
|
319
|
-
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return findProperty(name, variableNode.properties,
|
|
332
|
+
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return findProperty(name, variableNode.properties, scope) != null;
|
|
320
333
|
return false;
|
|
321
334
|
}
|
|
322
|
-
case AST_NODE_TYPES.ObjectExpression: return findProperty(name, attr.argument.properties,
|
|
335
|
+
case AST_NODE_TYPES.ObjectExpression: return findProperty(name, attr.argument.properties, scope) != null;
|
|
323
336
|
}
|
|
324
337
|
return false;
|
|
325
338
|
});
|
|
326
339
|
};
|
|
327
340
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Checks if a JSX element has a specific attribute
|
|
330
|
-
*
|
|
331
|
-
* @param context - ESLint rule context
|
|
332
|
-
* @param name - Name of the attribute to check for
|
|
333
|
-
* @param attributes - List of JSX attributes from opening element
|
|
334
|
-
* @param initialScope - Optional scope for resolving variables in spread attributes
|
|
335
|
-
* @returns boolean indicating whether the attribute exists
|
|
336
|
-
*/
|
|
337
|
-
function hasJsxAttribute(context, name, attributes, initialScope) {
|
|
338
|
-
return getJsxAttribute(context, attributes, initialScope)(name) != null;
|
|
339
|
-
}
|
|
340
341
|
|
|
341
342
|
//#endregion
|
|
342
343
|
//#region src/jsx/jsx-attribute-value.ts
|
|
@@ -1183,4 +1184,4 @@ function isAssignmentToThisState(node) {
|
|
|
1183
1184
|
}
|
|
1184
1185
|
|
|
1185
1186
|
//#endregion
|
|
1186
|
-
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,
|
|
1187
|
+
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, isChildrenOfCreateElement, 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, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, 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.0.5-next.
|
|
3
|
+
"version": "2.0.5-next.3",
|
|
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": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@typescript-eslint/utils": "^8.45.0",
|
|
33
33
|
"birecord": "^0.1.1",
|
|
34
34
|
"ts-pattern": "^5.8.0",
|
|
35
|
-
"@eslint-react/ast": "2.0.5-next.
|
|
36
|
-
"@eslint-react/eff": "2.0.5-next.
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
35
|
+
"@eslint-react/ast": "2.0.5-next.3",
|
|
36
|
+
"@eslint-react/eff": "2.0.5-next.3",
|
|
37
|
+
"@eslint-react/shared": "2.0.5-next.3",
|
|
38
|
+
"@eslint-react/kit": "2.0.5-next.3",
|
|
39
|
+
"@eslint-react/var": "2.0.5-next.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsdown": "^0.15.6",
|