@eslint-react/core 1.17.2-next.6 → 1.17.2
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 +80 -79
- package/dist/index.d.ts +80 -79
- package/dist/index.js +5 -7
- package/dist/index.mjs +5 -7
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,9 @@ import * as _eslint_react_types from '@eslint-react/types';
|
|
|
5
5
|
import { RuleContext } from '@eslint-react/types';
|
|
6
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
7
7
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
8
|
+
import * as birecord from 'birecord';
|
|
8
9
|
import { ESLintReactSettings } from '@eslint-react/shared';
|
|
9
10
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
10
|
-
import * as birecord from 'birecord';
|
|
11
11
|
import { SyntaxKind } from 'typescript';
|
|
12
12
|
|
|
13
13
|
interface ERSemanticNode {
|
|
@@ -229,6 +229,80 @@ declare const isUseStateCall: (node: TSESTree.CallExpression, context: Readonly<
|
|
|
229
229
|
declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
230
230
|
declare const isUseTransitionCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
231
231
|
|
|
232
|
+
declare const ERPhaseRelevance: birecord.BiRecord<{
|
|
233
|
+
readonly mount: "unmount";
|
|
234
|
+
readonly setup: "cleanup";
|
|
235
|
+
}>;
|
|
236
|
+
|
|
237
|
+
type EREffectPhaseKind = "cleanup" | "setup";
|
|
238
|
+
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
239
|
+
type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
|
|
240
|
+
|
|
241
|
+
declare const isInversePhase: {
|
|
242
|
+
(a: ERPhaseKind): (b: ERPhaseKind) => boolean;
|
|
243
|
+
(a: ERPhaseKind, b: ERPhaseKind): boolean;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Unsafe check whether given node is declared directly inside a render property
|
|
248
|
+
* ```jsx
|
|
249
|
+
* const rows = { render: () => <div /> }
|
|
250
|
+
* ` ^^^^^^^^^^^^^ `
|
|
251
|
+
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
252
|
+
* ` ^^^^^^^^^^^^^ `
|
|
253
|
+
* ```
|
|
254
|
+
* @internal
|
|
255
|
+
* @param node The AST node to check
|
|
256
|
+
* @returns `true` if component is declared inside a render property, `false` if not
|
|
257
|
+
*/
|
|
258
|
+
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Unsafe check whether given node is declared inside a render prop
|
|
261
|
+
* ```jsx
|
|
262
|
+
* _ = <Component renderRow={"node"} />
|
|
263
|
+
* ` ^^^^^^ `
|
|
264
|
+
* _ = <Component rows={ [{ render: "node" }] } />
|
|
265
|
+
* ` ^^^^^^ `
|
|
266
|
+
* ```
|
|
267
|
+
* @param node The AST node to check
|
|
268
|
+
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
269
|
+
*/
|
|
270
|
+
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Unsafe check whether given node is a render function
|
|
274
|
+
* ```jsx
|
|
275
|
+
* const renderRow = () => <div />
|
|
276
|
+
* ` ^^^^^^^^^^^^`
|
|
277
|
+
* _ = <Component renderRow={() => <div />} />
|
|
278
|
+
* ` ^^^^^^^^^^^^^ `
|
|
279
|
+
* ```
|
|
280
|
+
* @param node The AST node to check
|
|
281
|
+
* @param context The rule context
|
|
282
|
+
* @returns `true` if node is a render function, `false` if not
|
|
283
|
+
*/
|
|
284
|
+
declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Unsafe check whether given JSXAttribute is a render prop
|
|
287
|
+
* ```jsx
|
|
288
|
+
* _ = <Component renderRow={() => <div />} />
|
|
289
|
+
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
290
|
+
* ```
|
|
291
|
+
* @param node The AST node to check
|
|
292
|
+
* @param context The rule context
|
|
293
|
+
* @returns `true` if node is a render prop, `false` if not
|
|
294
|
+
*/
|
|
295
|
+
declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
|
|
296
|
+
|
|
297
|
+
interface ERSemanticEntry {
|
|
298
|
+
node: TSESTree.Node;
|
|
299
|
+
phase: ERPhaseKind;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
303
|
+
|
|
304
|
+
type ERStateKind = "actionState" | "state";
|
|
305
|
+
|
|
232
306
|
/**
|
|
233
307
|
* Checks if the given node is a call expression to the given function or method of the pragma
|
|
234
308
|
* @param name The name of the function or method to check
|
|
@@ -254,23 +328,6 @@ declare function isCallFromReactMember(pragmaMemberName: string, name: string):
|
|
|
254
328
|
*/
|
|
255
329
|
declare function isInitializedFromReact(name: string, initialScope: Scope, settings: ESLintReactSettings): boolean;
|
|
256
330
|
|
|
257
|
-
declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact>;
|
|
258
|
-
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
259
|
-
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
260
|
-
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
261
|
-
|
|
262
|
-
type EREffectPhaseKind = "cleanup" | "setup";
|
|
263
|
-
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
264
|
-
type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
|
|
265
|
-
declare const PHASE_RELEVANCE: birecord.BiRecord<{
|
|
266
|
-
readonly mount: "unmount";
|
|
267
|
-
readonly setup: "cleanup";
|
|
268
|
-
}>;
|
|
269
|
-
declare const isInversePhase: {
|
|
270
|
-
(a: ERPhaseKind): (b: ERPhaseKind) => boolean;
|
|
271
|
-
(a: ERPhaseKind, b: ERPhaseKind): boolean;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
331
|
/**********************************************
|
|
275
332
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
|
276
333
|
* *
|
|
@@ -2289,6 +2346,10 @@ declare interface YieldExpression extends BaseNode {
|
|
|
2289
2346
|
delegate: boolean;
|
|
2290
2347
|
}
|
|
2291
2348
|
|
|
2349
|
+
declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact>;
|
|
2350
|
+
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
2351
|
+
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
2352
|
+
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
2292
2353
|
declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2293
2354
|
declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2294
2355
|
declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
@@ -2312,64 +2373,4 @@ declare const isCreateRefCall: (node: CallExpression, context: _eslint_react_typ
|
|
|
2312
2373
|
declare const isForwardRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2313
2374
|
declare const isMemoCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2314
2375
|
|
|
2315
|
-
|
|
2316
|
-
* Unsafe check whether given node is declared directly inside a render property
|
|
2317
|
-
* ```jsx
|
|
2318
|
-
* const rows = { render: () => <div /> }
|
|
2319
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2320
|
-
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
2321
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2322
|
-
* ```
|
|
2323
|
-
* @internal
|
|
2324
|
-
* @param node The AST node to check
|
|
2325
|
-
* @returns `true` if component is declared inside a render property, `false` if not
|
|
2326
|
-
*/
|
|
2327
|
-
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
2328
|
-
/**
|
|
2329
|
-
* Unsafe check whether given node is declared inside a render prop
|
|
2330
|
-
* ```jsx
|
|
2331
|
-
* _ = <Component renderRow={"node"} />
|
|
2332
|
-
* ` ^^^^^^ `
|
|
2333
|
-
* _ = <Component rows={ [{ render: "node" }] } />
|
|
2334
|
-
* ` ^^^^^^ `
|
|
2335
|
-
* ```
|
|
2336
|
-
* @param node The AST node to check
|
|
2337
|
-
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
2338
|
-
*/
|
|
2339
|
-
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
2340
|
-
|
|
2341
|
-
/**
|
|
2342
|
-
* Unsafe check whether given node is a render function
|
|
2343
|
-
* ```jsx
|
|
2344
|
-
* const renderRow = () => <div />
|
|
2345
|
-
* ` ^^^^^^^^^^^^`
|
|
2346
|
-
* _ = <Component renderRow={() => <div />} />
|
|
2347
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2348
|
-
* ```
|
|
2349
|
-
* @param node The AST node to check
|
|
2350
|
-
* @param context The rule context
|
|
2351
|
-
* @returns `true` if node is a render function, `false` if not
|
|
2352
|
-
*/
|
|
2353
|
-
declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
|
|
2354
|
-
/**
|
|
2355
|
-
* Unsafe check whether given JSXAttribute is a render prop
|
|
2356
|
-
* ```jsx
|
|
2357
|
-
* _ = <Component renderRow={() => <div />} />
|
|
2358
|
-
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
2359
|
-
* ```
|
|
2360
|
-
* @param node The AST node to check
|
|
2361
|
-
* @param context The rule context
|
|
2362
|
-
* @returns `true` if node is a render prop, `false` if not
|
|
2363
|
-
*/
|
|
2364
|
-
declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
|
|
2365
|
-
|
|
2366
|
-
interface ERSemanticEntry {
|
|
2367
|
-
node: TSESTree.Node;
|
|
2368
|
-
phase: ERPhaseKind;
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
2372
|
-
|
|
2373
|
-
type ERStateKind = "actionState" | "state";
|
|
2374
|
-
|
|
2375
|
-
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, PHASE_RELEVANCE, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
|
2376
|
+
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import * as _eslint_react_types from '@eslint-react/types';
|
|
|
5
5
|
import { RuleContext } from '@eslint-react/types';
|
|
6
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
7
7
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
8
|
+
import * as birecord from 'birecord';
|
|
8
9
|
import { ESLintReactSettings } from '@eslint-react/shared';
|
|
9
10
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
10
|
-
import * as birecord from 'birecord';
|
|
11
11
|
import { SyntaxKind } from 'typescript';
|
|
12
12
|
|
|
13
13
|
interface ERSemanticNode {
|
|
@@ -229,6 +229,80 @@ declare const isUseStateCall: (node: TSESTree.CallExpression, context: Readonly<
|
|
|
229
229
|
declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
230
230
|
declare const isUseTransitionCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
231
231
|
|
|
232
|
+
declare const ERPhaseRelevance: birecord.BiRecord<{
|
|
233
|
+
readonly mount: "unmount";
|
|
234
|
+
readonly setup: "cleanup";
|
|
235
|
+
}>;
|
|
236
|
+
|
|
237
|
+
type EREffectPhaseKind = "cleanup" | "setup";
|
|
238
|
+
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
239
|
+
type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
|
|
240
|
+
|
|
241
|
+
declare const isInversePhase: {
|
|
242
|
+
(a: ERPhaseKind): (b: ERPhaseKind) => boolean;
|
|
243
|
+
(a: ERPhaseKind, b: ERPhaseKind): boolean;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Unsafe check whether given node is declared directly inside a render property
|
|
248
|
+
* ```jsx
|
|
249
|
+
* const rows = { render: () => <div /> }
|
|
250
|
+
* ` ^^^^^^^^^^^^^ `
|
|
251
|
+
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
252
|
+
* ` ^^^^^^^^^^^^^ `
|
|
253
|
+
* ```
|
|
254
|
+
* @internal
|
|
255
|
+
* @param node The AST node to check
|
|
256
|
+
* @returns `true` if component is declared inside a render property, `false` if not
|
|
257
|
+
*/
|
|
258
|
+
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Unsafe check whether given node is declared inside a render prop
|
|
261
|
+
* ```jsx
|
|
262
|
+
* _ = <Component renderRow={"node"} />
|
|
263
|
+
* ` ^^^^^^ `
|
|
264
|
+
* _ = <Component rows={ [{ render: "node" }] } />
|
|
265
|
+
* ` ^^^^^^ `
|
|
266
|
+
* ```
|
|
267
|
+
* @param node The AST node to check
|
|
268
|
+
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
269
|
+
*/
|
|
270
|
+
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Unsafe check whether given node is a render function
|
|
274
|
+
* ```jsx
|
|
275
|
+
* const renderRow = () => <div />
|
|
276
|
+
* ` ^^^^^^^^^^^^`
|
|
277
|
+
* _ = <Component renderRow={() => <div />} />
|
|
278
|
+
* ` ^^^^^^^^^^^^^ `
|
|
279
|
+
* ```
|
|
280
|
+
* @param node The AST node to check
|
|
281
|
+
* @param context The rule context
|
|
282
|
+
* @returns `true` if node is a render function, `false` if not
|
|
283
|
+
*/
|
|
284
|
+
declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Unsafe check whether given JSXAttribute is a render prop
|
|
287
|
+
* ```jsx
|
|
288
|
+
* _ = <Component renderRow={() => <div />} />
|
|
289
|
+
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
290
|
+
* ```
|
|
291
|
+
* @param node The AST node to check
|
|
292
|
+
* @param context The rule context
|
|
293
|
+
* @returns `true` if node is a render prop, `false` if not
|
|
294
|
+
*/
|
|
295
|
+
declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
|
|
296
|
+
|
|
297
|
+
interface ERSemanticEntry {
|
|
298
|
+
node: TSESTree.Node;
|
|
299
|
+
phase: ERPhaseKind;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
303
|
+
|
|
304
|
+
type ERStateKind = "actionState" | "state";
|
|
305
|
+
|
|
232
306
|
/**
|
|
233
307
|
* Checks if the given node is a call expression to the given function or method of the pragma
|
|
234
308
|
* @param name The name of the function or method to check
|
|
@@ -254,23 +328,6 @@ declare function isCallFromReactMember(pragmaMemberName: string, name: string):
|
|
|
254
328
|
*/
|
|
255
329
|
declare function isInitializedFromReact(name: string, initialScope: Scope, settings: ESLintReactSettings): boolean;
|
|
256
330
|
|
|
257
|
-
declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact>;
|
|
258
|
-
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
259
|
-
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
260
|
-
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
261
|
-
|
|
262
|
-
type EREffectPhaseKind = "cleanup" | "setup";
|
|
263
|
-
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
264
|
-
type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
|
|
265
|
-
declare const PHASE_RELEVANCE: birecord.BiRecord<{
|
|
266
|
-
readonly mount: "unmount";
|
|
267
|
-
readonly setup: "cleanup";
|
|
268
|
-
}>;
|
|
269
|
-
declare const isInversePhase: {
|
|
270
|
-
(a: ERPhaseKind): (b: ERPhaseKind) => boolean;
|
|
271
|
-
(a: ERPhaseKind, b: ERPhaseKind): boolean;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
331
|
/**********************************************
|
|
275
332
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
|
276
333
|
* *
|
|
@@ -2289,6 +2346,10 @@ declare interface YieldExpression extends BaseNode {
|
|
|
2289
2346
|
delegate: boolean;
|
|
2290
2347
|
}
|
|
2291
2348
|
|
|
2349
|
+
declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact>;
|
|
2350
|
+
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
2351
|
+
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
2352
|
+
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
2292
2353
|
declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2293
2354
|
declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2294
2355
|
declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
@@ -2312,64 +2373,4 @@ declare const isCreateRefCall: (node: CallExpression, context: _eslint_react_typ
|
|
|
2312
2373
|
declare const isForwardRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2313
2374
|
declare const isMemoCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2314
2375
|
|
|
2315
|
-
|
|
2316
|
-
* Unsafe check whether given node is declared directly inside a render property
|
|
2317
|
-
* ```jsx
|
|
2318
|
-
* const rows = { render: () => <div /> }
|
|
2319
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2320
|
-
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
2321
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2322
|
-
* ```
|
|
2323
|
-
* @internal
|
|
2324
|
-
* @param node The AST node to check
|
|
2325
|
-
* @returns `true` if component is declared inside a render property, `false` if not
|
|
2326
|
-
*/
|
|
2327
|
-
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
2328
|
-
/**
|
|
2329
|
-
* Unsafe check whether given node is declared inside a render prop
|
|
2330
|
-
* ```jsx
|
|
2331
|
-
* _ = <Component renderRow={"node"} />
|
|
2332
|
-
* ` ^^^^^^ `
|
|
2333
|
-
* _ = <Component rows={ [{ render: "node" }] } />
|
|
2334
|
-
* ` ^^^^^^ `
|
|
2335
|
-
* ```
|
|
2336
|
-
* @param node The AST node to check
|
|
2337
|
-
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
2338
|
-
*/
|
|
2339
|
-
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
2340
|
-
|
|
2341
|
-
/**
|
|
2342
|
-
* Unsafe check whether given node is a render function
|
|
2343
|
-
* ```jsx
|
|
2344
|
-
* const renderRow = () => <div />
|
|
2345
|
-
* ` ^^^^^^^^^^^^`
|
|
2346
|
-
* _ = <Component renderRow={() => <div />} />
|
|
2347
|
-
* ` ^^^^^^^^^^^^^ `
|
|
2348
|
-
* ```
|
|
2349
|
-
* @param node The AST node to check
|
|
2350
|
-
* @param context The rule context
|
|
2351
|
-
* @returns `true` if node is a render function, `false` if not
|
|
2352
|
-
*/
|
|
2353
|
-
declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
|
|
2354
|
-
/**
|
|
2355
|
-
* Unsafe check whether given JSXAttribute is a render prop
|
|
2356
|
-
* ```jsx
|
|
2357
|
-
* _ = <Component renderRow={() => <div />} />
|
|
2358
|
-
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
2359
|
-
* ```
|
|
2360
|
-
* @param node The AST node to check
|
|
2361
|
-
* @param context The rule context
|
|
2362
|
-
* @returns `true` if node is a render prop, `false` if not
|
|
2363
|
-
*/
|
|
2364
|
-
declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
|
|
2365
|
-
|
|
2366
|
-
interface ERSemanticEntry {
|
|
2367
|
-
node: TSESTree.Node;
|
|
2368
|
-
phase: ERPhaseKind;
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
2372
|
-
|
|
2373
|
-
type ERStateKind = "actionState" | "state";
|
|
2374
|
-
|
|
2375
|
-
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, PHASE_RELEVANCE, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
|
2376
|
+
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ function isInitializedFromReact(name, initialScope, settings) {
|
|
|
44
44
|
return VAR__namespace.isInitializedFromSource(name, importSource, initialScope);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/is-from-react.ts
|
|
47
|
+
// src/utils/is-from-react.ts
|
|
48
48
|
function isFromReact(name) {
|
|
49
49
|
return (node, context) => {
|
|
50
50
|
const settings = shared.unsafeReadSettings(context.settings);
|
|
@@ -83,15 +83,13 @@ function isCallFromReactMember(pragmaMemberName, name) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// src/is-react-api.ts
|
|
86
|
+
// src/utils/is-react-api.ts
|
|
87
87
|
function isReactAPIWithName(name, member) {
|
|
88
88
|
return member ? isFromReactMember(name, member) : isFromReact(name);
|
|
89
89
|
}
|
|
90
90
|
function isReactAPICallWithName(name, member) {
|
|
91
91
|
return member ? isCallFromReactMember(name, member) : isCallFromReact(name);
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
// src/react-api.ts
|
|
95
93
|
var isChildrenCount = isReactAPIWithName("Children", "count");
|
|
96
94
|
var isChildrenForEach = isReactAPIWithName("Children", "forEach");
|
|
97
95
|
var isChildrenMap = isReactAPIWithName("Children", "map");
|
|
@@ -629,11 +627,11 @@ function isCleanupFunction(node) {
|
|
|
629
627
|
if (!nearestFunction || !nearestFunctionOfRet) return false;
|
|
630
628
|
return nearestFunction === nearestFunctionOfRet && isSetupFunction(nearestFunction);
|
|
631
629
|
}
|
|
632
|
-
var
|
|
630
|
+
var ERPhaseRelevance = birecord__default.default({
|
|
633
631
|
mount: "unmount",
|
|
634
632
|
setup: "cleanup"
|
|
635
633
|
});
|
|
636
|
-
var isInversePhase = tools.F.dual(2, (a, b) =>
|
|
634
|
+
var isInversePhase = tools.F.dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
|
|
637
635
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
638
636
|
const matching = tsPattern.isMatching({
|
|
639
637
|
key: {
|
|
@@ -685,7 +683,7 @@ exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
|
|
|
685
683
|
exports.ERClassComponentFlag = ERClassComponentFlag;
|
|
686
684
|
exports.ERComponentHint = ERComponentHint;
|
|
687
685
|
exports.ERFunctionComponentFlag = ERFunctionComponentFlag;
|
|
688
|
-
exports.
|
|
686
|
+
exports.ERPhaseRelevance = ERPhaseRelevance;
|
|
689
687
|
exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
|
|
690
688
|
exports.RE_HOOK_NAME = RE_HOOK_NAME;
|
|
691
689
|
exports.getComponentNameFromIdentifier = getComponentNameFromIdentifier;
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ function isInitializedFromReact(name, initialScope, settings) {
|
|
|
16
16
|
return VAR.isInitializedFromSource(name, importSource, initialScope);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/is-from-react.ts
|
|
19
|
+
// src/utils/is-from-react.ts
|
|
20
20
|
function isFromReact(name) {
|
|
21
21
|
return (node, context) => {
|
|
22
22
|
const settings = unsafeReadSettings(context.settings);
|
|
@@ -55,15 +55,13 @@ function isCallFromReactMember(pragmaMemberName, name) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// src/is-react-api.ts
|
|
58
|
+
// src/utils/is-react-api.ts
|
|
59
59
|
function isReactAPIWithName(name, member) {
|
|
60
60
|
return member ? isFromReactMember(name, member) : isFromReact(name);
|
|
61
61
|
}
|
|
62
62
|
function isReactAPICallWithName(name, member) {
|
|
63
63
|
return member ? isCallFromReactMember(name, member) : isCallFromReact(name);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
// src/react-api.ts
|
|
67
65
|
var isChildrenCount = isReactAPIWithName("Children", "count");
|
|
68
66
|
var isChildrenForEach = isReactAPIWithName("Children", "forEach");
|
|
69
67
|
var isChildrenMap = isReactAPIWithName("Children", "map");
|
|
@@ -601,11 +599,11 @@ function isCleanupFunction(node) {
|
|
|
601
599
|
if (!nearestFunction || !nearestFunctionOfRet) return false;
|
|
602
600
|
return nearestFunction === nearestFunctionOfRet && isSetupFunction(nearestFunction);
|
|
603
601
|
}
|
|
604
|
-
var
|
|
602
|
+
var ERPhaseRelevance = birecord({
|
|
605
603
|
mount: "unmount",
|
|
606
604
|
setup: "cleanup"
|
|
607
605
|
});
|
|
608
|
-
var isInversePhase = F.dual(2, (a, b) =>
|
|
606
|
+
var isInversePhase = F.dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
|
|
609
607
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
610
608
|
const matching = isMatching({
|
|
611
609
|
key: {
|
|
@@ -653,4 +651,4 @@ function isThisSetState(node) {
|
|
|
653
651
|
return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
654
652
|
}
|
|
655
653
|
|
|
656
|
-
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag,
|
|
654
|
+
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideReactHookCall, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.17.2
|
|
3
|
+
"version": "1.17.2",
|
|
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": {
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"short-unique-id": "^5.2.0",
|
|
44
44
|
"ts-pattern": "^5.5.0",
|
|
45
|
-
"@eslint-react/ast": "1.17.2
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/types": "1.17.2
|
|
50
|
-
"@eslint-react/var": "1.17.2
|
|
45
|
+
"@eslint-react/ast": "1.17.2",
|
|
46
|
+
"@eslint-react/tools": "1.17.2",
|
|
47
|
+
"@eslint-react/jsx": "1.17.2",
|
|
48
|
+
"@eslint-react/shared": "1.17.2",
|
|
49
|
+
"@eslint-react/types": "1.17.2",
|
|
50
|
+
"@eslint-react/var": "1.17.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"tsup": "^8.3.5"
|