@eslint-react/core 2.0.0-next.14 → 2.0.0-next.140
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 +156 -37
- package/dist/index.js +129 -26
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { RuleContext } from '@eslint-react/kit';
|
|
2
2
|
import { TSESTree } from '@typescript-eslint/types';
|
|
3
|
-
import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
4
3
|
import * as AST from '@eslint-react/ast';
|
|
5
|
-
import {
|
|
4
|
+
import { unit } from '@eslint-react/eff';
|
|
5
|
+
import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
6
6
|
import * as birecord from 'birecord';
|
|
7
7
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
8
8
|
import * as VAR from '@eslint-react/var';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
export { isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Determines whether inside `createElement`'s children.
|
|
@@ -80,10 +82,10 @@ interface SemanticEntry {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
interface SemanticNode {
|
|
83
|
-
id:
|
|
85
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
84
86
|
key: string;
|
|
85
87
|
kind: string;
|
|
86
|
-
name:
|
|
88
|
+
name: unit | string;
|
|
87
89
|
node: TSESTree.Node;
|
|
88
90
|
flag: bigint;
|
|
89
91
|
hint: bigint;
|
|
@@ -100,23 +102,23 @@ declare const ComponentFlag: {
|
|
|
100
102
|
};
|
|
101
103
|
|
|
102
104
|
interface FunctionComponent extends SemanticNode {
|
|
103
|
-
id:
|
|
105
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
104
106
|
kind: "function";
|
|
105
107
|
node: AST.TSESTreeFunction;
|
|
106
108
|
flag: ComponentFlag;
|
|
107
109
|
hint: ComponentDetectionHint;
|
|
108
|
-
initPath:
|
|
110
|
+
initPath: unit | AST.FunctionInitPath;
|
|
109
111
|
hookCalls: TSESTree.CallExpression[];
|
|
110
|
-
displayName:
|
|
112
|
+
displayName: unit | TSESTree.Expression;
|
|
111
113
|
}
|
|
112
114
|
interface ClassComponent extends SemanticNode {
|
|
113
|
-
id:
|
|
115
|
+
id: unit | TSESTree.Identifier;
|
|
114
116
|
kind: "class";
|
|
115
117
|
node: AST.TSESTreeClass;
|
|
116
118
|
flag: ComponentFlag;
|
|
117
119
|
hint: ComponentDetectionHint;
|
|
118
120
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
119
|
-
displayName:
|
|
121
|
+
displayName: unit | TSESTree.Expression;
|
|
120
122
|
}
|
|
121
123
|
type Component = ClassComponent | FunctionComponent;
|
|
122
124
|
|
|
@@ -136,7 +138,7 @@ declare namespace useComponentCollector {
|
|
|
136
138
|
ctx: {
|
|
137
139
|
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
138
140
|
getCurrentEntries: () => FunctionEntry[];
|
|
139
|
-
getCurrentEntry: () => FunctionEntry |
|
|
141
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
140
142
|
};
|
|
141
143
|
listeners: ESLintUtils.RuleListener;
|
|
142
144
|
};
|
|
@@ -178,7 +180,7 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
178
180
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
179
181
|
declare function isValidComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
180
182
|
|
|
181
|
-
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] |
|
|
183
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
182
184
|
|
|
183
185
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
184
186
|
|
|
@@ -217,7 +219,7 @@ declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TS
|
|
|
217
219
|
|
|
218
220
|
declare function isComponentName(name: string): boolean;
|
|
219
221
|
declare function isComponentNameLoose(name: string): boolean;
|
|
220
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] |
|
|
222
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
221
223
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
222
224
|
|
|
223
225
|
/**
|
|
@@ -331,8 +333,17 @@ declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTre
|
|
|
331
333
|
|
|
332
334
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
333
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Checks if the given node is inside a `vi.mock` callback.
|
|
338
|
+
* @param context RuleContext
|
|
339
|
+
* @param node The node to check
|
|
340
|
+
* @returns `true` if the node is inside a `vi.mock` callback, otherwise `false`.
|
|
341
|
+
* @internal
|
|
342
|
+
*/
|
|
343
|
+
declare function isInViMockCallback(context: RuleContext, node: TSESTree.Node): boolean;
|
|
344
|
+
|
|
334
345
|
interface Hook extends SemanticNode {
|
|
335
|
-
id: TSESTree.Identifier |
|
|
346
|
+
id: TSESTree.Identifier | unit;
|
|
336
347
|
node: AST.TSESTreeFunction;
|
|
337
348
|
name: string;
|
|
338
349
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -350,17 +361,17 @@ declare function useHookCollector(): useHookCollector.ReturnType;
|
|
|
350
361
|
|
|
351
362
|
declare function isReactHookId(id: TSESTree.Identifier | TSESTree.MemberExpression): boolean;
|
|
352
363
|
|
|
353
|
-
declare function isReactHook(node: AST.TSESTreeFunction |
|
|
364
|
+
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
354
365
|
/**
|
|
355
366
|
* Check if the given node is a React Hook call by its name.
|
|
356
367
|
* @param node The node to check.
|
|
357
368
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
358
369
|
*/
|
|
359
|
-
declare function isReactHookCall(node: TSESTree.Node |
|
|
360
|
-
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node |
|
|
361
|
-
declare function isReactHookCallWithNameLoose(node: TSESTree.Node |
|
|
362
|
-
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?:
|
|
363
|
-
declare function isUseEffectCallLoose(node: TSESTree.Node |
|
|
370
|
+
declare function isReactHookCall(node: TSESTree.Node | unit): boolean;
|
|
371
|
+
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | unit): (name: string) => boolean;
|
|
372
|
+
declare function isReactHookCallWithNameLoose(node: TSESTree.Node | unit): (name: string) => boolean;
|
|
373
|
+
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?: unit | string[]): (node: TSESTree.CallExpression) => boolean;
|
|
374
|
+
declare function isUseEffectCallLoose(node: TSESTree.Node | unit): boolean;
|
|
364
375
|
declare const isUseCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
365
376
|
declare const isUseActionStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
366
377
|
declare const isUseCallbackCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
@@ -381,8 +392,7 @@ declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undef
|
|
|
381
392
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
382
393
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
383
394
|
|
|
384
|
-
|
|
385
|
-
|
|
395
|
+
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"];
|
|
386
396
|
/**
|
|
387
397
|
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
388
398
|
* character to exclude identifiers like "user".
|
|
@@ -399,7 +409,7 @@ declare function isReactHookName(name: string): boolean;
|
|
|
399
409
|
* @param initialScope The initial scope to use for variable resolution
|
|
400
410
|
* @returns The JSX attribute node or undefined
|
|
401
411
|
*/
|
|
402
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute |
|
|
412
|
+
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
403
413
|
|
|
404
414
|
/**
|
|
405
415
|
* Get the stringified name of a JSX attribute
|
|
@@ -442,7 +452,7 @@ declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
|
442
452
|
* @param node The AST node to check
|
|
443
453
|
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
444
454
|
*/
|
|
445
|
-
declare function isJsxText(node: TSESTree$1.Node | null |
|
|
455
|
+
declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
446
456
|
/**
|
|
447
457
|
* Heuristic decision to determine if a node is a JSX-like node.
|
|
448
458
|
* @param code The sourceCode object
|
|
@@ -453,7 +463,10 @@ declare function isJsxText(node: TSESTree$1.Node | null | _): node is TSESTree$1
|
|
|
453
463
|
*/
|
|
454
464
|
declare function isJsxLike(code: {
|
|
455
465
|
getScope: (node: TSESTree$1.Node) => Scope;
|
|
456
|
-
}, node: TSESTree$1.Node |
|
|
466
|
+
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
467
|
+
|
|
468
|
+
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
469
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node): node is TSESTree.JSXElement;
|
|
457
470
|
|
|
458
471
|
/**
|
|
459
472
|
* Get the stringified type of a JSX element
|
|
@@ -473,12 +486,7 @@ declare function hasEveryAttribute(context: RuleContext, names: string[], attrib
|
|
|
473
486
|
* @param test The test to apply to the parent attribute
|
|
474
487
|
* @returns The parent attribute node or undefined
|
|
475
488
|
*/
|
|
476
|
-
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute |
|
|
477
|
-
|
|
478
|
-
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
479
|
-
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
480
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
481
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
489
|
+
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
482
490
|
|
|
483
491
|
/**
|
|
484
492
|
* Get the stringified representation of a JSX node
|
|
@@ -487,15 +495,126 @@ declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | n
|
|
|
487
495
|
*/
|
|
488
496
|
declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
|
|
489
497
|
|
|
498
|
+
/** @internal */
|
|
499
|
+
declare const isAnyType: (type: ts.Type) => boolean;
|
|
500
|
+
/** @internal */
|
|
501
|
+
declare const isBigIntType: (type: ts.Type) => boolean;
|
|
502
|
+
/** @internal */
|
|
503
|
+
declare const isBooleanType: (type: ts.Type) => boolean;
|
|
504
|
+
/** @internal */
|
|
505
|
+
declare const isEnumType: (type: ts.Type) => boolean;
|
|
506
|
+
/** @internal */
|
|
507
|
+
declare const isFalsyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
508
|
+
freshType: ts.FreshableType;
|
|
509
|
+
regularType: ts.FreshableType;
|
|
510
|
+
flags: ts.TypeFlags;
|
|
511
|
+
symbol: ts.Symbol;
|
|
512
|
+
pattern?: ts.DestructuringPattern;
|
|
513
|
+
aliasSymbol?: ts.Symbol;
|
|
514
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
515
|
+
getFlags: () => ts.TypeFlags;
|
|
516
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
517
|
+
getProperties: () => ts.Symbol[];
|
|
518
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
519
|
+
getApparentProperties: () => ts.Symbol[];
|
|
520
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
521
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
522
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
523
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
524
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
525
|
+
getNonNullableType: () => ts.Type;
|
|
526
|
+
getConstraint: () => ts.Type | undefined;
|
|
527
|
+
getDefault: () => ts.Type | undefined;
|
|
528
|
+
isUnion: () => this is ts.UnionType;
|
|
529
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
530
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
531
|
+
isLiteral: () => this is ts.LiteralType;
|
|
532
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
533
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
534
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
535
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
536
|
+
isClass: () => this is ts.InterfaceType;
|
|
537
|
+
isIndexType: () => this is ts.IndexType;
|
|
538
|
+
value: {
|
|
539
|
+
negative: boolean;
|
|
540
|
+
base10Value: "0";
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
/** @internal */
|
|
544
|
+
declare const isFalsyNumberType: (type: ts.Type) => boolean;
|
|
545
|
+
/** @internal */
|
|
546
|
+
declare const isFalsyStringType: (type: ts.Type) => boolean;
|
|
547
|
+
/** @internal */
|
|
548
|
+
declare const isNeverType: (type: ts.Type) => boolean;
|
|
549
|
+
/** @internal */
|
|
550
|
+
declare const isNullishType: (type: ts.Type) => boolean;
|
|
551
|
+
/** @internal */
|
|
552
|
+
declare const isNumberType: (type: ts.Type) => boolean;
|
|
553
|
+
/** @internal */
|
|
554
|
+
declare const isObjectType: (type: ts.Type) => boolean;
|
|
555
|
+
/** @internal */
|
|
556
|
+
declare const isStringType: (type: ts.Type) => boolean;
|
|
557
|
+
/** @internal */
|
|
558
|
+
declare const isTruthyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
559
|
+
freshType: ts.FreshableType;
|
|
560
|
+
regularType: ts.FreshableType;
|
|
561
|
+
flags: ts.TypeFlags;
|
|
562
|
+
symbol: ts.Symbol;
|
|
563
|
+
pattern?: ts.DestructuringPattern;
|
|
564
|
+
aliasSymbol?: ts.Symbol;
|
|
565
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
566
|
+
getFlags: () => ts.TypeFlags;
|
|
567
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
568
|
+
getProperties: () => ts.Symbol[];
|
|
569
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
570
|
+
getApparentProperties: () => ts.Symbol[];
|
|
571
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
572
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
573
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
574
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
575
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
576
|
+
getNonNullableType: () => ts.Type;
|
|
577
|
+
getConstraint: () => ts.Type | undefined;
|
|
578
|
+
getDefault: () => ts.Type | undefined;
|
|
579
|
+
isUnion: () => this is ts.UnionType;
|
|
580
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
581
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
582
|
+
isLiteral: () => this is ts.LiteralType;
|
|
583
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
584
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
585
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
586
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
587
|
+
isClass: () => this is ts.InterfaceType;
|
|
588
|
+
isIndexType: () => this is ts.IndexType;
|
|
589
|
+
value: ts.PseudoBigInt;
|
|
590
|
+
};
|
|
591
|
+
/** @internal */
|
|
592
|
+
declare const isTruthyNumberType: (type: ts.Type) => boolean;
|
|
593
|
+
/** @internal */
|
|
594
|
+
declare const isTruthyStringType: (type: ts.Type) => boolean;
|
|
595
|
+
/** @internal */
|
|
596
|
+
declare const isUnknownType: (type: ts.Type) => boolean;
|
|
597
|
+
|
|
598
|
+
type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" | "number" | "object" | "string" | "unknown" | "falsy bigint" | "falsy boolean" | "falsy number" | "falsy string" | "truthy bigint" | "truthy boolean" | "truthy number" | "truthy string";
|
|
599
|
+
/**
|
|
600
|
+
* Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
|
|
601
|
+
* Get the variants of an array of types.
|
|
602
|
+
* @param types The types to get the variants of
|
|
603
|
+
* @returns The variants of the types
|
|
604
|
+
* @internal
|
|
605
|
+
*/
|
|
606
|
+
declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|
|
607
|
+
|
|
490
608
|
/** @internal */
|
|
491
609
|
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.BinaryExpression | 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.UnaryExpression | TSESTree.UpdateExpression | TSESTree.YieldExpression | undefined;
|
|
492
610
|
|
|
493
611
|
/**
|
|
494
|
-
* Check if an identifier is initialized from react
|
|
612
|
+
* Check if an identifier name is initialized from react
|
|
495
613
|
* @param name The top-level identifier's name
|
|
496
614
|
* @param importSource The import source to check against
|
|
497
615
|
* @param initialScope Initial scope to search for the identifier
|
|
498
|
-
* @returns Whether the identifier is initialized from react
|
|
616
|
+
* @returns Whether the identifier name is initialized from react
|
|
617
|
+
* @internal
|
|
499
618
|
*/
|
|
500
619
|
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
501
620
|
|
|
@@ -504,15 +623,15 @@ declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TS
|
|
|
504
623
|
|
|
505
624
|
declare namespace isReactAPI {
|
|
506
625
|
type ReturnType = {
|
|
507
|
-
(context: RuleContext, node:
|
|
508
|
-
(context: RuleContext): (node:
|
|
626
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
627
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
509
628
|
};
|
|
510
629
|
}
|
|
511
630
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
512
631
|
declare namespace isReactAPICall {
|
|
513
632
|
type ReturnType = {
|
|
514
|
-
(context: RuleContext, node:
|
|
515
|
-
(context: RuleContext): (node:
|
|
633
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
634
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
516
635
|
};
|
|
517
636
|
}
|
|
518
637
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
@@ -543,4 +662,4 @@ declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
|
543
662
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
544
663
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
545
664
|
|
|
546
|
-
export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, type EffectKind, type FunctionComponent, type Hook,
|
|
665
|
+
export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, type EffectKind, type FunctionComponent, type Hook, JSXDetectionHint, REACT_BUILTIN_HOOK_NAMES, type SemanticEntry, type SemanticNode, type TypeVariant, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, getTypeVariants, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isEnumType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInViMockCallback, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isStringType, isThisSetState, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
2
|
import * as AST14 from '@eslint-react/ast';
|
|
3
|
-
import { flip, dual, constFalse, identity, constTrue,
|
|
3
|
+
import { flip, dual, constFalse, identity, constTrue, unit } from '@eslint-react/eff';
|
|
4
4
|
import { RegExp, Selector } from '@eslint-react/kit';
|
|
5
5
|
import { coerceSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
|
|
6
6
|
import * as VAR3 from '@eslint-react/var';
|
|
7
7
|
import { isMatching, P, match } from 'ts-pattern';
|
|
8
8
|
import birecord from 'birecord';
|
|
9
|
+
import { isTypeFlagSet, isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
|
|
10
|
+
export { isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
|
|
11
|
+
import ts from 'typescript';
|
|
9
12
|
|
|
10
13
|
// src/component/component-children.ts
|
|
11
14
|
function isReactAPI(api) {
|
|
@@ -70,7 +73,7 @@ function getInstanceId(node, prev) {
|
|
|
70
73
|
case (node.type === AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
71
74
|
return node.key;
|
|
72
75
|
case (node.type === AST_NODE_TYPES.BlockStatement || node.type === AST_NODE_TYPES.Program || node.parent === node):
|
|
73
|
-
return
|
|
76
|
+
return unit;
|
|
74
77
|
default:
|
|
75
78
|
return getInstanceId(node.parent, node);
|
|
76
79
|
}
|
|
@@ -108,6 +111,27 @@ function isInstanceIdEqual(context, a, b) {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
// src/hook/hook-name.ts
|
|
114
|
+
var REACT_BUILTIN_HOOK_NAMES = [
|
|
115
|
+
"use",
|
|
116
|
+
"useActionState",
|
|
117
|
+
"useCallback",
|
|
118
|
+
"useContext",
|
|
119
|
+
"useDebugValue",
|
|
120
|
+
"useDeferredValue",
|
|
121
|
+
"useEffect",
|
|
122
|
+
"useFormStatus",
|
|
123
|
+
"useId",
|
|
124
|
+
"useImperativeHandle",
|
|
125
|
+
"useInsertionEffect",
|
|
126
|
+
"useLayoutEffect",
|
|
127
|
+
"useMemo",
|
|
128
|
+
"useOptimistic",
|
|
129
|
+
"useReducer",
|
|
130
|
+
"useRef",
|
|
131
|
+
"useState",
|
|
132
|
+
"useSyncExternalStore",
|
|
133
|
+
"useTransition"
|
|
134
|
+
];
|
|
111
135
|
function isReactHookName(name) {
|
|
112
136
|
return name === "use" || /^use[A-Z0-9]/.test(name);
|
|
113
137
|
}
|
|
@@ -411,6 +435,9 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
411
435
|
return !(hint & JSXDetectionHint.SkipStringLiteral);
|
|
412
436
|
}
|
|
413
437
|
case AST_NODE_TYPES.ArrayExpression: {
|
|
438
|
+
if (node.elements.length === 0) {
|
|
439
|
+
return !(hint & JSXDetectionHint.SkipEmptyArray);
|
|
440
|
+
}
|
|
414
441
|
if (hint & JSXDetectionHint.StrictArray) {
|
|
415
442
|
return node.elements.every((n) => isJsxLike(code, n, hint));
|
|
416
443
|
}
|
|
@@ -480,6 +507,15 @@ function getElementType(context, node) {
|
|
|
480
507
|
return stringifyJsx(node.openingElement.name);
|
|
481
508
|
}
|
|
482
509
|
|
|
510
|
+
// src/jsx/jsx-element-is.ts
|
|
511
|
+
function isHostElement(context, node) {
|
|
512
|
+
return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
|
|
513
|
+
}
|
|
514
|
+
function isFragmentElement(context, node) {
|
|
515
|
+
if (node.type !== AST_NODE_TYPES.JSXElement) return false;
|
|
516
|
+
return getElementType(context, node).split(".").at(-1) === "Fragment";
|
|
517
|
+
}
|
|
518
|
+
|
|
483
519
|
// src/jsx/jsx-has.ts
|
|
484
520
|
function hasAttribute(context, name, attributes, initialScope) {
|
|
485
521
|
return getAttribute(context, name, attributes, initialScope) != null;
|
|
@@ -496,18 +532,6 @@ function findParentAttribute(node, test = constTrue) {
|
|
|
496
532
|
};
|
|
497
533
|
return AST14.findParentNode(node, guard);
|
|
498
534
|
}
|
|
499
|
-
function isHostElement(context, node) {
|
|
500
|
-
return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
|
|
501
|
-
}
|
|
502
|
-
function isKeyedElement(context, node, initialScope) {
|
|
503
|
-
return node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
|
|
504
|
-
}
|
|
505
|
-
function isFragmentElement(context, node, allowJSXFragment = false) {
|
|
506
|
-
if (node == null) return false;
|
|
507
|
-
if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
|
|
508
|
-
if (node.type === AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
|
|
509
|
-
return getElementType(context, node).split(".").at(-1) === "Fragment";
|
|
510
|
-
}
|
|
511
535
|
|
|
512
536
|
// src/component/component-detection-hint.ts
|
|
513
537
|
var ComponentDetectionHint = {
|
|
@@ -643,7 +667,7 @@ function getFunctionComponentId(context, node) {
|
|
|
643
667
|
if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
644
668
|
return parent.parent.parent.id;
|
|
645
669
|
}
|
|
646
|
-
return
|
|
670
|
+
return unit;
|
|
647
671
|
}
|
|
648
672
|
|
|
649
673
|
// src/component/component-flag.ts
|
|
@@ -674,7 +698,7 @@ function isComponentNameLoose(name) {
|
|
|
674
698
|
return RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
675
699
|
}
|
|
676
700
|
function getComponentNameFromId(id) {
|
|
677
|
-
if (id == null) return
|
|
701
|
+
if (id == null) return unit;
|
|
678
702
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
679
703
|
}
|
|
680
704
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -702,11 +726,15 @@ function useComponentCollector(context, options = {}) {
|
|
|
702
726
|
const entry = functionEntries.at(-1);
|
|
703
727
|
if (entry == null) return;
|
|
704
728
|
if (!entry.isComponent) return functionEntries.pop();
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
729
|
+
const rets = AST14.getNestedReturnStatements(entry.node.body);
|
|
730
|
+
for (let i = rets.length - 1; i >= 0; i--) {
|
|
731
|
+
const ret = rets[i];
|
|
732
|
+
if (ret == null) continue;
|
|
733
|
+
const shouldDrop = context.sourceCode.getScope(ret).block === entry.node && ret.argument != null && !isJsxLike(context.sourceCode, ret.argument, hint);
|
|
734
|
+
if (shouldDrop) {
|
|
735
|
+
components.delete(entry.key);
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
710
738
|
}
|
|
711
739
|
return functionEntries.pop();
|
|
712
740
|
};
|
|
@@ -739,7 +767,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
739
767
|
kind: "function",
|
|
740
768
|
name,
|
|
741
769
|
node: entry.node,
|
|
742
|
-
displayName:
|
|
770
|
+
displayName: unit,
|
|
743
771
|
flag: getComponentFlagFromInitPath(initPath),
|
|
744
772
|
hint,
|
|
745
773
|
hookCalls: entry.hookCalls,
|
|
@@ -750,7 +778,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
750
778
|
[Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
751
779
|
const { left, right } = node;
|
|
752
780
|
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
753
|
-
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name :
|
|
781
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : unit;
|
|
754
782
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
755
783
|
if (component == null) return;
|
|
756
784
|
component.displayName = right;
|
|
@@ -779,7 +807,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
779
807
|
kind: "function",
|
|
780
808
|
name,
|
|
781
809
|
node: entry.node,
|
|
782
|
-
displayName:
|
|
810
|
+
displayName: unit,
|
|
783
811
|
flag: getComponentFlagFromInitPath(initPath),
|
|
784
812
|
hint,
|
|
785
813
|
hookCalls: entry.hookCalls,
|
|
@@ -813,7 +841,7 @@ function useComponentCollectorLegacy() {
|
|
|
813
841
|
name: id?.name,
|
|
814
842
|
node,
|
|
815
843
|
// TODO: Get displayName of class component
|
|
816
|
-
displayName:
|
|
844
|
+
displayName: unit,
|
|
817
845
|
flag,
|
|
818
846
|
hint: 0n,
|
|
819
847
|
// TODO: Get methods of class component
|
|
@@ -933,5 +961,80 @@ function isAssignmentToThisState(node) {
|
|
|
933
961
|
const { left } = node;
|
|
934
962
|
return left.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(left.object) && AST14.getPropertyName(left.property) === "state";
|
|
935
963
|
}
|
|
964
|
+
function isInViMockCallback(context, node) {
|
|
965
|
+
const found = AST14.findParentNode(node, (n) => {
|
|
966
|
+
if (!AST14.isFunction(n)) return false;
|
|
967
|
+
return n.parent.type === AST_NODE_TYPES.CallExpression && n.parent.callee.type === AST_NODE_TYPES.MemberExpression && n.parent.callee.object.type === AST_NODE_TYPES.Identifier && n.parent.callee.object.name === "vi" && n.parent.callee.property.type === AST_NODE_TYPES.Identifier && n.parent.callee.property.name === "mock" && n.parent.arguments[1] === n;
|
|
968
|
+
});
|
|
969
|
+
return found != null;
|
|
970
|
+
}
|
|
971
|
+
var isAnyType = (type) => isTypeFlagSet(type, ts.TypeFlags.TypeParameter | ts.TypeFlags.Any);
|
|
972
|
+
var isBigIntType = (type) => isTypeFlagSet(type, ts.TypeFlags.BigIntLike);
|
|
973
|
+
var isBooleanType = (type) => isTypeFlagSet(type, ts.TypeFlags.BooleanLike);
|
|
974
|
+
var isEnumType = (type) => isTypeFlagSet(type, ts.TypeFlags.EnumLike);
|
|
975
|
+
var isFalsyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: "0" } }, type);
|
|
976
|
+
var isFalsyNumberType = (type) => type.isNumberLiteral() && type.value === 0;
|
|
977
|
+
var isFalsyStringType = (type) => type.isStringLiteral() && type.value === "";
|
|
978
|
+
var isNeverType = (type) => isTypeFlagSet(type, ts.TypeFlags.Never);
|
|
979
|
+
var isNullishType = (type) => isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike);
|
|
980
|
+
var isNumberType = (type) => isTypeFlagSet(type, ts.TypeFlags.NumberLike);
|
|
981
|
+
var isObjectType = (type) => !isTypeFlagSet(
|
|
982
|
+
type,
|
|
983
|
+
ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike | ts.TypeFlags.BooleanLike | ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike | ts.TypeFlags.TypeParameter | ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never
|
|
984
|
+
);
|
|
985
|
+
var isStringType = (type) => isTypeFlagSet(type, ts.TypeFlags.StringLike);
|
|
986
|
+
var isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: P.not("0") } }, type);
|
|
987
|
+
var isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
|
|
988
|
+
var isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
|
|
989
|
+
var isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
|
|
990
|
+
function getTypeVariants(types) {
|
|
991
|
+
const variants = /* @__PURE__ */ new Set();
|
|
992
|
+
if (types.some(isUnknownType)) {
|
|
993
|
+
variants.add("unknown");
|
|
994
|
+
return variants;
|
|
995
|
+
}
|
|
996
|
+
if (types.some(isNullishType)) {
|
|
997
|
+
variants.add("nullish");
|
|
998
|
+
}
|
|
999
|
+
const booleans = types.filter(isBooleanType);
|
|
1000
|
+
const boolean0 = booleans[0];
|
|
1001
|
+
if (booleans.length === 1 && boolean0 != null) {
|
|
1002
|
+
if (isFalseLiteralType(boolean0)) {
|
|
1003
|
+
variants.add("falsy boolean");
|
|
1004
|
+
} else if (isTrueLiteralType(boolean0)) {
|
|
1005
|
+
variants.add("truthy boolean");
|
|
1006
|
+
}
|
|
1007
|
+
} else if (booleans.length === 2) {
|
|
1008
|
+
variants.add("boolean");
|
|
1009
|
+
}
|
|
1010
|
+
const strings = types.filter(isStringType);
|
|
1011
|
+
if (strings.length > 0) {
|
|
1012
|
+
const evaluated = match(strings).when((types2) => types2.every(isTruthyStringType), () => "truthy string").when((types2) => types2.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
|
|
1013
|
+
variants.add(evaluated);
|
|
1014
|
+
}
|
|
1015
|
+
const bigints = types.filter(isBigIntType);
|
|
1016
|
+
if (bigints.length > 0) {
|
|
1017
|
+
const evaluated = match(bigints).when((types2) => types2.every(isTruthyBigIntType), () => "truthy bigint").when((types2) => types2.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
|
|
1018
|
+
variants.add(evaluated);
|
|
1019
|
+
}
|
|
1020
|
+
const numbers = types.filter(isNumberType);
|
|
1021
|
+
if (numbers.length > 0) {
|
|
1022
|
+
const evaluated = match(numbers).when((types2) => types2.every(isTruthyNumberType), () => "truthy number").when((types2) => types2.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
|
|
1023
|
+
variants.add(evaluated);
|
|
1024
|
+
}
|
|
1025
|
+
if (types.some(isEnumType)) {
|
|
1026
|
+
variants.add("enum");
|
|
1027
|
+
}
|
|
1028
|
+
if (types.some(isObjectType)) {
|
|
1029
|
+
variants.add("object");
|
|
1030
|
+
}
|
|
1031
|
+
if (types.some(isAnyType)) {
|
|
1032
|
+
variants.add("any");
|
|
1033
|
+
}
|
|
1034
|
+
if (types.some(isNeverType)) {
|
|
1035
|
+
variants.add("never");
|
|
1036
|
+
}
|
|
1037
|
+
return variants;
|
|
1038
|
+
}
|
|
936
1039
|
|
|
937
|
-
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText,
|
|
1040
|
+
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, REACT_BUILTIN_HOOK_NAMES, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, getTypeVariants, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isEnumType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInViMockCallback, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isStringType, isThisSetState, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.140",
|
|
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": {
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"./package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
31
|
-
"@typescript-eslint/type-utils": "^8.
|
|
32
|
-
"@typescript-eslint/types": "^8.
|
|
33
|
-
"@typescript-eslint/utils": "^8.
|
|
30
|
+
"@typescript-eslint/scope-manager": "^8.40.0",
|
|
31
|
+
"@typescript-eslint/type-utils": "^8.40.0",
|
|
32
|
+
"@typescript-eslint/types": "^8.40.0",
|
|
33
|
+
"@typescript-eslint/utils": "^8.40.0",
|
|
34
34
|
"birecord": "^0.1.1",
|
|
35
|
-
"ts-
|
|
36
|
-
"
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
35
|
+
"ts-api-utils": "^2.1.0",
|
|
36
|
+
"ts-pattern": "^5.8.0",
|
|
37
|
+
"@eslint-react/ast": "2.0.0-next.140",
|
|
38
|
+
"@eslint-react/eff": "2.0.0-next.140",
|
|
39
|
+
"@eslint-react/kit": "2.0.0-next.140",
|
|
40
|
+
"@eslint-react/shared": "2.0.0-next.140",
|
|
41
|
+
"@eslint-react/var": "2.0.0-next.140"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"tsup": "^8.
|
|
44
|
+
"tsup": "^8.5.0",
|
|
44
45
|
"@local/configs": "0.0.0"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
|
-
"bun": ">=1.0.15",
|
|
48
48
|
"node": ">=20.19.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|