@eslint-react/core 5.30.0-beta.0 → 5.30.0-beta.1

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 CHANGED
@@ -326,67 +326,6 @@ export declare namespace getClassComponentCollector {
326
326
  * @deprecated Class components are legacy. This function exists only to support legacy rules.
327
327
  */
328
328
  export declare function getClassComponentCollector(context: RuleContext): getClassComponentCollector.ReturnType;
329
- /**
330
- * Get the type argument (the first argument) of a `createElement` call.
331
- * @param context The ESLint rule context.
332
- * @param node The node to inspect.
333
- * @returns The type argument, or `null` when the node is not a `createElement` call or has no arguments.
334
- */
335
- export declare function getCreateElementTypeArgument(context: RuleContext, node: null | TSESTree.Node): TSESTree.CallExpressionArgument | null;
336
- /**
337
- * Get the props object (the second argument) of a `createElement` call.
338
- *
339
- * Type expressions and chain expressions wrapping the argument are unwrapped
340
- * before the object check; `null`, spread, or otherwise non-object props
341
- * arguments yield `null`.
342
- *
343
- * @param context The ESLint rule context.
344
- * @param node The node to inspect.
345
- * @returns The props `ObjectExpression`, or `null` when absent or not statically an object literal.
346
- */
347
- export declare function getCreateElementPropsObject(context: RuleContext, node: null | TSESTree.Node): TSESTree.ObjectExpression | null;
348
- /**
349
- * Get the children arguments (the arguments after the props object) of a `createElement` call.
350
- * @param context The ESLint rule context.
351
- * @param node The node to inspect.
352
- * @returns The children arguments, or an empty array when the node is not a `createElement` call.
353
- */
354
- export declare function getCreateElementChildrenArguments(context: RuleContext, node: null | TSESTree.Node): TSESTree.CallExpressionArgument[];
355
- /**
356
- * Find a statically named property in the props object of a `createElement` call.
357
- *
358
- * Statically resolvable names include plain identifier keys as well as
359
- * string-literal and simple template-literal keys (computed or not).
360
- * @param context The ESLint rule context.
361
- * @param node The node to inspect.
362
- * @param name The property name to look for (ex: `"children"`, `"key"`).
363
- * @returns The matching `Property` node, or `null` when the call has no static property with that name.
364
- *
365
- * @example
366
- * ```ts
367
- * import { getCreateElementProp } from "@eslint-react/core";
368
- *
369
- * const childrenProp = getCreateElementProp(context, node, "children");
370
- * ```
371
- */
372
- export declare function getCreateElementProp(context: RuleContext, node: null | TSESTree.Node, name: string): TSESTree.Property | null;
373
- /**
374
- * Check if the node is passed as a children argument (the third argument or
375
- * later) of a `createElement` call.
376
- * @param context The ESLint rule context.
377
- * @param node The node to check.
378
- * @returns `true` if the node is a direct children argument of a `createElement` call.
379
- */
380
- export declare function isCreateElementChildrenArgument(context: RuleContext, node: TSESTree.Node): boolean;
381
- /**
382
- * Check if the node is directly inside the props object (the second argument) of a `createElement` call,
383
- * that is, its closest `ObjectExpression` ancestor is the props object itself. Nodes nested deeper
384
- * (ex: inside an object nested in the props object) are not considered inside.
385
- * @param context The ESLint rule context.
386
- * @param node The node to check.
387
- * @returns `true` if the node is directly inside `createElement`'s props object.
388
- */
389
- export declare function isInsideCreateElementProps(context: RuleContext, node: TSESTree.Node): boolean;
390
329
  /** The return type of {@link getFunctionId}. */
391
330
  export type FunctionID = ReturnType<typeof getFunctionId>;
392
331
  /**
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Check, Extract, Traverse } from "@eslint-react/ast";
2
2
  import { getText } from "@eslint-react/eslint";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
4
+ import { isCreateElementChildrenArgument } from "@eslint-react/jsx";
4
5
  import { 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";
5
6
  import { resolve } from "@eslint-react/var";
6
7
  import { findVariable } from "@typescript-eslint/utils/ast-utils";
@@ -296,42 +297,6 @@ function getClassComponentCollector(context) {
296
297
  }
297
298
  };
298
299
  }
299
- // src/create-element.ts
300
- function getCreateElementTypeArgument(context, node) {
301
- if (!isCreateElementCall(context, node)) return null;
302
- return node.arguments[0] ?? null;
303
- }
304
- function getCreateElementPropsObject(context, node) {
305
- if (!isCreateElementCall(context, node)) return null;
306
- const propsArg = node.arguments[1];
307
- if (propsArg == null) return null;
308
- const expr = Extract.unwrap(propsArg);
309
- return expr.type === AST_NODE_TYPES.ObjectExpression ? expr : null;
310
- }
311
- function getCreateElementChildrenArguments(context, node) {
312
- if (!isCreateElementCall(context, node)) return [];
313
- return node.arguments.slice(2);
314
- }
315
- function getCreateElementProp(context, node, name) {
316
- const propsObject = getCreateElementPropsObject(context, node);
317
- if (propsObject == null) return null;
318
- for (const prop of propsObject.properties) if (prop.type === AST_NODE_TYPES.Property && Extract.getPropertyName(prop, "max") === name) return prop;
319
- return null;
320
- }
321
- function isCreateElementChildrenArgument(context, node) {
322
- let parent = node.parent;
323
- while (Check.isTypeExpression(parent)) parent = parent.parent;
324
- return parent?.type === AST_NODE_TYPES.CallExpression && isCreateElementCall(context, parent) && parent.arguments.slice(2).some((arg) => Extract.unwrap(arg) === Extract.unwrap(node));
325
- }
326
- function isInsideCreateElementProps(context, node) {
327
- const call = Traverse.findParent(node, isCreateElementCall(context));
328
- if (call == null) return false;
329
- const prop = Traverse.findParent(node, Check.isObjectExpression);
330
- if (prop == null) return false;
331
- const propsArg = call.arguments[1];
332
- if (propsArg == null) return false;
333
- return prop === Extract.unwrap(propsArg);
334
- }
335
300
  // src/function.ts
336
301
  function getFunctionId(node) {
337
302
  switch (true) {
@@ -956,4 +921,4 @@ function getTypeVariants(types) {
956
921
  if (types.some(isNeverType)) variants.add("never");
957
922
  return variants;
958
923
  }
959
- export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JSXDetectionHint, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getCreateElementChildrenArguments, getCreateElementProp, getCreateElementPropsObject, getCreateElementTypeArgument, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getJSXConfig, getJSXConfigFromAnnotation, getJSXConfigFromCompilerOptions, getTypeVariants, isAPI, isAPICall, isAnyType, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateElementChildrenArgument, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionEmpty, isFunctionHasCallInInitPath, isFunctionHasDirective, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isHookTag, isInsideCreateElementProps, isJSXLike, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseRefLikeCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
924
+ export { DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, JSXDetectionHint, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getJSXConfig, getJSXConfigFromAnnotation, getJSXConfigFromCompilerOptions, getTypeVariants, isAPI, isAPICall, isAnyType, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionEmpty, isFunctionHasCallInInitPath, isFunctionHasDirective, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isHookTag, isJSXLike, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseRefLikeCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.30.0-beta.0",
3
+ "version": "5.30.0-beta.1",
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": {
@@ -29,10 +29,11 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.30.0-beta.0",
33
- "@eslint-react/eslint": "5.30.0-beta.0",
34
- "@eslint-react/shared": "5.30.0-beta.0",
35
- "@eslint-react/var": "5.30.0-beta.0",
32
+ "@eslint-react/ast": "5.30.0-beta.1",
33
+ "@eslint-react/eslint": "5.30.0-beta.1",
34
+ "@eslint-react/jsx": "5.30.0-beta.1",
35
+ "@eslint-react/shared": "5.30.0-beta.1",
36
+ "@eslint-react/var": "5.30.0-beta.1",
36
37
  "@typescript-eslint/types": "^8.72.0",
37
38
  "@typescript-eslint/utils": "^8.72.0",
38
39
  "ts-pattern": "^5.9.2"