oxlint-plugin-react-doctor 0.9.17 → 0.9.18-dev.3fd747e

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