@eslint-react/core 1.52.3-beta.1 → 1.52.3-beta.10
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.mts +30 -30
- package/dist/index.d.ts +30 -30
- package/dist/index.js +7 -7
- package/dist/index.mjs +8 -8
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
2
|
import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
3
3
|
import * as AST from '@eslint-react/ast';
|
|
4
|
-
import {
|
|
4
|
+
import { unit } from '@eslint-react/eff';
|
|
5
5
|
import { RuleContext } from '@eslint-react/kit';
|
|
6
6
|
import * as birecord from 'birecord';
|
|
7
7
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
@@ -72,10 +72,10 @@ interface SemanticEntry {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
interface SemanticNode {
|
|
75
|
-
id:
|
|
75
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
76
76
|
key: string;
|
|
77
77
|
kind: string;
|
|
78
|
-
name:
|
|
78
|
+
name: unit | string;
|
|
79
79
|
node: TSESTree.Node;
|
|
80
80
|
flag: bigint;
|
|
81
81
|
hint: bigint;
|
|
@@ -92,23 +92,23 @@ declare const ComponentFlag: {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
interface FunctionComponent extends SemanticNode {
|
|
95
|
-
id:
|
|
95
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
96
96
|
kind: "function";
|
|
97
97
|
node: AST.TSESTreeFunction;
|
|
98
98
|
flag: ComponentFlag;
|
|
99
99
|
hint: ComponentDetectionHint;
|
|
100
|
-
initPath:
|
|
100
|
+
initPath: unit | AST.FunctionInitPath;
|
|
101
101
|
hookCalls: TSESTree.CallExpression[];
|
|
102
|
-
displayName:
|
|
102
|
+
displayName: unit | TSESTree.Expression;
|
|
103
103
|
}
|
|
104
104
|
interface ClassComponent extends SemanticNode {
|
|
105
|
-
id:
|
|
105
|
+
id: unit | TSESTree.Identifier;
|
|
106
106
|
kind: "class";
|
|
107
107
|
node: AST.TSESTreeClass;
|
|
108
108
|
flag: ComponentFlag;
|
|
109
109
|
hint: ComponentDetectionHint;
|
|
110
110
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
111
|
-
displayName:
|
|
111
|
+
displayName: unit | TSESTree.Expression;
|
|
112
112
|
}
|
|
113
113
|
type Component = ClassComponent | FunctionComponent;
|
|
114
114
|
|
|
@@ -128,7 +128,7 @@ declare namespace useComponentCollector {
|
|
|
128
128
|
ctx: {
|
|
129
129
|
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
130
130
|
getCurrentEntries: () => FunctionEntry[];
|
|
131
|
-
getCurrentEntry: () => FunctionEntry |
|
|
131
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
132
132
|
};
|
|
133
133
|
listeners: ESLintUtils.RuleListener;
|
|
134
134
|
};
|
|
@@ -196,7 +196,7 @@ declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
|
|
|
196
196
|
*/
|
|
197
197
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
198
198
|
|
|
199
|
-
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] |
|
|
199
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
200
200
|
|
|
201
201
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
202
202
|
|
|
@@ -235,7 +235,7 @@ declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TS
|
|
|
235
235
|
|
|
236
236
|
declare function isComponentName(name: string): boolean;
|
|
237
237
|
declare function isComponentNameLoose(name: string): boolean;
|
|
238
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] |
|
|
238
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
239
239
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
240
240
|
|
|
241
241
|
/**
|
|
@@ -350,7 +350,7 @@ declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTre
|
|
|
350
350
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
351
351
|
|
|
352
352
|
interface Hook extends SemanticNode {
|
|
353
|
-
id: TSESTree.Identifier |
|
|
353
|
+
id: TSESTree.Identifier | unit;
|
|
354
354
|
node: AST.TSESTreeFunction;
|
|
355
355
|
name: string;
|
|
356
356
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -366,20 +366,20 @@ declare namespace useHookCollector {
|
|
|
366
366
|
}
|
|
367
367
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
368
368
|
|
|
369
|
-
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node |
|
|
370
|
-
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node |
|
|
369
|
+
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit): boolean;
|
|
370
|
+
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boolean;
|
|
371
371
|
|
|
372
|
-
declare function isReactHook(node: AST.TSESTreeFunction |
|
|
372
|
+
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
373
373
|
/**
|
|
374
374
|
* Check if the given node is a React Hook call by its name.
|
|
375
375
|
* @param node The node to check.
|
|
376
376
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
377
377
|
*/
|
|
378
|
-
declare function isReactHookCall(node: TSESTree.Node |
|
|
379
|
-
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node |
|
|
380
|
-
declare function isReactHookCallWithNameLoose(node: TSESTree.Node |
|
|
381
|
-
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?:
|
|
382
|
-
declare function isUseEffectCallLoose(node: TSESTree.Node |
|
|
378
|
+
declare function isReactHookCall(node: TSESTree.Node | unit): boolean;
|
|
379
|
+
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | unit): (name: string) => boolean;
|
|
380
|
+
declare function isReactHookCallWithNameLoose(node: TSESTree.Node | unit): (name: string) => boolean;
|
|
381
|
+
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?: unit | string[]): (node: TSESTree.CallExpression) => boolean;
|
|
382
|
+
declare function isUseEffectCallLoose(node: TSESTree.Node | unit): boolean;
|
|
383
383
|
declare const isUseCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
384
384
|
declare const isUseActionStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
385
385
|
declare const isUseCallbackCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
@@ -418,7 +418,7 @@ declare function isReactHookName(name: string): boolean;
|
|
|
418
418
|
* @param initialScope The initial scope to use for variable resolution
|
|
419
419
|
* @returns The JSX attribute node or undefined
|
|
420
420
|
*/
|
|
421
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute |
|
|
421
|
+
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
422
422
|
|
|
423
423
|
/**
|
|
424
424
|
* Get the stringified name of a JSX attribute
|
|
@@ -461,7 +461,7 @@ declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
|
461
461
|
* @param node The AST node to check
|
|
462
462
|
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
463
463
|
*/
|
|
464
|
-
declare function isJsxText(node: TSESTree$1.Node | null |
|
|
464
|
+
declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
465
465
|
/**
|
|
466
466
|
* Heuristic decision to determine if a node is a JSX-like node.
|
|
467
467
|
* @param code The sourceCode object
|
|
@@ -472,7 +472,7 @@ declare function isJsxText(node: TSESTree$1.Node | null | _): node is TSESTree$1
|
|
|
472
472
|
*/
|
|
473
473
|
declare function isJsxLike(code: {
|
|
474
474
|
getScope: (node: TSESTree$1.Node) => Scope;
|
|
475
|
-
}, node: TSESTree$1.Node |
|
|
475
|
+
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
476
476
|
|
|
477
477
|
/**
|
|
478
478
|
* Get the stringified type of a JSX element
|
|
@@ -492,12 +492,12 @@ declare function hasEveryAttribute(context: RuleContext, names: string[], attrib
|
|
|
492
492
|
* @param test The test to apply to the parent attribute
|
|
493
493
|
* @returns The parent attribute node or undefined
|
|
494
494
|
*/
|
|
495
|
-
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute |
|
|
495
|
+
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
496
496
|
|
|
497
497
|
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
498
498
|
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
499
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null |
|
|
500
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null |
|
|
499
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
500
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
501
501
|
|
|
502
502
|
/**
|
|
503
503
|
* Get the stringified representation of a JSX node
|
|
@@ -523,15 +523,15 @@ declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TS
|
|
|
523
523
|
|
|
524
524
|
declare namespace isReactAPI {
|
|
525
525
|
type ReturnType = {
|
|
526
|
-
(context: RuleContext, node:
|
|
527
|
-
(context: RuleContext): (node:
|
|
526
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
527
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
530
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
531
531
|
declare namespace isReactAPICall {
|
|
532
532
|
type ReturnType = {
|
|
533
|
-
(context: RuleContext, node:
|
|
534
|
-
(context: RuleContext): (node:
|
|
533
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
534
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
2
|
import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
3
3
|
import * as AST from '@eslint-react/ast';
|
|
4
|
-
import {
|
|
4
|
+
import { unit } from '@eslint-react/eff';
|
|
5
5
|
import { RuleContext } from '@eslint-react/kit';
|
|
6
6
|
import * as birecord from 'birecord';
|
|
7
7
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
@@ -72,10 +72,10 @@ interface SemanticEntry {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
interface SemanticNode {
|
|
75
|
-
id:
|
|
75
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
76
76
|
key: string;
|
|
77
77
|
kind: string;
|
|
78
|
-
name:
|
|
78
|
+
name: unit | string;
|
|
79
79
|
node: TSESTree.Node;
|
|
80
80
|
flag: bigint;
|
|
81
81
|
hint: bigint;
|
|
@@ -92,23 +92,23 @@ declare const ComponentFlag: {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
interface FunctionComponent extends SemanticNode {
|
|
95
|
-
id:
|
|
95
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
96
96
|
kind: "function";
|
|
97
97
|
node: AST.TSESTreeFunction;
|
|
98
98
|
flag: ComponentFlag;
|
|
99
99
|
hint: ComponentDetectionHint;
|
|
100
|
-
initPath:
|
|
100
|
+
initPath: unit | AST.FunctionInitPath;
|
|
101
101
|
hookCalls: TSESTree.CallExpression[];
|
|
102
|
-
displayName:
|
|
102
|
+
displayName: unit | TSESTree.Expression;
|
|
103
103
|
}
|
|
104
104
|
interface ClassComponent extends SemanticNode {
|
|
105
|
-
id:
|
|
105
|
+
id: unit | TSESTree.Identifier;
|
|
106
106
|
kind: "class";
|
|
107
107
|
node: AST.TSESTreeClass;
|
|
108
108
|
flag: ComponentFlag;
|
|
109
109
|
hint: ComponentDetectionHint;
|
|
110
110
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
111
|
-
displayName:
|
|
111
|
+
displayName: unit | TSESTree.Expression;
|
|
112
112
|
}
|
|
113
113
|
type Component = ClassComponent | FunctionComponent;
|
|
114
114
|
|
|
@@ -128,7 +128,7 @@ declare namespace useComponentCollector {
|
|
|
128
128
|
ctx: {
|
|
129
129
|
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
130
130
|
getCurrentEntries: () => FunctionEntry[];
|
|
131
|
-
getCurrentEntry: () => FunctionEntry |
|
|
131
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
132
132
|
};
|
|
133
133
|
listeners: ESLintUtils.RuleListener;
|
|
134
134
|
};
|
|
@@ -196,7 +196,7 @@ declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
|
|
|
196
196
|
*/
|
|
197
197
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
198
198
|
|
|
199
|
-
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] |
|
|
199
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
200
200
|
|
|
201
201
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
202
202
|
|
|
@@ -235,7 +235,7 @@ declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TS
|
|
|
235
235
|
|
|
236
236
|
declare function isComponentName(name: string): boolean;
|
|
237
237
|
declare function isComponentNameLoose(name: string): boolean;
|
|
238
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] |
|
|
238
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
239
239
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
240
240
|
|
|
241
241
|
/**
|
|
@@ -350,7 +350,7 @@ declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTre
|
|
|
350
350
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
351
351
|
|
|
352
352
|
interface Hook extends SemanticNode {
|
|
353
|
-
id: TSESTree.Identifier |
|
|
353
|
+
id: TSESTree.Identifier | unit;
|
|
354
354
|
node: AST.TSESTreeFunction;
|
|
355
355
|
name: string;
|
|
356
356
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -366,20 +366,20 @@ declare namespace useHookCollector {
|
|
|
366
366
|
}
|
|
367
367
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
368
368
|
|
|
369
|
-
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node |
|
|
370
|
-
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node |
|
|
369
|
+
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit): boolean;
|
|
370
|
+
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boolean;
|
|
371
371
|
|
|
372
|
-
declare function isReactHook(node: AST.TSESTreeFunction |
|
|
372
|
+
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
373
373
|
/**
|
|
374
374
|
* Check if the given node is a React Hook call by its name.
|
|
375
375
|
* @param node The node to check.
|
|
376
376
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
377
377
|
*/
|
|
378
|
-
declare function isReactHookCall(node: TSESTree.Node |
|
|
379
|
-
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node |
|
|
380
|
-
declare function isReactHookCallWithNameLoose(node: TSESTree.Node |
|
|
381
|
-
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?:
|
|
382
|
-
declare function isUseEffectCallLoose(node: TSESTree.Node |
|
|
378
|
+
declare function isReactHookCall(node: TSESTree.Node | unit): boolean;
|
|
379
|
+
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | unit): (name: string) => boolean;
|
|
380
|
+
declare function isReactHookCallWithNameLoose(node: TSESTree.Node | unit): (name: string) => boolean;
|
|
381
|
+
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?: unit | string[]): (node: TSESTree.CallExpression) => boolean;
|
|
382
|
+
declare function isUseEffectCallLoose(node: TSESTree.Node | unit): boolean;
|
|
383
383
|
declare const isUseCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
384
384
|
declare const isUseActionStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
385
385
|
declare const isUseCallbackCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
@@ -418,7 +418,7 @@ declare function isReactHookName(name: string): boolean;
|
|
|
418
418
|
* @param initialScope The initial scope to use for variable resolution
|
|
419
419
|
* @returns The JSX attribute node or undefined
|
|
420
420
|
*/
|
|
421
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute |
|
|
421
|
+
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
422
422
|
|
|
423
423
|
/**
|
|
424
424
|
* Get the stringified name of a JSX attribute
|
|
@@ -461,7 +461,7 @@ declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
|
461
461
|
* @param node The AST node to check
|
|
462
462
|
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
463
463
|
*/
|
|
464
|
-
declare function isJsxText(node: TSESTree$1.Node | null |
|
|
464
|
+
declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
465
465
|
/**
|
|
466
466
|
* Heuristic decision to determine if a node is a JSX-like node.
|
|
467
467
|
* @param code The sourceCode object
|
|
@@ -472,7 +472,7 @@ declare function isJsxText(node: TSESTree$1.Node | null | _): node is TSESTree$1
|
|
|
472
472
|
*/
|
|
473
473
|
declare function isJsxLike(code: {
|
|
474
474
|
getScope: (node: TSESTree$1.Node) => Scope;
|
|
475
|
-
}, node: TSESTree$1.Node |
|
|
475
|
+
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
476
476
|
|
|
477
477
|
/**
|
|
478
478
|
* Get the stringified type of a JSX element
|
|
@@ -492,12 +492,12 @@ declare function hasEveryAttribute(context: RuleContext, names: string[], attrib
|
|
|
492
492
|
* @param test The test to apply to the parent attribute
|
|
493
493
|
* @returns The parent attribute node or undefined
|
|
494
494
|
*/
|
|
495
|
-
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute |
|
|
495
|
+
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
496
496
|
|
|
497
497
|
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
498
498
|
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
499
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null |
|
|
500
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null |
|
|
499
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
500
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
501
501
|
|
|
502
502
|
/**
|
|
503
503
|
* Get the stringified representation of a JSX node
|
|
@@ -523,15 +523,15 @@ declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TS
|
|
|
523
523
|
|
|
524
524
|
declare namespace isReactAPI {
|
|
525
525
|
type ReturnType = {
|
|
526
|
-
(context: RuleContext, node:
|
|
527
|
-
(context: RuleContext): (node:
|
|
526
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
527
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
530
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
531
531
|
declare namespace isReactAPICall {
|
|
532
532
|
type ReturnType = {
|
|
533
|
-
(context: RuleContext, node:
|
|
534
|
-
(context: RuleContext): (node:
|
|
533
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
534
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ function getInstanceId(node, prev) {
|
|
|
43
43
|
case (node.type === types.AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
44
44
|
return node.key;
|
|
45
45
|
case (node.type === types.AST_NODE_TYPES.BlockStatement || node.type === types.AST_NODE_TYPES.Program || node.parent === node):
|
|
46
|
-
return eff.
|
|
46
|
+
return eff.unit;
|
|
47
47
|
default:
|
|
48
48
|
return getInstanceId(node.parent, node);
|
|
49
49
|
}
|
|
@@ -743,7 +743,7 @@ function getFunctionComponentId(context, node) {
|
|
|
743
743
|
if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
|
|
744
744
|
return parent.parent.parent.id;
|
|
745
745
|
}
|
|
746
|
-
return eff.
|
|
746
|
+
return eff.unit;
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
// src/component/component-flag.ts
|
|
@@ -774,7 +774,7 @@ function isComponentNameLoose(name) {
|
|
|
774
774
|
return kit.RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
775
775
|
}
|
|
776
776
|
function getComponentNameFromId(id) {
|
|
777
|
-
if (id == null) return eff.
|
|
777
|
+
if (id == null) return eff.unit;
|
|
778
778
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
779
779
|
}
|
|
780
780
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -843,7 +843,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
843
843
|
kind: "function",
|
|
844
844
|
name,
|
|
845
845
|
node: entry.node,
|
|
846
|
-
displayName: eff.
|
|
846
|
+
displayName: eff.unit,
|
|
847
847
|
flag: getComponentFlagFromInitPath(initPath),
|
|
848
848
|
hint,
|
|
849
849
|
hookCalls: entry.hookCalls,
|
|
@@ -854,7 +854,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
854
854
|
[kit.Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
855
855
|
const { left, right } = node;
|
|
856
856
|
if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
|
|
857
|
-
const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff.
|
|
857
|
+
const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff.unit;
|
|
858
858
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
859
859
|
if (component == null) return;
|
|
860
860
|
component.displayName = right;
|
|
@@ -883,7 +883,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
883
883
|
kind: "function",
|
|
884
884
|
name,
|
|
885
885
|
node: entry.node,
|
|
886
|
-
displayName: eff.
|
|
886
|
+
displayName: eff.unit,
|
|
887
887
|
flag: getComponentFlagFromInitPath(initPath),
|
|
888
888
|
hint,
|
|
889
889
|
hookCalls: entry.hookCalls,
|
|
@@ -917,7 +917,7 @@ function useComponentCollectorLegacy() {
|
|
|
917
917
|
name: id?.name,
|
|
918
918
|
node,
|
|
919
919
|
// TODO: Get displayName of class component
|
|
920
|
-
displayName: eff.
|
|
920
|
+
displayName: eff.unit,
|
|
921
921
|
flag,
|
|
922
922
|
hint: 0n,
|
|
923
923
|
// TODO: Get methods of class component
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AST9 from '@eslint-react/ast';
|
|
2
|
-
import { flip, dual, constFalse, identity, constTrue,
|
|
2
|
+
import { flip, dual, constFalse, identity, constTrue, unit } from '@eslint-react/eff';
|
|
3
3
|
import { RegExp, Selector } from '@eslint-react/kit';
|
|
4
4
|
import { coerceSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
|
|
5
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
@@ -17,7 +17,7 @@ function getInstanceId(node, prev) {
|
|
|
17
17
|
case (node.type === AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
18
18
|
return node.key;
|
|
19
19
|
case (node.type === AST_NODE_TYPES.BlockStatement || node.type === AST_NODE_TYPES.Program || node.parent === node):
|
|
20
|
-
return
|
|
20
|
+
return unit;
|
|
21
21
|
default:
|
|
22
22
|
return getInstanceId(node.parent, node);
|
|
23
23
|
}
|
|
@@ -717,7 +717,7 @@ function getFunctionComponentId(context, node) {
|
|
|
717
717
|
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) {
|
|
718
718
|
return parent.parent.parent.id;
|
|
719
719
|
}
|
|
720
|
-
return
|
|
720
|
+
return unit;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
723
|
// src/component/component-flag.ts
|
|
@@ -748,7 +748,7 @@ function isComponentNameLoose(name) {
|
|
|
748
748
|
return RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
749
749
|
}
|
|
750
750
|
function getComponentNameFromId(id) {
|
|
751
|
-
if (id == null) return
|
|
751
|
+
if (id == null) return unit;
|
|
752
752
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
753
753
|
}
|
|
754
754
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -817,7 +817,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
817
817
|
kind: "function",
|
|
818
818
|
name,
|
|
819
819
|
node: entry.node,
|
|
820
|
-
displayName:
|
|
820
|
+
displayName: unit,
|
|
821
821
|
flag: getComponentFlagFromInitPath(initPath),
|
|
822
822
|
hint,
|
|
823
823
|
hookCalls: entry.hookCalls,
|
|
@@ -828,7 +828,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
828
828
|
[Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
829
829
|
const { left, right } = node;
|
|
830
830
|
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
831
|
-
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name :
|
|
831
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : unit;
|
|
832
832
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
833
833
|
if (component == null) return;
|
|
834
834
|
component.displayName = right;
|
|
@@ -857,7 +857,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
857
857
|
kind: "function",
|
|
858
858
|
name,
|
|
859
859
|
node: entry.node,
|
|
860
|
-
displayName:
|
|
860
|
+
displayName: unit,
|
|
861
861
|
flag: getComponentFlagFromInitPath(initPath),
|
|
862
862
|
hint,
|
|
863
863
|
hookCalls: entry.hookCalls,
|
|
@@ -891,7 +891,7 @@ function useComponentCollectorLegacy() {
|
|
|
891
891
|
name: id?.name,
|
|
892
892
|
node,
|
|
893
893
|
// TODO: Get displayName of class component
|
|
894
|
-
displayName:
|
|
894
|
+
displayName: unit,
|
|
895
895
|
flag,
|
|
896
896
|
hint: 0n,
|
|
897
897
|
// TODO: Get methods of class component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.52.3-beta.
|
|
3
|
+
"version": "1.52.3-beta.10",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/type-utils": "^8.
|
|
40
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.35.1",
|
|
39
|
+
"@typescript-eslint/type-utils": "^8.35.1",
|
|
40
|
+
"@typescript-eslint/types": "^8.35.1",
|
|
41
|
+
"@typescript-eslint/utils": "^8.35.1",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.7.1",
|
|
44
|
-
"@eslint-react/ast": "1.52.3-beta.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/shared": "1.52.3-beta.
|
|
48
|
-
"@eslint-react/var": "1.52.3-beta.
|
|
44
|
+
"@eslint-react/ast": "1.52.3-beta.10",
|
|
45
|
+
"@eslint-react/eff": "1.52.3-beta.10",
|
|
46
|
+
"@eslint-react/kit": "1.52.3-beta.10",
|
|
47
|
+
"@eslint-react/shared": "1.52.3-beta.10",
|
|
48
|
+
"@eslint-react/var": "1.52.3-beta.10"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.5.0",
|