@eslint-react/core 5.2.2-next.0 → 5.2.3-beta.0
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 +56 -44
- package/dist/index.js +12 -3
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TSESTreeClass, TSESTreeDirective, TSESTreeFunction, TSESTreeMethodOrPropertyDefinition } from "@eslint-react/ast";
|
|
2
2
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
import { RuleContext } from "@eslint-react/eslint";
|
|
4
4
|
import { RegExpLike } from "@eslint-react/shared";
|
|
@@ -118,7 +118,7 @@ declare const isUseTransitionCall: isAPICall.ReturnType;
|
|
|
118
118
|
* @param node The class node to get the identifier from
|
|
119
119
|
* @returns The class identifier or null if not found
|
|
120
120
|
*/
|
|
121
|
-
declare function getClassId(node:
|
|
121
|
+
declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | null;
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/semantic.d.ts
|
|
124
124
|
/**
|
|
@@ -149,7 +149,7 @@ interface SemanticFunc extends SemanticNode {
|
|
|
149
149
|
/** The identifier of the function */
|
|
150
150
|
id: null | TSESTree.Node;
|
|
151
151
|
/** The AST node of the function */
|
|
152
|
-
node:
|
|
152
|
+
node: TSESTreeFunction;
|
|
153
153
|
/** The name of the function */
|
|
154
154
|
name: string | null;
|
|
155
155
|
/** The return type annotation of the function */
|
|
@@ -157,7 +157,7 @@ interface SemanticFunc extends SemanticNode {
|
|
|
157
157
|
/** The body of the function */
|
|
158
158
|
body: TSESTree.BlockStatement | TSESTree.Expression;
|
|
159
159
|
/** The directives of the function (ex: "use strict", "use client", "use server", etc.) */
|
|
160
|
-
directives:
|
|
160
|
+
directives: TSESTreeDirective[];
|
|
161
161
|
/** The parameters of the function */
|
|
162
162
|
parameters: TSESTree.Parameter[];
|
|
163
163
|
/** The type parameters of the function */
|
|
@@ -174,68 +174,68 @@ interface ClassComponentSemanticNode extends SemanticNode {
|
|
|
174
174
|
displayName: null | TSESTree.Expression;
|
|
175
175
|
flag: bigint;
|
|
176
176
|
hint: bigint;
|
|
177
|
-
methods:
|
|
178
|
-
node:
|
|
177
|
+
methods: TSESTreeMethodOrPropertyDefinition[];
|
|
178
|
+
node: TSESTreeClass;
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* @param node The AST node to check.
|
|
182
182
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
183
183
|
*/
|
|
184
|
-
declare function isClassComponent(node: TSESTree.Node): node is
|
|
184
|
+
declare function isClassComponent(node: TSESTree.Node): node is TSESTreeClass;
|
|
185
185
|
/**
|
|
186
186
|
* @param node The AST node to check.
|
|
187
187
|
* @param context The rule context.
|
|
188
188
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
189
189
|
*/
|
|
190
|
-
declare function isClassComponent(node: TSESTree.Node, context: RuleContext): node is
|
|
191
|
-
declare function isClassComponentLoose(node: TSESTree.Node): node is
|
|
190
|
+
declare function isClassComponent(node: TSESTree.Node, context: RuleContext): node is TSESTreeClass;
|
|
191
|
+
declare function isClassComponentLoose(node: TSESTree.Node): node is TSESTreeClass;
|
|
192
192
|
/**
|
|
193
193
|
* @param node The AST node to check.
|
|
194
194
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
195
195
|
*/
|
|
196
196
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
197
197
|
/** @deprecated Class components are legacy. */
|
|
198
|
-
declare const isRender: (node: TSESTree.Node) => node is
|
|
198
|
+
declare const isRender: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
199
199
|
/** @deprecated Class components are legacy. */
|
|
200
|
-
declare const isComponentDidCatch: (node: TSESTree.Node) => node is
|
|
200
|
+
declare const isComponentDidCatch: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
201
201
|
/** @deprecated Class components are legacy. */
|
|
202
|
-
declare const isComponentDidMount: (node: TSESTree.Node) => node is
|
|
202
|
+
declare const isComponentDidMount: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
203
203
|
/** @deprecated Class components are legacy. */
|
|
204
|
-
declare const isComponentDidUpdate: (node: TSESTree.Node) => node is
|
|
204
|
+
declare const isComponentDidUpdate: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
205
205
|
/** @deprecated Class components are legacy. */
|
|
206
|
-
declare const isComponentWillMount: (node: TSESTree.Node) => node is
|
|
206
|
+
declare const isComponentWillMount: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
207
207
|
/** @deprecated Class components are legacy. */
|
|
208
|
-
declare const isComponentWillReceiveProps: (node: TSESTree.Node) => node is
|
|
208
|
+
declare const isComponentWillReceiveProps: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
209
209
|
/** @deprecated Class components are legacy. */
|
|
210
|
-
declare const isComponentWillUnmount: (node: TSESTree.Node) => node is
|
|
210
|
+
declare const isComponentWillUnmount: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
211
211
|
/** @deprecated Class components are legacy. */
|
|
212
|
-
declare const isComponentWillUpdate: (node: TSESTree.Node) => node is
|
|
212
|
+
declare const isComponentWillUpdate: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
213
213
|
/** @deprecated Class components are legacy. */
|
|
214
|
-
declare const isGetChildContext: (node: TSESTree.Node) => node is
|
|
214
|
+
declare const isGetChildContext: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
215
215
|
/** @deprecated Class components are legacy. */
|
|
216
|
-
declare const isGetInitialState: (node: TSESTree.Node) => node is
|
|
216
|
+
declare const isGetInitialState: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
217
217
|
/** @deprecated Class components are legacy. */
|
|
218
|
-
declare const isGetSnapshotBeforeUpdate: (node: TSESTree.Node) => node is
|
|
218
|
+
declare const isGetSnapshotBeforeUpdate: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
219
219
|
/** @deprecated Class components are legacy. */
|
|
220
|
-
declare const isShouldComponentUpdate: (node: TSESTree.Node) => node is
|
|
220
|
+
declare const isShouldComponentUpdate: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
221
221
|
/** @deprecated Class components are legacy. */
|
|
222
|
-
declare const isUnsafeComponentWillMount: (node: TSESTree.Node) => node is
|
|
222
|
+
declare const isUnsafeComponentWillMount: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
223
223
|
/** @deprecated Class components are legacy. */
|
|
224
|
-
declare const isUnsafeComponentWillReceiveProps: (node: TSESTree.Node) => node is
|
|
224
|
+
declare const isUnsafeComponentWillReceiveProps: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
225
225
|
/** @deprecated Class components are legacy. */
|
|
226
|
-
declare const isUnsafeComponentWillUpdate: (node: TSESTree.Node) => node is
|
|
226
|
+
declare const isUnsafeComponentWillUpdate: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
227
227
|
/** @deprecated Class components are legacy. */
|
|
228
|
-
declare const isGetDefaultProps: (node: TSESTree.Node) => node is
|
|
228
|
+
declare const isGetDefaultProps: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
229
229
|
/** @deprecated Class components are legacy. */
|
|
230
|
-
declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is
|
|
230
|
+
declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
231
231
|
/** @deprecated Class components are legacy. */
|
|
232
|
-
declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is
|
|
232
|
+
declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is TSESTreeMethodOrPropertyDefinition;
|
|
233
233
|
/**
|
|
234
234
|
* @param node The AST node to check.
|
|
235
235
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
236
236
|
*/
|
|
237
|
-
declare function isRenderMethodLike(node: TSESTree.Node): node is
|
|
238
|
-
declare function isRenderMethodCallback(node:
|
|
237
|
+
declare function isRenderMethodLike(node: TSESTree.Node): node is TSESTreeMethodOrPropertyDefinition;
|
|
238
|
+
declare function isRenderMethodCallback(node: TSESTreeFunction): boolean;
|
|
239
239
|
/**
|
|
240
240
|
* @param node The call expression node to check.
|
|
241
241
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
@@ -274,7 +274,7 @@ type FunctionID = ReturnType<typeof getFunctionId>;
|
|
|
274
274
|
* Represents various AST paths for function declarations.
|
|
275
275
|
* Each tuple type represents a specific function definition pattern.
|
|
276
276
|
*/
|
|
277
|
-
type FunctionInitPath = readonly [TSESTree.FunctionDeclaration] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator,
|
|
277
|
+
type FunctionInitPath = readonly [TSESTree.FunctionDeclaration] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration | TSESTree.ClassExpression, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration | TSESTree.ClassExpression, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
|
|
278
278
|
/**
|
|
279
279
|
* Represents the kind of a function.
|
|
280
280
|
*/
|
|
@@ -315,14 +315,14 @@ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticN
|
|
|
315
315
|
* @param node - The function node to analyze.
|
|
316
316
|
* @returns The identifier node if found, `null` otherwise.
|
|
317
317
|
*/
|
|
318
|
-
declare function getFunctionId(node: TSESTree.Expression |
|
|
318
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | null;
|
|
319
319
|
/**
|
|
320
320
|
* Identifies the initialization path of a function node in the AST.
|
|
321
321
|
*
|
|
322
322
|
* @param node - The function node to analyze.
|
|
323
323
|
* @returns The function initialization path or `null` if not identifiable.
|
|
324
324
|
*/
|
|
325
|
-
declare function getFunctionInitPath(node:
|
|
325
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): null | FunctionInitPath;
|
|
326
326
|
/**
|
|
327
327
|
* Checks if a specific function call exists in the function initialization path.
|
|
328
328
|
*
|
|
@@ -337,14 +337,14 @@ declare function isFunctionHasCallInInitPath(callName: string, initPath: Functio
|
|
|
337
337
|
* @param node - The function node to check.
|
|
338
338
|
* @returns `true` if the function is empty, `false` otherwise.
|
|
339
339
|
*/
|
|
340
|
-
declare function isFunctionEmpty(node:
|
|
340
|
+
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
341
341
|
/**
|
|
342
342
|
* Gets all directive expression statements from the top of a function body.
|
|
343
343
|
*
|
|
344
344
|
* @param node - The function AST node.
|
|
345
345
|
* @returns An array of directive expression statements.
|
|
346
346
|
*/
|
|
347
|
-
declare function getFunctionDirectives(node:
|
|
347
|
+
declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirective[];
|
|
348
348
|
/**
|
|
349
349
|
* Checks if a directive with the given name exists in the function directives.
|
|
350
350
|
*
|
|
@@ -352,7 +352,7 @@ declare function getFunctionDirectives(node: FunctionExpression): Directive[];
|
|
|
352
352
|
* @param name - The directive name to check (e.g., "use memo", "use no memo").
|
|
353
353
|
* @returns `true` if the directive exists, `false` otherwise.
|
|
354
354
|
*/
|
|
355
|
-
declare function isFunctionHasDirective(node:
|
|
355
|
+
declare function isFunctionHasDirective(node: TSESTreeFunction, name: string): boolean;
|
|
356
356
|
//#endregion
|
|
357
357
|
//#region src/function-component.d.ts
|
|
358
358
|
/**
|
|
@@ -370,7 +370,7 @@ interface FunctionComponentSemanticNode extends SemanticNode {
|
|
|
370
370
|
/**
|
|
371
371
|
* The AST node of the function
|
|
372
372
|
*/
|
|
373
|
-
node:
|
|
373
|
+
node: TSESTreeFunction;
|
|
374
374
|
/**
|
|
375
375
|
* Flags describing the component's characteristics
|
|
376
376
|
*/
|
|
@@ -406,7 +406,7 @@ interface FunctionComponentSemanticNode extends SemanticNode {
|
|
|
406
406
|
/**
|
|
407
407
|
* The directives used in the function (ex: "use strict", "use client", etc.)
|
|
408
408
|
*/
|
|
409
|
-
directives:
|
|
409
|
+
directives: TSESTreeDirective[];
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
412
|
* Component flag constants
|
|
@@ -445,7 +445,7 @@ declare function isFunctionComponentWrapperCallback(context: RuleContext, node:
|
|
|
445
445
|
* @param node The AST node to get the function component identifier from
|
|
446
446
|
* @internal
|
|
447
447
|
*/
|
|
448
|
-
declare function getFunctionComponentId(context: RuleContext, node:
|
|
448
|
+
declare function getFunctionComponentId(context: RuleContext, node: TSESTreeFunction): FunctionID;
|
|
449
449
|
/**
|
|
450
450
|
* Check if a string matches the strict component name pattern
|
|
451
451
|
* @param name The name to check
|
|
@@ -463,7 +463,7 @@ declare function isFunctionComponentNameLoose(name: string): boolean;
|
|
|
463
463
|
* @param allowNone Whether to allow no name
|
|
464
464
|
* @returns Whether the function has a loose component name
|
|
465
465
|
*/
|
|
466
|
-
declare function isFunctionWithLooseComponentName(context: RuleContext, fn:
|
|
466
|
+
declare function isFunctionWithLooseComponentName(context: RuleContext, fn: TSESTreeFunction, allowNone?: boolean): boolean;
|
|
467
467
|
type FunctionComponentDetectionHint = bigint;
|
|
468
468
|
/**
|
|
469
469
|
* Hints for component collector
|
|
@@ -502,7 +502,7 @@ declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
|
502
502
|
* @param hint Component detection hints (bit flags) to customize detection logic
|
|
503
503
|
* @returns `true` if the node is considered a component definition
|
|
504
504
|
*/
|
|
505
|
-
declare function isFunctionComponentDefinition(context: RuleContext, node:
|
|
505
|
+
declare function isFunctionComponentDefinition(context: RuleContext, node: TSESTreeFunction, hint: bigint): boolean;
|
|
506
506
|
//#endregion
|
|
507
507
|
//#region src/function-component-collector.d.ts
|
|
508
508
|
declare namespace getFunctionComponentCollector {
|
|
@@ -525,6 +525,18 @@ declare namespace getFunctionComponentCollector {
|
|
|
525
525
|
*/
|
|
526
526
|
declare function getFunctionComponentCollector(context: RuleContext, options?: getFunctionComponentCollector.Options): getFunctionComponentCollector.ReturnType;
|
|
527
527
|
//#endregion
|
|
528
|
+
//#region src/function-display-name.d.ts
|
|
529
|
+
type FunctionDisplayNameAssignment = TSESTree.AssignmentExpression & {
|
|
530
|
+
left: TSESTree.MemberExpression & {
|
|
531
|
+
property: TSESTree.Identifier & {
|
|
532
|
+
name: "displayName";
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
operator: "=";
|
|
536
|
+
right: TSESTree.Literal;
|
|
537
|
+
};
|
|
538
|
+
declare const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT: string;
|
|
539
|
+
//#endregion
|
|
528
540
|
//#region src/hook.d.ts
|
|
529
541
|
/**
|
|
530
542
|
* Represents a semantic hook node in the AST
|
|
@@ -533,7 +545,7 @@ interface HookSemanticNode extends SemanticNode {
|
|
|
533
545
|
/** The identifier of the hook */
|
|
534
546
|
id: FunctionID;
|
|
535
547
|
/** The AST node of the hook */
|
|
536
|
-
node:
|
|
548
|
+
node: TSESTreeFunction;
|
|
537
549
|
/** The kind of hook */
|
|
538
550
|
kind: "hook";
|
|
539
551
|
/** List of expressions returned by the hook */
|
|
@@ -541,7 +553,7 @@ interface HookSemanticNode extends SemanticNode {
|
|
|
541
553
|
/** The other hooks called by the hook */
|
|
542
554
|
hookCalls: TSESTree.CallExpression[];
|
|
543
555
|
/** The directives used in the function (ex: "use strict", "use client", etc.) */
|
|
544
|
-
directives:
|
|
556
|
+
directives: TSESTreeDirective[];
|
|
545
557
|
}
|
|
546
558
|
declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
|
|
547
559
|
/**
|
|
@@ -562,7 +574,7 @@ declare function isHookId(id: TSESTree.Node): id is TSESTree.Identifier | TSESTr
|
|
|
562
574
|
* @param node The function node to check
|
|
563
575
|
* @returns True if the function is a React Hook, false otherwise
|
|
564
576
|
*/
|
|
565
|
-
declare function isHookDefinition(node:
|
|
577
|
+
declare function isHookDefinition(node: TSESTreeFunction | null): boolean;
|
|
566
578
|
/**
|
|
567
579
|
* Check if the given node is a React Hook call by its name.
|
|
568
580
|
* @param node The node to check.
|
|
@@ -738,4 +750,4 @@ type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" |
|
|
|
738
750
|
*/
|
|
739
751
|
declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|
|
740
752
|
//#endregion
|
|
741
|
-
export { ClassComponentSemanticNode, ClientFunctionSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, FunctionComponentSemanticNode, FunctionID, FunctionInitPath, FunctionKind, FunctionSemanticNode, HookSemanticNode, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, TypeVariant, getClassComponentCollector, getClassId, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getTypeVariants, isAPI, isAPICall, isAPIFromReact, isAPIFromReactNative, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isClassComponentLoose, 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, 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, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
|
|
753
|
+
export { ClassComponentSemanticNode, ClientFunctionSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, FunctionComponentSemanticNode, FunctionDisplayNameAssignment, FunctionID, FunctionInitPath, FunctionKind, FunctionSemanticNode, HookSemanticNode, REACT_BUILTIN_HOOK_NAMES, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, TypeVariant, getClassComponentCollector, getClassId, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getTypeVariants, isAPI, isAPICall, isAPIFromReact, isAPIFromReactNative, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isClassComponentLoose, 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, 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, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Check, Extract,
|
|
1
|
+
import { Check, Extract, Traverse, is, isOneOf } from "@eslint-react/ast";
|
|
2
2
|
import { resolveImportSource } from "@eslint-react/var";
|
|
3
3
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
4
4
|
import "@eslint-react/eslint";
|
|
@@ -709,6 +709,15 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
709
709
|
return true;
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
+
//#endregion
|
|
713
|
+
//#region src/function-display-name.ts
|
|
714
|
+
const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT = [
|
|
715
|
+
"AssignmentExpression",
|
|
716
|
+
"[operator='=']",
|
|
717
|
+
"[left.type='MemberExpression']",
|
|
718
|
+
"[left.property.name='displayName']"
|
|
719
|
+
].join("");
|
|
720
|
+
|
|
712
721
|
//#endregion
|
|
713
722
|
//#region src/hook.ts
|
|
714
723
|
const REACT_BUILTIN_HOOK_NAMES = [
|
|
@@ -893,7 +902,7 @@ function getFunctionComponentCollector(context, options = {}) {
|
|
|
893
902
|
if (!components.has(entry.key) && !isJsxLike(context, body, hint)) return;
|
|
894
903
|
components.set(entry.key, entry);
|
|
895
904
|
},
|
|
896
|
-
...collectDisplayName ? { [
|
|
905
|
+
...collectDisplayName ? { [SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT](node) {
|
|
897
906
|
const { left, right } = node;
|
|
898
907
|
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
899
908
|
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : null;
|
|
@@ -1133,4 +1142,4 @@ function getTypeVariants(types) {
|
|
|
1133
1142
|
}
|
|
1134
1143
|
|
|
1135
1144
|
//#endregion
|
|
1136
|
-
export { DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, REACT_BUILTIN_HOOK_NAMES, getClassComponentCollector, getClassId, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getTypeVariants, isAPI, isAPICall, isAPIFromReact, isAPIFromReactNative, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isClassComponentLoose, 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, 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, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };
|
|
1145
|
+
export { DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, REACT_BUILTIN_HOOK_NAMES, SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT, getClassComponentCollector, getClassId, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHookCollector, getTypeVariants, isAPI, isAPICall, isAPIFromReact, isAPIFromReactNative, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isClassComponentLoose, 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, 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, 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.2.
|
|
3
|
+
"version": "5.2.3-beta.0",
|
|
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": {
|
|
@@ -30,22 +30,22 @@
|
|
|
30
30
|
"./package.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@typescript-eslint/scope-manager": "^8.58.
|
|
34
|
-
"@typescript-eslint/types": "^8.58.
|
|
35
|
-
"@typescript-eslint/utils": "^8.58.
|
|
33
|
+
"@typescript-eslint/scope-manager": "^8.58.2",
|
|
34
|
+
"@typescript-eslint/types": "^8.58.2",
|
|
35
|
+
"@typescript-eslint/utils": "^8.58.2",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
37
|
"ulid": "^3.0.2",
|
|
38
|
-
"@eslint-react/ast": "5.2.
|
|
39
|
-
"@eslint-react/eslint": "5.2.
|
|
40
|
-
"@eslint-react/shared": "5.2.
|
|
41
|
-
"@eslint-react/jsx": "5.2.
|
|
42
|
-
"@eslint-react/var": "5.2.
|
|
38
|
+
"@eslint-react/ast": "5.2.3-beta.0",
|
|
39
|
+
"@eslint-react/eslint": "5.2.3-beta.0",
|
|
40
|
+
"@eslint-react/shared": "5.2.3-beta.0",
|
|
41
|
+
"@eslint-react/jsx": "5.2.3-beta.0",
|
|
42
|
+
"@eslint-react/var": "5.2.3-beta.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@typescript-eslint/typescript-estree": "^8.58.
|
|
46
|
-
"tsdown": "^0.21.
|
|
47
|
-
"@local/
|
|
48
|
-
"@local/
|
|
45
|
+
"@typescript-eslint/typescript-estree": "^8.58.2",
|
|
46
|
+
"tsdown": "^0.21.8",
|
|
47
|
+
"@local/configs": "0.0.0",
|
|
48
|
+
"@local/eff": "3.0.0-beta.72"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"eslint": "^10.2.0",
|