@pobammer-ts/eslint-cease-nonsense-rules 0.4.1 → 0.4.3
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 +39 -3
- package/dist/index.js.map +1 -1
- package/dist/rules/enforce-ianitor-check-type.js +26 -26
- package/dist/rules/enforce-ianitor-check-type.js.map +1 -1
- package/dist/rules/no-shorthand-names.js +1 -1
- package/dist/rules/no-shorthand-names.js.map +1 -1
- package/dist/rules/require-react-component-keys.d.ts +14 -2
- package/dist/rules/require-react-component-keys.js +219 -15
- package/dist/rules/require-react-component-keys.js.map +1 -1
- package/dist/rules/use-exhaustive-dependencies.d.ts +96 -1
- package/dist/rules/use-exhaustive-dependencies.js +227 -120
- package/dist/rules/use-exhaustive-dependencies.js.map +1 -1
- package/dist/rules/use-hook-at-top-level.js +88 -90
- package/dist/rules/use-hook-at-top-level.js.map +1 -1
- package/dist/stricty +3303 -0
- package/package.json +5 -4
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
import type { Rule, Scope } from "eslint";
|
|
3
|
+
/**
|
|
4
|
+
* Stable result configuration.
|
|
5
|
+
*/
|
|
6
|
+
type StableResult = boolean | ReadonlySet<number> | ReadonlySet<string>;
|
|
7
|
+
declare function resetTestingMetrics(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Minimal definition information used for stability analysis.
|
|
10
|
+
*/
|
|
11
|
+
interface VariableDefinitionLike {
|
|
12
|
+
readonly node: TSESTree.Node | Rule.Node;
|
|
13
|
+
readonly type: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Minimal variable interface compatible with ESLint scope variables.
|
|
17
|
+
*/
|
|
18
|
+
interface VariableLike {
|
|
19
|
+
readonly defs: ReadonlyArray<VariableDefinitionLike>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Capture information from closure analysis.
|
|
23
|
+
*/
|
|
24
|
+
interface CaptureInfo {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly node: TSESTree.Node;
|
|
27
|
+
readonly usagePath: string;
|
|
28
|
+
readonly variable: VariableLike | undefined;
|
|
29
|
+
readonly depth: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a stable array index is being accessed.
|
|
33
|
+
*
|
|
34
|
+
* @param stableResult - The stable result set.
|
|
35
|
+
* @param node - The variable declarator node.
|
|
36
|
+
* @param identifierName - The identifier name being accessed.
|
|
37
|
+
* @returns True if accessing a stable array index.
|
|
38
|
+
*/
|
|
39
|
+
declare function isStableArrayIndex(stableResult: StableResult | undefined, node: Scope.Definition["node"], identifierName: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a value is stable (doesn't need to be in dependencies).
|
|
42
|
+
*
|
|
43
|
+
* @param variable - The variable to check.
|
|
44
|
+
* @param identifierName - The identifier name being accessed.
|
|
45
|
+
* @param stableHooks - Map of stable hooks.
|
|
46
|
+
* @returns True if the value is stable.
|
|
47
|
+
*/
|
|
48
|
+
declare function isStableValue(variable: VariableLike | undefined, identifierName: string, stableHooks: Map<string, StableResult>): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if an identifier is in a TypeScript type-only position.
|
|
51
|
+
* Type parameters and type annotations are compile-time only and should not be dependencies.
|
|
52
|
+
*
|
|
53
|
+
* @param identifier - The identifier node to check.
|
|
54
|
+
* @returns True if the identifier is in a type-only position.
|
|
55
|
+
*/
|
|
56
|
+
declare function isInTypePosition(identifier: TSESTree.Identifier): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if a variable is declared directly in the component/hook body OR is a prop (parameter).
|
|
59
|
+
* Per React rules, only variables "declared directly inside the component body" are reactive.
|
|
60
|
+
* This includes props (function parameters).
|
|
61
|
+
* Variables from outer scopes (module-level, parent functions) are non-reactive.
|
|
62
|
+
*
|
|
63
|
+
* @param variable - The variable to check.
|
|
64
|
+
* @param closureNode - The closure node (useEffect callback, etc.).
|
|
65
|
+
* @returns True if the variable is declared in the component body or is a prop.
|
|
66
|
+
*/
|
|
67
|
+
declare function isDeclaredInComponentBody(variable: VariableLike, closureNode: TSESTree.Node): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Collects all captured identifiers from a closure.
|
|
70
|
+
*
|
|
71
|
+
* @param node - The closure node (function/arrow function).
|
|
72
|
+
* @param scope - The scope of the closure.
|
|
73
|
+
* @param sourceCode - The source code instance.
|
|
74
|
+
* @returns Array of captured identifiers.
|
|
75
|
+
*/
|
|
76
|
+
declare function collectCaptures(node: TSESTree.Node, scope: Scope.Scope, sourceCode: Rule.RuleContext["sourceCode"]): ReadonlyArray<CaptureInfo>;
|
|
77
|
+
/**
|
|
78
|
+
* Converts stableResult configuration to internal format.
|
|
79
|
+
*
|
|
80
|
+
* @param stableResult - The stable result configuration.
|
|
81
|
+
* @returns The internal stable result format.
|
|
82
|
+
*/
|
|
83
|
+
declare function convertStableResult(stableResult: boolean | number | ReadonlyArray<number> | ReadonlyArray<string>): StableResult;
|
|
2
84
|
declare const useExhaustiveDependencies: Rule.RuleModule;
|
|
85
|
+
export declare const __testing: {
|
|
86
|
+
collectCaptures: typeof collectCaptures;
|
|
87
|
+
convertStableResult: typeof convertStableResult;
|
|
88
|
+
isDeclaredInComponentBody: typeof isDeclaredInComponentBody;
|
|
89
|
+
isInTypePosition: typeof isInTypePosition;
|
|
90
|
+
isStableArrayIndex: typeof isStableArrayIndex;
|
|
91
|
+
isStableValue: typeof isStableValue;
|
|
92
|
+
metrics: {
|
|
93
|
+
moduleLevelStableConst: number;
|
|
94
|
+
outerScopeSkip: number;
|
|
95
|
+
};
|
|
96
|
+
resetMetrics: typeof resetTestingMetrics;
|
|
97
|
+
};
|
|
3
98
|
export default useExhaustiveDependencies;
|