oxlint-plugin-react-doctor 0.9.13-dev.fa72869 → 0.9.13-dev.ff7dd67

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,333 @@
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
+ 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
+ getText?: (node?: EsTreeNode | null) => string;
111
+ }
112
+ interface BaseRuleContext {
113
+ report: (descriptor: ReportDescriptor) => void;
114
+ readonly filename?: string;
115
+ /**
116
+ * @deprecated Rules use `context.filename`. Read only as a fallback by
117
+ * `wrapWithSemanticContext`; ESLint implements it as a `this`-bound class
118
+ * method, so it must be called on the host context, never a detached
119
+ * reference.
120
+ */
121
+ getFilename?: () => string | undefined;
122
+ readonly settings?: Readonly<Record<string, unknown>>;
123
+ readonly sourceCode?: BaseRuleSourceCode;
124
+ }
125
+ interface RuleContext extends Omit<BaseRuleContext, "getFilename"> {
126
+ readonly scopes: ScopeAnalysis;
127
+ readonly cfg: ControlFlowAnalysis;
128
+ }
129
+ //#endregion
130
+ //#region src/plugin/utils/rule-visitors.d.ts
131
+ interface RuleVisitors {
132
+ [selector: string]: ((node: any) => void) | (() => void);
133
+ }
134
+ //#endregion
135
+ //#region src/plugin/utils/rule.d.ts
136
+ type RuleSeverity = "error" | "warn";
137
+ type RuleExecution = "project";
138
+ type RuleFramework = "global" | "nextjs" | "react-native" | "tanstack-start" | "tanstack-query" | "preact";
139
+ interface Rule {
140
+ id: string;
141
+ title?: string;
142
+ severity: RuleSeverity;
143
+ category?: string;
144
+ framework?: RuleFramework;
145
+ requires?: ReadonlyArray<Capability>;
146
+ minimumInkVersion?: string;
147
+ disabledWhen?: ReadonlyArray<Capability>;
148
+ tags?: ReadonlyArray<string>;
149
+ matchByOccurrence?: boolean;
150
+ defaultEnabled?: boolean;
151
+ lifecycle?: "retired";
152
+ execution?: RuleExecution;
153
+ scan?: FileScan;
154
+ committedFilesOnly?: boolean;
155
+ recommendation?: string;
156
+ recommendationFor?: (hasCapability: CapabilityQuery) => string | undefined;
157
+ create: (context: RuleContext) => RuleVisitors;
158
+ }
159
+ //#endregion
160
+ //#region src/types.d.ts
161
+ type OxlintRuleSeverity = RuleSeverity | "off";
162
+ //#endregion
163
+ //#region src/external-rules.d.ts
164
+ declare const EXTERNAL_RULES: readonly [{
165
+ readonly key: "react-hooks-js/set-state-in-render";
166
+ readonly source: "react-compiler";
167
+ readonly severity: "error";
168
+ }, {
169
+ readonly key: "react-hooks-js/immutability";
170
+ readonly source: "react-compiler";
171
+ readonly severity: "error";
172
+ }, {
173
+ readonly key: "react-hooks-js/refs";
174
+ readonly source: "react-compiler";
175
+ readonly severity: "error";
176
+ }, {
177
+ readonly key: "react-hooks-js/purity";
178
+ readonly source: "react-compiler";
179
+ readonly severity: "error";
180
+ }, {
181
+ readonly key: "react-hooks-js/hooks";
182
+ readonly source: "react-compiler";
183
+ readonly severity: "error";
184
+ }, {
185
+ readonly key: "react-hooks-js/set-state-in-effect";
186
+ readonly source: "react-compiler";
187
+ readonly severity: "warn";
188
+ }, {
189
+ readonly key: "react-hooks-js/globals";
190
+ readonly source: "react-compiler";
191
+ readonly severity: "error";
192
+ }, {
193
+ readonly key: "react-hooks-js/error-boundaries";
194
+ readonly source: "react-compiler";
195
+ readonly severity: "error";
196
+ }, {
197
+ readonly key: "react-hooks-js/preserve-manual-memoization";
198
+ readonly source: "react-compiler";
199
+ readonly severity: "error";
200
+ }, {
201
+ readonly key: "react-hooks-js/unsupported-syntax";
202
+ readonly source: "react-compiler";
203
+ readonly severity: "error";
204
+ }, {
205
+ readonly key: "react-hooks-js/component-hook-factories";
206
+ readonly source: "react-compiler";
207
+ readonly severity: "error";
208
+ }, {
209
+ readonly key: "react-hooks-js/static-components";
210
+ readonly source: "react-compiler";
211
+ readonly severity: "error";
212
+ }, {
213
+ readonly key: "react-hooks-js/use-memo";
214
+ readonly source: "react-compiler";
215
+ readonly severity: "error";
216
+ }, {
217
+ readonly key: "react-hooks-js/void-use-memo";
218
+ readonly source: "react-compiler";
219
+ readonly severity: "error";
220
+ }, {
221
+ readonly key: "react-hooks-js/incompatible-library";
222
+ readonly source: "react-compiler";
223
+ readonly severity: "error";
224
+ }, {
225
+ readonly key: "react-hooks-js/todo";
226
+ readonly source: "react-compiler";
227
+ readonly severity: "error";
228
+ }];
229
+ declare const REACT_COMPILER_RULES: Record<string, OxlintRuleSeverity>;
230
+ //#endregion
231
+ //#region src/plugin/constants/style.d.ts
232
+ declare const MOTION_LIBRARY_PACKAGES: Set<string>;
233
+ //#endregion
234
+ //#region src/plugin/constants/cross-file-rule-ids.d.ts
235
+ declare const CROSS_FILE_RULE_IDS: ReadonlySet<string>;
236
+ //#endregion
237
+ //#region src/plugin/utils/cross-file-probe-recorder.d.ts
238
+ interface CrossFileProbeTrace {
239
+ /** Paths whose existence classification (file / dir / none) was consulted. */
240
+ readonly existencePaths: Set<string>;
241
+ /** Paths whose content (bytes, exports, parse) was consulted. */
242
+ readonly contentPaths: Set<string>;
243
+ }
244
+ //#endregion
245
+ //#region src/plugin/cross-file-dependencies.d.ts
246
+ /**
247
+ * Per-rule cross-file dependency collectors — the foundation of the sidecar
248
+ * lint cache's dependency fingerprints (`@react-doctor/core`,
249
+ * `runners/oxlint/sidecar-lint-cache.ts`).
250
+ *
251
+ * A collector re-runs the SAME resolver helpers its rule calls at lint time
252
+ * (import resolution, barrel following, ancestor-layout walks, package.json
253
+ * classification) under the probe recorder
254
+ * (`utils/cross-file-probe-recorder.ts`), so the recorded probe set is the
255
+ * exact set of filesystem facts the rule's execution consulted — including
256
+ * the negative probes (extension candidates that did NOT exist) that make
257
+ * resolution shadowing detectable when a new file appears.
258
+ *
259
+ * SOUNDNESS INVARIANT — each collector's probe set must be a SUPERSET of
260
+ * every filesystem read its rule can make while linting the file, for any
261
+ * file content and any filesystem state:
262
+ *
263
+ * - Over-approximation is always safe (extra probes only cause a spurious
264
+ * re-lint); under-approximation is forbidden (a missed probe could
265
+ * replay a stale verdict).
266
+ * - Where a rule gates its cross-file reads on in-file conditions, a
267
+ * collector may skip the gate (probe more) or must mirror it EXACTLY
268
+ * (probe the same). Each collector documents which it does per gate.
269
+ * - The replay argument: the stored probe set is the complete read set of
270
+ * the collector's execution at store time. If every stored probe has
271
+ * the same answer on a later scan, re-executing the collector — and
272
+ * therefore the rule, whose reads are a subset — reproduces the same
273
+ * execution step by step (the file's own content is pinned separately
274
+ * by the cache key's content hash), so the stored diagnostics are
275
+ * exactly what a fresh sidecar lint would produce.
276
+ *
277
+ * A cross-file rule WITHOUT a collector here must be listed in
278
+ * `UNBOUNDED_CROSS_FILE_RULE_IDS` — it then re-lints every file on every
279
+ * scan (the sound fallback). `cross-file-rule-ids.test.ts` in
280
+ * `@react-doctor/core` forces every `CROSS_FILE_RULE_IDS` entry into
281
+ * exactly one of the two classifications.
282
+ */
283
+ interface CrossFileDependencyCollectorInput {
284
+ /** Absolute, forward-slash-normalized path of the file being fingerprinted. */
285
+ readonly absoluteFilePath: string;
286
+ readonly sourceText: string;
287
+ /** oxc module record — the file's static import declarations. */
288
+ readonly staticImports: ReadonlyArray<StaticImport>;
289
+ /** Lazily materialized program (no parent references attached). */
290
+ readonly getProgram: () => EsTreeNode;
291
+ }
292
+ type CrossFileDependencyCollector = (input: CrossFileDependencyCollectorInput) => void;
293
+ declare const CROSS_FILE_DEPENDENCY_COLLECTORS: ReadonlyMap<string, CrossFileDependencyCollector>;
294
+ /**
295
+ * Cross-file rules whose dependency set CANNOT be soundly bounded — they are
296
+ * excluded from fingerprinting and re-lint every file on every scan. A new
297
+ * cross-file rule must be added either here or to
298
+ * `CROSS_FILE_DEPENDENCY_COLLECTORS` (the core guard test enforces the
299
+ * partition), forcing a conscious classification.
300
+ */
301
+ declare const UNBOUNDED_CROSS_FILE_RULE_IDS: ReadonlySet<string>;
302
+ /**
303
+ * Runs the collectors for `ruleIds` over one file and returns every
304
+ * filesystem probe they made — the file's cross-file dependency set.
305
+ *
306
+ * Returns `null` (caller must treat the file as unfingerprintable and always
307
+ * re-lint it) when the file has a fatal parse error — an execution the
308
+ * collectors cannot mirror — or when a requested rule has no collector.
309
+ */
310
+ declare const collectCrossFileDependencyProbes: (input: {
311
+ absoluteFilePath: string;
312
+ sourceText: string;
313
+ ruleIds: ReadonlyArray<string>;
314
+ }) => CrossFileProbeTrace | null;
315
+ //#endregion
316
+ //#region src/plugin/utils/reset-filesystem-caches.d.ts
317
+ declare const resetFilesystemCaches: () => void;
318
+ //#endregion
319
+ //#region src/plugin/rules/security-scan/utils/classify-security-scan-file.d.ts
320
+ interface SecurityScanFileClassification {
321
+ readonly bucket: "priority" | "artifact" | "other";
322
+ readonly isGeneratedBundleByName: boolean;
323
+ }
324
+ declare const classifySecurityScanFile: (relativePath: string) => SecurityScanFileClassification | null;
325
+ declare const shouldReadSecurityScanContent: (relativePath: string, isGeneratedBundle: boolean) => boolean;
326
+ //#endregion
327
+ //#region src/react-native-dependency-names.d.ts
328
+ declare const REACT_NATIVE_DEPENDENCY_NAMES: ReadonlySet<string>;
329
+ declare const REACT_NATIVE_DEPENDENCY_PREFIXES: ReadonlyArray<string>;
330
+ declare const isReactNativeDependencyName: (dependencyName: string) => boolean;
331
+ //#endregion
332
+ export { FrameworkToken as A, EsTreeNode as C, Capability as D, ScannedFile as E, CapabilityQuery as O, RuleContext as S, ScanFinding as T, RuleExecution as _, shouldReadSecurityScanContent as a, RuleVisitors 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, FRAMEWORK_TOKENS 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, FileScan as w, BaseRuleContext as x, RuleSeverity as y };
333
+ //# sourceMappingURL=react-native-dependency-names-waW0owVD.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-react-doctor",
3
- "version": "0.9.13-dev.fa72869",
3
+ "version": "0.9.13-dev.ff7dd67",
4
4
  "description": "React Doctor rules for oxlint.",
5
5
  "keywords": [
6
6
  "accessibility",