oxlint-plugin-react-doctor 0.9.11-dev.cd2b22e → 0.9.11-dev.d908bb1

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