oxlint-plugin-react-doctor 0.9.3-dev.b02bc69 → 0.9.3-dev.f7dbdfa
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/core.d.ts +1045 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/react-native-dependency-names-DrsRME-d.d.ts +330 -0
- package/package.json +1 -1
- package/dist/core-NYcNjo1f.d.ts +0 -1371
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { StaticImport } from "oxc-parser";
|
|
2
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/utils/capability.d.ts
|
|
5
|
+
declare const FRAMEWORK_TOKENS: readonly ["nextjs", "astro", "vite", "cra", "remix", "gatsby", "expo", "react-native", "tanstack-start", "preact", "unknown"];
|
|
6
|
+
type FrameworkToken = (typeof FRAMEWORK_TOKENS)[number];
|
|
7
|
+
type Capability = FrameworkToken | "react" | "remotion" | "pure-preact" | "react-native" | "server-actions" | "ssr" | "client-only" | "expo:54" | "nextjs:static-export" | "nextjs:15" | "nextjs:16" | "tailwind" | "tailwind:3.4" | "tailwind:4" | "zod" | "zod:4" | "mobx" | "mobx-react" | "mobx-react-lite" | "mobx-react-binding" | "mobx-react-binding-observer-memo-guard" | "mobx-react-observer-memo-guard" | "mobx-react-lite-observer-memo-guard" | "mobx-state-tree" | "mobx-react-observer" | "zustand" | "typescript" | "react-compiler" | "reanimated" | "reanimated:4" | "tanstack-query" | "valtio" | "i18n" | "styled-components" | "styled-components:6" | "three" | "r3f" | "react-router" | "react-router-framework" | "react-router:6.4" | "react-router:6.7" | "react-router:6.9" | "react-router:6.19" | "react-router:7" | "react-router:7.8" | "react-router:7.9" | "react-router:7.10" | "react-router:7.15" | "react-router:8" | "pre-es2023" | "target-blank-needs-explicit-protection" | "target-blank-needs-noreferrer" | `react:${number}` | `preact:${number}` | `remotion:${number}` | `valtio:${number}` | `mobx:${number}` | `zustand:${number}` | `three:${number}` | `r3f:${number}`;
|
|
8
|
+
type CapabilityQuery = (capability: Capability) => boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/plugin/utils/file-scan.d.ts
|
|
11
|
+
interface ScannedFile {
|
|
12
|
+
readonly absolutePath: string;
|
|
13
|
+
readonly relativePath: string;
|
|
14
|
+
readonly content: string;
|
|
15
|
+
readonly isGeneratedBundle: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface ScanFinding {
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly line: number;
|
|
20
|
+
readonly column: number;
|
|
21
|
+
readonly severity?: "error" | "warn";
|
|
22
|
+
readonly title?: string;
|
|
23
|
+
readonly help?: string;
|
|
24
|
+
}
|
|
25
|
+
interface FileScan {
|
|
26
|
+
(file: ScannedFile): ScanFinding[];
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/plugin/utils/es-tree-node.d.ts
|
|
30
|
+
type WithLooseParent<NodeType> = NodeType extends NodeType ? Omit<NodeType, "parent"> & {
|
|
31
|
+
parent?: EsTreeNode | null;
|
|
32
|
+
} : never;
|
|
33
|
+
type EsTreeNode = WithLooseParent<TSESTree.Node>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/plugin/utils/report-descriptor.d.ts
|
|
36
|
+
interface ReportDescriptor {
|
|
37
|
+
node: EsTreeNode;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/plugin/semantic/control-flow-graph.d.ts
|
|
42
|
+
type CfgEdgeKind = "uncond" | "cond" | "throw";
|
|
43
|
+
interface CfgEdge {
|
|
44
|
+
readonly from: BasicBlock;
|
|
45
|
+
readonly to: BasicBlock;
|
|
46
|
+
readonly kind: CfgEdgeKind;
|
|
47
|
+
}
|
|
48
|
+
interface BasicBlock {
|
|
49
|
+
readonly id: number;
|
|
50
|
+
readonly nodes: EsTreeNode[];
|
|
51
|
+
readonly successors: CfgEdge[];
|
|
52
|
+
readonly predecessors: CfgEdge[];
|
|
53
|
+
}
|
|
54
|
+
interface FunctionCfg {
|
|
55
|
+
readonly owner: EsTreeNode;
|
|
56
|
+
readonly entry: BasicBlock;
|
|
57
|
+
readonly exit: BasicBlock;
|
|
58
|
+
readonly blocks: BasicBlock[];
|
|
59
|
+
readonly blockOf: (node: EsTreeNode) => BasicBlock | null;
|
|
60
|
+
}
|
|
61
|
+
interface ControlFlowAnalysis {
|
|
62
|
+
readonly cfgFor: (functionLike: EsTreeNode) => FunctionCfg | null;
|
|
63
|
+
readonly enclosingFunction: (node: EsTreeNode) => EsTreeNode | null;
|
|
64
|
+
readonly isUnconditionalFromEntry: (node: EsTreeNode) => boolean;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/plugin/semantic/scope-analysis.d.ts
|
|
68
|
+
type SymbolKind = "var" | "let" | "const" | "using" | "function" | "class" | "parameter" | "import" | "ts-import-equals" | "ts-enum" | "ts-type-alias" | "ts-interface" | "ts-module" | "catch-clause-parameter";
|
|
69
|
+
type ScopeKind = "module" | "function" | "arrow-function" | "method" | "block" | "class" | "catch" | "for" | "switch" | "with" | "ts-module" | "ts-enum";
|
|
70
|
+
interface SymbolDescriptor {
|
|
71
|
+
readonly id: number;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly kind: SymbolKind;
|
|
74
|
+
readonly bindingIdentifier: EsTreeNode;
|
|
75
|
+
readonly declarationNode: EsTreeNode;
|
|
76
|
+
readonly scope: ScopeDescriptor;
|
|
77
|
+
readonly initializer: EsTreeNode | null;
|
|
78
|
+
readonly references: ReferenceDescriptor[];
|
|
79
|
+
}
|
|
80
|
+
type ReferenceFlag = "read" | "write" | "read-write";
|
|
81
|
+
interface ReferenceDescriptor {
|
|
82
|
+
readonly id: number;
|
|
83
|
+
readonly identifier: EsTreeNode;
|
|
84
|
+
resolvedSymbol: SymbolDescriptor | null;
|
|
85
|
+
readonly flag: ReferenceFlag;
|
|
86
|
+
readonly scope: ScopeDescriptor;
|
|
87
|
+
}
|
|
88
|
+
interface ScopeDescriptor {
|
|
89
|
+
readonly id: number;
|
|
90
|
+
readonly kind: ScopeKind;
|
|
91
|
+
readonly node: EsTreeNode;
|
|
92
|
+
readonly parent: ScopeDescriptor | null;
|
|
93
|
+
readonly children: ScopeDescriptor[];
|
|
94
|
+
readonly symbols: SymbolDescriptor[];
|
|
95
|
+
readonly references: ReferenceDescriptor[];
|
|
96
|
+
readonly symbolsByName: Map<string, SymbolDescriptor>;
|
|
97
|
+
}
|
|
98
|
+
interface ScopeAnalysis {
|
|
99
|
+
readonly rootScope: ScopeDescriptor;
|
|
100
|
+
readonly scopeFor: (node: EsTreeNode) => ScopeDescriptor;
|
|
101
|
+
readonly ownScopeFor: (node: EsTreeNode) => ScopeDescriptor | null;
|
|
102
|
+
readonly symbolFor: (identifier: EsTreeNode) => SymbolDescriptor | null;
|
|
103
|
+
readonly referenceFor: (identifier: EsTreeNode) => ReferenceDescriptor | null;
|
|
104
|
+
readonly isGlobalReference: (identifier: EsTreeNode) => boolean;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/plugin/utils/rule-context.d.ts
|
|
108
|
+
interface BaseRuleSourceCode {
|
|
109
|
+
readonly ast?: EsTreeNode;
|
|
110
|
+
}
|
|
111
|
+
interface BaseRuleContext {
|
|
112
|
+
report: (descriptor: ReportDescriptor) => void;
|
|
113
|
+
readonly filename?: string;
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated Rules use `context.filename`. Read only as a fallback by
|
|
116
|
+
* `wrapWithSemanticContext`; ESLint implements it as a `this`-bound class
|
|
117
|
+
* method, so it must be called on the host context, never a detached
|
|
118
|
+
* reference.
|
|
119
|
+
*/
|
|
120
|
+
getFilename?: () => string | undefined;
|
|
121
|
+
readonly settings?: Readonly<Record<string, unknown>>;
|
|
122
|
+
readonly sourceCode?: BaseRuleSourceCode;
|
|
123
|
+
}
|
|
124
|
+
interface RuleContext extends Omit<BaseRuleContext, "getFilename"> {
|
|
125
|
+
readonly scopes: ScopeAnalysis;
|
|
126
|
+
readonly cfg: ControlFlowAnalysis;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/plugin/utils/rule-visitors.d.ts
|
|
130
|
+
interface RuleVisitors {
|
|
131
|
+
[selector: string]: ((node: any) => void) | (() => void);
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/plugin/utils/rule.d.ts
|
|
135
|
+
type RuleSeverity = "error" | "warn";
|
|
136
|
+
type RuleFramework = "global" | "nextjs" | "react-native" | "tanstack-start" | "tanstack-query" | "preact";
|
|
137
|
+
interface Rule {
|
|
138
|
+
id: string;
|
|
139
|
+
title?: string;
|
|
140
|
+
severity: RuleSeverity;
|
|
141
|
+
category?: string;
|
|
142
|
+
framework?: RuleFramework;
|
|
143
|
+
requires?: ReadonlyArray<Capability>;
|
|
144
|
+
minimumInkVersion?: string;
|
|
145
|
+
disabledWhen?: ReadonlyArray<Capability>;
|
|
146
|
+
tags?: ReadonlyArray<string>;
|
|
147
|
+
matchByOccurrence?: boolean;
|
|
148
|
+
defaultEnabled?: boolean;
|
|
149
|
+
lifecycle?: "retired";
|
|
150
|
+
scan?: FileScan;
|
|
151
|
+
committedFilesOnly?: boolean;
|
|
152
|
+
recommendation?: string;
|
|
153
|
+
recommendationFor?: (hasCapability: CapabilityQuery) => string | undefined;
|
|
154
|
+
create: (context: RuleContext) => RuleVisitors;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/types.d.ts
|
|
158
|
+
type OxlintRuleSeverity = RuleSeverity | "off";
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/external-rules.d.ts
|
|
161
|
+
declare const EXTERNAL_RULES: readonly [{
|
|
162
|
+
readonly key: "react-hooks-js/set-state-in-render";
|
|
163
|
+
readonly source: "react-compiler";
|
|
164
|
+
readonly severity: "error";
|
|
165
|
+
}, {
|
|
166
|
+
readonly key: "react-hooks-js/immutability";
|
|
167
|
+
readonly source: "react-compiler";
|
|
168
|
+
readonly severity: "error";
|
|
169
|
+
}, {
|
|
170
|
+
readonly key: "react-hooks-js/refs";
|
|
171
|
+
readonly source: "react-compiler";
|
|
172
|
+
readonly severity: "error";
|
|
173
|
+
}, {
|
|
174
|
+
readonly key: "react-hooks-js/purity";
|
|
175
|
+
readonly source: "react-compiler";
|
|
176
|
+
readonly severity: "error";
|
|
177
|
+
}, {
|
|
178
|
+
readonly key: "react-hooks-js/hooks";
|
|
179
|
+
readonly source: "react-compiler";
|
|
180
|
+
readonly severity: "error";
|
|
181
|
+
}, {
|
|
182
|
+
readonly key: "react-hooks-js/set-state-in-effect";
|
|
183
|
+
readonly source: "react-compiler";
|
|
184
|
+
readonly severity: "warn";
|
|
185
|
+
}, {
|
|
186
|
+
readonly key: "react-hooks-js/globals";
|
|
187
|
+
readonly source: "react-compiler";
|
|
188
|
+
readonly severity: "error";
|
|
189
|
+
}, {
|
|
190
|
+
readonly key: "react-hooks-js/error-boundaries";
|
|
191
|
+
readonly source: "react-compiler";
|
|
192
|
+
readonly severity: "error";
|
|
193
|
+
}, {
|
|
194
|
+
readonly key: "react-hooks-js/preserve-manual-memoization";
|
|
195
|
+
readonly source: "react-compiler";
|
|
196
|
+
readonly severity: "error";
|
|
197
|
+
}, {
|
|
198
|
+
readonly key: "react-hooks-js/unsupported-syntax";
|
|
199
|
+
readonly source: "react-compiler";
|
|
200
|
+
readonly severity: "error";
|
|
201
|
+
}, {
|
|
202
|
+
readonly key: "react-hooks-js/component-hook-factories";
|
|
203
|
+
readonly source: "react-compiler";
|
|
204
|
+
readonly severity: "error";
|
|
205
|
+
}, {
|
|
206
|
+
readonly key: "react-hooks-js/static-components";
|
|
207
|
+
readonly source: "react-compiler";
|
|
208
|
+
readonly severity: "error";
|
|
209
|
+
}, {
|
|
210
|
+
readonly key: "react-hooks-js/use-memo";
|
|
211
|
+
readonly source: "react-compiler";
|
|
212
|
+
readonly severity: "error";
|
|
213
|
+
}, {
|
|
214
|
+
readonly key: "react-hooks-js/void-use-memo";
|
|
215
|
+
readonly source: "react-compiler";
|
|
216
|
+
readonly severity: "error";
|
|
217
|
+
}, {
|
|
218
|
+
readonly key: "react-hooks-js/incompatible-library";
|
|
219
|
+
readonly source: "react-compiler";
|
|
220
|
+
readonly severity: "error";
|
|
221
|
+
}, {
|
|
222
|
+
readonly key: "react-hooks-js/todo";
|
|
223
|
+
readonly source: "react-compiler";
|
|
224
|
+
readonly severity: "error";
|
|
225
|
+
}];
|
|
226
|
+
declare const REACT_COMPILER_RULES: Record<string, OxlintRuleSeverity>;
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/plugin/constants/style.d.ts
|
|
229
|
+
declare const MOTION_LIBRARY_PACKAGES: Set<string>;
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/plugin/constants/cross-file-rule-ids.d.ts
|
|
232
|
+
declare const CROSS_FILE_RULE_IDS: ReadonlySet<string>;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/plugin/utils/cross-file-probe-recorder.d.ts
|
|
235
|
+
interface CrossFileProbeTrace {
|
|
236
|
+
/** Paths whose existence classification (file / dir / none) was consulted. */
|
|
237
|
+
readonly existencePaths: Set<string>;
|
|
238
|
+
/** Paths whose content (bytes, exports, parse) was consulted. */
|
|
239
|
+
readonly contentPaths: Set<string>;
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/plugin/cross-file-dependencies.d.ts
|
|
243
|
+
/**
|
|
244
|
+
* Per-rule cross-file dependency collectors — the foundation of the sidecar
|
|
245
|
+
* lint cache's dependency fingerprints (`@react-doctor/core`,
|
|
246
|
+
* `runners/oxlint/sidecar-lint-cache.ts`).
|
|
247
|
+
*
|
|
248
|
+
* A collector re-runs the SAME resolver helpers its rule calls at lint time
|
|
249
|
+
* (import resolution, barrel following, ancestor-layout walks, package.json
|
|
250
|
+
* classification) under the probe recorder
|
|
251
|
+
* (`utils/cross-file-probe-recorder.ts`), so the recorded probe set is the
|
|
252
|
+
* exact set of filesystem facts the rule's execution consulted — including
|
|
253
|
+
* the negative probes (extension candidates that did NOT exist) that make
|
|
254
|
+
* resolution shadowing detectable when a new file appears.
|
|
255
|
+
*
|
|
256
|
+
* SOUNDNESS INVARIANT — each collector's probe set must be a SUPERSET of
|
|
257
|
+
* every filesystem read its rule can make while linting the file, for any
|
|
258
|
+
* file content and any filesystem state:
|
|
259
|
+
*
|
|
260
|
+
* - Over-approximation is always safe (extra probes only cause a spurious
|
|
261
|
+
* re-lint); under-approximation is forbidden (a missed probe could
|
|
262
|
+
* replay a stale verdict).
|
|
263
|
+
* - Where a rule gates its cross-file reads on in-file conditions, a
|
|
264
|
+
* collector may skip the gate (probe more) or must mirror it EXACTLY
|
|
265
|
+
* (probe the same). Each collector documents which it does per gate.
|
|
266
|
+
* - The replay argument: the stored probe set is the complete read set of
|
|
267
|
+
* the collector's execution at store time. If every stored probe has
|
|
268
|
+
* the same answer on a later scan, re-executing the collector — and
|
|
269
|
+
* therefore the rule, whose reads are a subset — reproduces the same
|
|
270
|
+
* execution step by step (the file's own content is pinned separately
|
|
271
|
+
* by the cache key's content hash), so the stored diagnostics are
|
|
272
|
+
* exactly what a fresh sidecar lint would produce.
|
|
273
|
+
*
|
|
274
|
+
* A cross-file rule WITHOUT a collector here must be listed in
|
|
275
|
+
* `UNBOUNDED_CROSS_FILE_RULE_IDS` — it then re-lints every file on every
|
|
276
|
+
* scan (the sound fallback). `cross-file-rule-ids.test.ts` in
|
|
277
|
+
* `@react-doctor/core` forces every `CROSS_FILE_RULE_IDS` entry into
|
|
278
|
+
* exactly one of the two classifications.
|
|
279
|
+
*/
|
|
280
|
+
interface CrossFileDependencyCollectorInput {
|
|
281
|
+
/** Absolute, forward-slash-normalized path of the file being fingerprinted. */
|
|
282
|
+
readonly absoluteFilePath: string;
|
|
283
|
+
readonly sourceText: string;
|
|
284
|
+
/** oxc module record — the file's static import declarations. */
|
|
285
|
+
readonly staticImports: ReadonlyArray<StaticImport>;
|
|
286
|
+
/** Lazily materialized program (no parent references attached). */
|
|
287
|
+
readonly getProgram: () => EsTreeNode;
|
|
288
|
+
}
|
|
289
|
+
type CrossFileDependencyCollector = (input: CrossFileDependencyCollectorInput) => void;
|
|
290
|
+
declare const CROSS_FILE_DEPENDENCY_COLLECTORS: ReadonlyMap<string, CrossFileDependencyCollector>;
|
|
291
|
+
/**
|
|
292
|
+
* Cross-file rules whose dependency set CANNOT be soundly bounded — they are
|
|
293
|
+
* excluded from fingerprinting and re-lint every file on every scan. A new
|
|
294
|
+
* cross-file rule must be added either here or to
|
|
295
|
+
* `CROSS_FILE_DEPENDENCY_COLLECTORS` (the core guard test enforces the
|
|
296
|
+
* partition), forcing a conscious classification.
|
|
297
|
+
*/
|
|
298
|
+
declare const UNBOUNDED_CROSS_FILE_RULE_IDS: ReadonlySet<string>;
|
|
299
|
+
/**
|
|
300
|
+
* Runs the collectors for `ruleIds` over one file and returns every
|
|
301
|
+
* filesystem probe they made — the file's cross-file dependency set.
|
|
302
|
+
*
|
|
303
|
+
* Returns `null` (caller must treat the file as unfingerprintable and always
|
|
304
|
+
* re-lint it) when the file has a fatal parse error — an execution the
|
|
305
|
+
* collectors cannot mirror — or when a requested rule has no collector.
|
|
306
|
+
*/
|
|
307
|
+
declare const collectCrossFileDependencyProbes: (input: {
|
|
308
|
+
absoluteFilePath: string;
|
|
309
|
+
sourceText: string;
|
|
310
|
+
ruleIds: ReadonlyArray<string>;
|
|
311
|
+
}) => CrossFileProbeTrace | null;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/plugin/utils/reset-filesystem-caches.d.ts
|
|
314
|
+
declare const resetFilesystemCaches: () => void;
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/plugin/rules/security-scan/utils/classify-security-scan-file.d.ts
|
|
317
|
+
interface SecurityScanFileClassification {
|
|
318
|
+
readonly bucket: "priority" | "artifact" | "other";
|
|
319
|
+
readonly isGeneratedBundleByName: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare const classifySecurityScanFile: (relativePath: string) => SecurityScanFileClassification | null;
|
|
322
|
+
declare const shouldReadSecurityScanContent: (relativePath: string, isGeneratedBundle: boolean) => boolean;
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/react-native-dependency-names.d.ts
|
|
325
|
+
declare const REACT_NATIVE_DEPENDENCY_NAMES: ReadonlySet<string>;
|
|
326
|
+
declare const REACT_NATIVE_DEPENDENCY_PREFIXES: ReadonlyArray<string>;
|
|
327
|
+
declare const isReactNativeDependencyName: (dependencyName: string) => boolean;
|
|
328
|
+
//#endregion
|
|
329
|
+
export { FileScan as C, CapabilityQuery as D, Capability as E, FRAMEWORK_TOKENS as O, EsTreeNode as S, ScannedFile as T, RuleFramework as _, shouldReadSecurityScanContent as a, BaseRuleContext as b, UNBOUNDED_CROSS_FILE_RULE_IDS as c, CROSS_FILE_RULE_IDS as d, MOTION_LIBRARY_PACKAGES as f, Rule as g, OxlintRuleSeverity as h, classifySecurityScanFile as i, FrameworkToken as k, collectCrossFileDependencyProbes as l, REACT_COMPILER_RULES as m, REACT_NATIVE_DEPENDENCY_PREFIXES as n, resetFilesystemCaches as o, EXTERNAL_RULES as p, isReactNativeDependencyName as r, CROSS_FILE_DEPENDENCY_COLLECTORS as s, REACT_NATIVE_DEPENDENCY_NAMES as t, CrossFileProbeTrace as u, RuleSeverity as v, ScanFinding as w, RuleContext as x, RuleVisitors as y };
|
|
330
|
+
//# sourceMappingURL=react-native-dependency-names-DrsRME-d.d.ts.map
|