oxlint-plugin-react-doctor 0.9.17 → 0.9.18-dev.d1feed1

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