react-doctor 0.5.1-dev.2f26228 → 0.5.1-dev.7c88165

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/index.d.ts CHANGED
@@ -9116,11 +9116,11 @@ interface SurfaceControls {
9116
9116
  *
9117
9117
  * Mirrors how Socket Firewall's free tier (`sfw`) works: each direct
9118
9118
  * dependency's PURL is looked up against Socket's keyless
9119
- * `firewall-api.socket.dev/purl/<purl>` endpoint, which returns a
9120
- * supply-chain score (0–100 once normalized). A dependency scoring below
9121
- * `minScore` produces a diagnostic; at the default `severity: "error"` it
9122
- * fails the scan (non-zero CI exit), the same way an error-severity lint
9123
- * finding does.
9119
+ * `firewall-api.socket.dev/purl/<purl>` endpoint, which returns per-axis
9120
+ * scores (0–100 once normalized). A dependency whose worst security axis
9121
+ * (supply chain or vulnerability) scores below `minScore` produces a
9122
+ * diagnostic; at the default `severity: "error"` it fails the scan
9123
+ * (non-zero CI exit), the same way an error-severity lint finding does.
9124
9124
  */
9125
9125
  interface SupplyChainConfig {
9126
9126
  /**
@@ -9132,8 +9132,9 @@ interface SupplyChainConfig {
9132
9132
  enabled?: boolean;
9133
9133
  /**
9134
9134
  * Minimum acceptable Socket score on a 0–100 scale. A direct dependency
9135
- * whose Socket `overall` score is below this is flagged. Default: `50`.
9136
- * Values outside `0..100` are clamped.
9135
+ * whose worst Socket *security* axis — supply chain or vulnerability — is
9136
+ * below this is flagged; the quality / maintenance / license axes never
9137
+ * gate. Default: `50`. Values outside `0..100` are clamped.
9137
9138
  */
9138
9139
  minScore?: number;
9139
9140
  /**
@@ -9236,6 +9237,22 @@ interface ReactDoctorConfig {
9236
9237
  * requested directory).
9237
9238
  */
9238
9239
  rootDir?: string;
9240
+ /**
9241
+ * Projects to scan and score separately — the config-file equivalent of
9242
+ * the CLI `--project` flag, for repos that always want per-module scoring
9243
+ * (e.g. a monorepo dashboard tracking each module's score daily) without
9244
+ * passing the flag on every run.
9245
+ *
9246
+ * Entries resolve exactly like `--project` values: workspace package
9247
+ * names (or directory basenames) first, then directory paths relative to
9248
+ * the scanned root. `"*"` selects every discovered workspace project.
9249
+ * Invalid entries fail the run with the same error as the flag.
9250
+ *
9251
+ * Precedence: an explicit `--project` flag overrides this list. Only the
9252
+ * config at the invocation root is consulted — `projects` inside a
9253
+ * module's own config is ignored (modules can't redirect the scan).
9254
+ */
9255
+ projects?: string[];
9239
9256
  textComponents?: string[];
9240
9257
  /**
9241
9258
  * Names of components that safely route string-only children through a
@@ -9600,12 +9617,55 @@ interface DiagnoseResult {
9600
9617
  elapsedMilliseconds: number;
9601
9618
  }
9602
9619
  /**
9603
- * A single project to scan as part of a `diagnoseProjects()` batch.
9620
+ * A single project to scan as part of a `diagnose({ projects })` batch.
9604
9621
  * Scan options (`deadCode`, `lint`, etc.) are flat on the entry and
9605
9622
  * layer on top of the global defaults — omitted fields fall through.
9606
- * `config` is a full `ReactDoctorConfig` override that replaces the
9607
- * on-disk `doctor.config.*` for this project's scan.
9608
9623
  */
9624
+ interface ProjectDefinition extends DiagnoseOptions {
9625
+ directory: string;
9626
+ /**
9627
+ * Per-project config overrides, layered additively (see
9628
+ * `mergeReactDoctorConfigs`) on top of the project's on-disk
9629
+ * `doctor.config.*` and the batch-level `DiagnoseProjectsInput.config`
9630
+ * — so disabling one rule here keeps every base rule intact.
9631
+ */
9632
+ config?: ReactDoctorConfig;
9633
+ }
9634
+ interface ProjectResultOk extends DiagnoseResult {
9635
+ ok: true;
9636
+ directory: string;
9637
+ }
9638
+ interface ProjectResultError {
9639
+ ok: false;
9640
+ directory: string;
9641
+ error: Error;
9642
+ }
9643
+ type ProjectResult = ProjectResultOk | ProjectResultError;
9644
+ interface DiagnoseProjectsInput extends DiagnoseOptions {
9645
+ projects: ProjectDefinition[];
9646
+ /**
9647
+ * Config overrides applied to every project in the batch, layered
9648
+ * additively (see `mergeReactDoctorConfigs`) between each project's
9649
+ * on-disk `doctor.config.*` and its `ProjectDefinition.config` — one
9650
+ * base rule set for the batch, overridden per project only where needed.
9651
+ */
9652
+ config?: ReactDoctorConfig;
9653
+ /**
9654
+ * Maximum number of projects to scan concurrently. Defaults to
9655
+ * `DEFAULT_PROJECT_SCAN_CONCURRENCY` (4) — each project scan fans out
9656
+ * its own lint workers, so the batch is bounded rather than fully
9657
+ * parallel. Set to `1` for sequential execution. Values below 1 are
9658
+ * clamped to 1.
9659
+ */
9660
+ concurrency?: number;
9661
+ }
9662
+ interface DiagnoseProjectsResult {
9663
+ projects: ProjectResult[];
9664
+ diagnostics: Diagnostic[];
9665
+ score: ScoreResult | null;
9666
+ elapsedMilliseconds: number;
9667
+ } //#endregion
9668
+ //#region src/types/handle-error.d.ts
9609
9669
  //#endregion
9610
9670
  //#region src/types/inspect.d.ts
9611
9671
  interface InspectResult {
@@ -10026,41 +10086,20 @@ declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //
10026
10086
  //#endregion
10027
10087
  //#region ../api/dist/index.d.ts
10028
10088
  //#region src/diagnose.d.ts
10029
- declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>;
10030
- /**
10031
- * Scan multiple projects in parallel and return per-project scores,
10032
- * diagnostics, and an aggregate score (worst-of across all projects).
10033
- *
10034
- * Each project runs its own independent `runInspect` pipeline — the
10035
- * same pipeline `diagnose()` uses — so per-project config overrides,
10036
- * dead-code analysis, and scoring all work identically to a single
10037
- * `diagnose()` call.
10038
- *
10039
- * Projects that fail (e.g. missing `package.json`, no React dependency)
10040
- * are included in the result with `ok: false` rather than aborting the
10041
- * entire batch, so callers always receive partial results.
10042
- *
10043
- * ```ts
10044
- * const result = await diagnoseProjects({
10045
- * projects: [
10046
- * { directory: "packages/app" },
10047
- * { directory: "packages/shared", deadCode: false },
10048
- * { directory: "packages/admin", config: {
10049
- * rules: { "react-doctor/no-array-index-as-key": "off" },
10050
- * }},
10051
- * ],
10052
- * concurrency: 4,
10053
- * });
10054
- *
10055
- * for (const project of result.projects) {
10056
- * if (project.ok) {
10057
- * console.log(project.directory, project.score);
10058
- * } else {
10059
- * console.error(project.directory, project.error);
10060
- * }
10061
- * }
10062
- * ```
10063
- */
10089
+ interface Diagnose {
10090
+ /** Scan a single project directory and return diagnostics + score. */
10091
+ (directory: string, options?: DiagnoseOptions): Promise<DiagnoseResult>;
10092
+ /**
10093
+ * Scan multiple projects in parallel — each through the same pipeline as
10094
+ * the single-directory form — and return per-project results plus an
10095
+ * aggregate worst-of score. A failing project (e.g. no `package.json`)
10096
+ * comes back with `ok: false` instead of aborting the batch. Per-project
10097
+ * `config` layers on the batch `config`, which layers on each project's
10098
+ * on-disk config (see `mergeReactDoctorConfigs`).
10099
+ */
10100
+ (input: DiagnoseProjectsInput): Promise<DiagnoseProjectsResult>;
10101
+ }
10102
+ declare const diagnose: Diagnose; //#endregion
10064
10103
  //#endregion
10065
10104
  //#region src/index.d.ts
10066
10105
  declare const clearCaches: () => void;
@@ -10071,5 +10110,5 @@ interface ToJsonReportOptions {
10071
10110
  }
10072
10111
  declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
10073
10112
  //#endregion
10074
- export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
10113
+ export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseProjectsInput, type DiagnoseProjectsResult, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectDefinition, type ProjectInfo, ProjectNotFoundError, type ProjectResult, type ProjectResultError, type ProjectResultOk, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
10075
10114
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dc9a4bab-aa8a-5831-97ae-77b1f28179d6")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d789108a-ddf2-5b61-a479-4c797dba74cb")}catch(e){}}();
3
3
  import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import * as NFS from "node:fs";
@@ -38475,6 +38475,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38475
38475
  };
38476
38476
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38477
38477
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38478
+ const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38478
38479
  const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
38479
38480
  const PLUGIN_CATEGORY_MAP = {
38480
38481
  react: "Bugs",
@@ -38502,7 +38503,10 @@ const getRuleRecommendation = (ruleName, project) => {
38502
38503
  };
38503
38504
  const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
38504
38505
  const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
38505
- const resolveDiagnosticTitle = (plugin, rule) => plugin === "react-hooks-js" ? REACT_COMPILER_TITLE : getRuleTitle(rule);
38506
+ const resolveDiagnosticTitle = (plugin, rule) => {
38507
+ if (plugin !== "react-hooks-js") return getRuleTitle(rule);
38508
+ return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
38509
+ };
38506
38510
  const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38507
38511
  const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
38508
38512
  return {
@@ -39261,25 +39265,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
39261
39265
  const SCORE_AXES = [
39262
39266
  {
39263
39267
  key: "supplyChain",
39264
- label: "supply chain"
39268
+ label: "supply chain",
39269
+ gates: true
39265
39270
  },
39266
39271
  {
39267
39272
  key: "vulnerability",
39268
- label: "vulnerability"
39273
+ label: "vulnerability",
39274
+ gates: true
39269
39275
  },
39270
39276
  {
39271
39277
  key: "maintenance",
39272
- label: "maintenance"
39278
+ label: "maintenance",
39279
+ gates: false
39273
39280
  },
39274
39281
  {
39275
39282
  key: "quality",
39276
- label: "quality"
39283
+ label: "quality",
39284
+ gates: false
39277
39285
  },
39278
39286
  {
39279
39287
  key: "license",
39280
- label: "license"
39288
+ label: "license",
39289
+ gates: false
39281
39290
  }
39282
39291
  ];
39292
+ const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
39293
+ const worstGatedAxis = (score) => {
39294
+ let worst = GATED_AXES[0];
39295
+ for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
39296
+ return worst;
39297
+ };
39283
39298
  const clampScore = (value) => {
39284
39299
  if (!Number.isFinite(value)) return 50;
39285
39300
  return Math.min(Math.max(value, 0), 100);
@@ -39395,15 +39410,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39395
39410
  "socket.purl": toPurl(dependency)
39396
39411
  } }));
39397
39412
  const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39398
- const buildLowScoreDiagnostic = (dependency, score, options) => {
39399
- const overall = toHundred(score.overall);
39413
+ const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
39400
39414
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
39401
39415
  return {
39402
39416
  filePath: "package.json",
39403
39417
  plugin: SUPPLY_CHAIN_PLUGIN,
39404
39418
  rule: SUPPLY_CHAIN_RULE,
39405
39419
  severity: options.severity,
39406
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket supply-chain score of ${overall}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39420
+ message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39407
39421
  help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
39408
39422
  url: packagePageUrl,
39409
39423
  line: dependency.line,
@@ -39415,7 +39429,9 @@ const buildLowScoreDiagnostic = (dependency, score, options) => {
39415
39429
  * Scores every direct dependency in the project's `package.json` against
39416
39430
  * Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
39417
39431
  * uses — no API key) and returns a diagnostic for each dependency whose
39418
- * Socket `overall` score is below the configured `minScore`.
39432
+ * worst Socket *security* axis — supply chain or vulnerability — is below
39433
+ * the configured `minScore`. The quality / maintenance / license axes are
39434
+ * reported as context but never gate (see GATED_AXES).
39419
39435
  *
39420
39436
  * Lookups run with bounded concurrency via `Effect.forEach`. The check is
39421
39437
  * total/fail-open: each per-package lookup already recovers to `null`
@@ -39433,8 +39449,9 @@ const checkSupplyChain = (input) => gen(function* () {
39433
39449
  for (let index = 0; index < dependencies.length; index += 1) {
39434
39450
  const score = scores[index];
39435
39451
  if (!score) continue;
39436
- if (toHundred(score.overall) >= options.minScore) continue;
39437
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
39452
+ const worstAxis = worstGatedAxis(score);
39453
+ if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
39454
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
39438
39455
  }
39439
39456
  return diagnostics;
39440
39457
  });
@@ -39442,7 +39459,8 @@ const checkSupplyChain = (input) => gen(function* () {
39442
39459
  * `SupplyChain` scores the project's direct dependencies against Socket.dev's
39443
39460
  * free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
39444
39461
  * (`sfw`) performs — and streams a diagnostic for each dependency whose
39445
- * Socket score falls below the configured `supplyChain.minScore`.
39462
+ * worst Socket security axis (supply chain or vulnerability) falls below
39463
+ * the configured `supplyChain.minScore`.
39446
39464
  *
39447
39465
  * Runs by default (one network request per dependency); the orchestrator
39448
39466
  * provides `layerOf([])` only when the user opts out via
@@ -40085,13 +40103,55 @@ const clearAutoSuppressionCaches = () => {};
40085
40103
  * untouched so the loader sees the same plain object either way.
40086
40104
  */
40087
40105
  const defineConfig = (config) => config;
40106
+ const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
40107
+ const mergeIgnores = (baseIgnore, overrideIgnore) => {
40108
+ const mergedIgnore = {
40109
+ ...baseIgnore,
40110
+ ...overrideIgnore
40111
+ };
40112
+ if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
40113
+ if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
40114
+ if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
40115
+ if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
40116
+ return mergedIgnore;
40117
+ };
40118
+ /**
40119
+ * Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
40120
+ * `categories` / `supplyChain` merge per key, `ignore` lists union
40121
+ * (`ignore.overrides` concatenate), and every other field is a scalar the
40122
+ * override simply wins on when set. Returns the base unchanged when there
40123
+ * is no override, and vice versa — so callers can thread `null` /
40124
+ * `undefined` through without special-casing.
40125
+ */
40126
+ const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
40127
+ if (overrideConfig === void 0) return baseConfig;
40128
+ if (baseConfig === null) return overrideConfig;
40129
+ const mergedConfig = {
40130
+ ...baseConfig,
40131
+ ...overrideConfig
40132
+ };
40133
+ if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
40134
+ ...baseConfig.rules,
40135
+ ...overrideConfig.rules
40136
+ };
40137
+ if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
40138
+ ...baseConfig.categories,
40139
+ ...overrideConfig.categories
40140
+ };
40141
+ if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
40142
+ ...baseConfig.supplyChain,
40143
+ ...overrideConfig.supplyChain
40144
+ };
40145
+ if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
40146
+ return mergedConfig;
40147
+ };
40088
40148
  //#endregion
40089
40149
  //#region ../api/dist/index.js
40090
- const buildDiagnoseLayer = (config, configOverride) => {
40091
- const configLayer = configOverride === void 0 ? Config.layerNode : Config.layerOf({
40150
+ const buildDiagnoseLayer = (config, configOverrideTarget) => {
40151
+ const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
40092
40152
  config,
40093
- resolvedDirectory: configOverride.resolvedDirectory,
40094
- configSourceDirectory: null
40153
+ resolvedDirectory: configOverrideTarget.resolvedDirectory,
40154
+ configSourceDirectory: configOverrideTarget.configSourceDirectory
40095
40155
  });
40096
40156
  return mergeAll$1(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp, config?.supplyChain?.enabled !== false ? SupplyChain.layerNode : SupplyChain.layerOf([]));
40097
40157
  };
@@ -40123,11 +40183,64 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
40123
40183
  elapsedMilliseconds
40124
40184
  };
40125
40185
  };
40126
- const diagnose = async (directory, options = {}) => {
40186
+ const diagnoseDirectory = async (directory, options) => {
40127
40187
  const startTime = globalThis.performance.now();
40128
40188
  const scanTarget = await resolveScanTarget(directory);
40129
40189
  return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
40130
40190
  };
40191
+ const findWorstScore = (projectResults) => {
40192
+ let worstResult = null;
40193
+ let worstScore = Number.POSITIVE_INFINITY;
40194
+ for (const projectResult of projectResults) {
40195
+ if (!projectResult.ok || projectResult.score === null) continue;
40196
+ if (projectResult.score.score < worstScore) {
40197
+ worstScore = projectResult.score.score;
40198
+ worstResult = projectResult.score;
40199
+ }
40200
+ }
40201
+ return worstResult;
40202
+ };
40203
+ const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
40204
+ const startTime = globalThis.performance.now();
40205
+ try {
40206
+ const scanTarget = await resolveScanTarget(projectDefinition.directory);
40207
+ const { directory: _, config: projectConfig, ...perProjectOptions } = projectDefinition;
40208
+ const didOverrideConfig = batchConfig !== void 0 || projectConfig !== void 0;
40209
+ const effectiveConfig = mergeReactDoctorConfigs(mergeReactDoctorConfigs(scanTarget.userConfig, batchConfig), projectConfig);
40210
+ const program = buildInspectProgram(scanTarget, {
40211
+ ...baseOptions,
40212
+ ...perProjectOptions
40213
+ }, effectiveConfig ?? void 0);
40214
+ const didOverridePlugins = batchConfig?.plugins !== void 0 || projectConfig?.plugins !== void 0;
40215
+ const layer = buildDiagnoseLayer(effectiveConfig, didOverrideConfig ? {
40216
+ resolvedDirectory: scanTarget.resolvedDirectory,
40217
+ configSourceDirectory: didOverridePlugins ? null : scanTarget.configSourceDirectory
40218
+ } : void 0);
40219
+ return {
40220
+ ok: true,
40221
+ ...outputToDiagnoseResult(await runPromise(restoreLegacyThrow(program.pipe(provide(layer), provide(layerOtlp)))), globalThis.performance.now() - startTime),
40222
+ directory: scanTarget.resolvedDirectory
40223
+ };
40224
+ } catch (error) {
40225
+ return {
40226
+ ok: false,
40227
+ directory: projectDefinition.directory,
40228
+ error: error instanceof Error ? error : new Error(String(error))
40229
+ };
40230
+ }
40231
+ };
40232
+ const diagnoseProjectBatch = async (input) => {
40233
+ const startTime = globalThis.performance.now();
40234
+ const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
40235
+ const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
40236
+ return {
40237
+ projects: projectResults,
40238
+ diagnostics: projectResults.flatMap((projectResult) => projectResult.ok ? projectResult.diagnostics : []),
40239
+ score: findWorstScore(projectResults),
40240
+ elapsedMilliseconds: globalThis.performance.now() - startTime
40241
+ };
40242
+ };
40243
+ const diagnose = (async (directoryOrInput, options = {}) => typeof directoryOrInput === "string" ? diagnoseDirectory(directoryOrInput, options) : diagnoseProjectBatch(directoryOrInput));
40131
40244
  //#endregion
40132
40245
  //#region src/index.ts
40133
40246
  const clearCaches = () => {
@@ -40160,4 +40273,4 @@ const toJsonReport = (result, options) => buildJsonReport({
40160
40273
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
40161
40274
 
40162
40275
  //# sourceMappingURL=index.js.map
40163
- //# debugId=dc9a4bab-aa8a-5831-97ae-77b1f28179d6
40276
+ //# debugId=d789108a-ddf2-5b61-a479-4c797dba74cb
package/dist/lsp.js CHANGED
@@ -38461,6 +38461,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38461
38461
  };
38462
38462
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38463
38463
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38464
+ const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38464
38465
  const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
38465
38466
  const PLUGIN_CATEGORY_MAP = {
38466
38467
  react: "Bugs",
@@ -38488,7 +38489,10 @@ const getRuleRecommendation = (ruleName, project) => {
38488
38489
  };
38489
38490
  const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
38490
38491
  const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
38491
- const resolveDiagnosticTitle = (plugin, rule) => plugin === "react-hooks-js" ? REACT_COMPILER_TITLE : getRuleTitle(rule);
38492
+ const resolveDiagnosticTitle = (plugin, rule) => {
38493
+ if (plugin !== "react-hooks-js") return getRuleTitle(rule);
38494
+ return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
38495
+ };
38492
38496
  const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38493
38497
  const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
38494
38498
  return {
@@ -39247,25 +39251,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
39247
39251
  const SCORE_AXES = [
39248
39252
  {
39249
39253
  key: "supplyChain",
39250
- label: "supply chain"
39254
+ label: "supply chain",
39255
+ gates: true
39251
39256
  },
39252
39257
  {
39253
39258
  key: "vulnerability",
39254
- label: "vulnerability"
39259
+ label: "vulnerability",
39260
+ gates: true
39255
39261
  },
39256
39262
  {
39257
39263
  key: "maintenance",
39258
- label: "maintenance"
39264
+ label: "maintenance",
39265
+ gates: false
39259
39266
  },
39260
39267
  {
39261
39268
  key: "quality",
39262
- label: "quality"
39269
+ label: "quality",
39270
+ gates: false
39263
39271
  },
39264
39272
  {
39265
39273
  key: "license",
39266
- label: "license"
39274
+ label: "license",
39275
+ gates: false
39267
39276
  }
39268
39277
  ];
39278
+ const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
39279
+ const worstGatedAxis = (score) => {
39280
+ let worst = GATED_AXES[0];
39281
+ for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
39282
+ return worst;
39283
+ };
39269
39284
  const clampScore = (value) => {
39270
39285
  if (!Number.isFinite(value)) return 50;
39271
39286
  return Math.min(Math.max(value, 0), 100);
@@ -39381,15 +39396,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39381
39396
  "socket.purl": toPurl(dependency)
39382
39397
  } }));
39383
39398
  const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39384
- const buildLowScoreDiagnostic = (dependency, score, options) => {
39385
- const overall = toHundred(score.overall);
39399
+ const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
39386
39400
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
39387
39401
  return {
39388
39402
  filePath: "package.json",
39389
39403
  plugin: SUPPLY_CHAIN_PLUGIN,
39390
39404
  rule: SUPPLY_CHAIN_RULE,
39391
39405
  severity: options.severity,
39392
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket supply-chain score of ${overall}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39406
+ message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39393
39407
  help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
39394
39408
  url: packagePageUrl,
39395
39409
  line: dependency.line,
@@ -39401,7 +39415,9 @@ const buildLowScoreDiagnostic = (dependency, score, options) => {
39401
39415
  * Scores every direct dependency in the project's `package.json` against
39402
39416
  * Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
39403
39417
  * uses — no API key) and returns a diagnostic for each dependency whose
39404
- * Socket `overall` score is below the configured `minScore`.
39418
+ * worst Socket *security* axis — supply chain or vulnerability — is below
39419
+ * the configured `minScore`. The quality / maintenance / license axes are
39420
+ * reported as context but never gate (see GATED_AXES).
39405
39421
  *
39406
39422
  * Lookups run with bounded concurrency via `Effect.forEach`. The check is
39407
39423
  * total/fail-open: each per-package lookup already recovers to `null`
@@ -39419,8 +39435,9 @@ const checkSupplyChain = (input) => gen(function* () {
39419
39435
  for (let index = 0; index < dependencies.length; index += 1) {
39420
39436
  const score = scores[index];
39421
39437
  if (!score) continue;
39422
- if (toHundred(score.overall) >= options.minScore) continue;
39423
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
39438
+ const worstAxis = worstGatedAxis(score);
39439
+ if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
39440
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
39424
39441
  }
39425
39442
  return diagnostics;
39426
39443
  });
@@ -39428,7 +39445,8 @@ const checkSupplyChain = (input) => gen(function* () {
39428
39445
  * `SupplyChain` scores the project's direct dependencies against Socket.dev's
39429
39446
  * free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
39430
39447
  * (`sfw`) performs — and streams a diagnostic for each dependency whose
39431
- * Socket score falls below the configured `supplyChain.minScore`.
39448
+ * worst Socket security axis (supply chain or vulnerability) falls below
39449
+ * the configured `supplyChain.minScore`.
39432
39450
  *
39433
39451
  * Runs by default (one network request per dependency); the orchestrator
39434
39452
  * provides `layerOf([])` only when the user opts out via
@@ -41695,6 +41713,8 @@ const METRIC = {
41695
41713
  cliInvoked: "cli.invoked",
41696
41714
  cliError: "cli.error",
41697
41715
  projectDetected: "project.detected",
41716
+ projectPathSelected: "project.path_selected",
41717
+ projectConfigSelected: "project.config_selected",
41698
41718
  scanCompleted: "scan.completed",
41699
41719
  scanDuration: "scan.duration",
41700
41720
  scanPhaseDuration: "scan.phase_duration",
@@ -42038,5 +42058,5 @@ const startLanguageServer = () => {
42038
42058
  };
42039
42059
  //#endregion
42040
42060
  export { startLanguageServer };
42041
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad272c0f-4a71-56b8-8de2-799b99bcd894")}catch(e){}}();
42042
- //# debugId=ad272c0f-4a71-56b8-8de2-799b99bcd894
42061
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1e6dd9cd-7bbf-509d-9302-bdf56d4cf879")}catch(e){}}();
42062
+ //# debugId=1e6dd9cd-7bbf-509d-9302-bdf56d4cf879
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.1-dev.2f26228",
3
+ "version": "0.5.1-dev.7c88165",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -54,17 +54,17 @@
54
54
  "agent-install": "0.0.5",
55
55
  "conf": "^15.1.0",
56
56
  "confbox": "^0.2.4",
57
- "deslop-js": "^0.0.21",
57
+ "deslop-js": "^0.0.23",
58
58
  "eslint-plugin-react-hooks": "^7.1.1",
59
59
  "jiti": "^2.7.0",
60
60
  "magicast": "^0.5.3",
61
- "oxlint": "^1.66.0",
61
+ "oxlint": ">=1.66.0 <1.67.0",
62
62
  "prompts": "^2.4.2",
63
63
  "typescript": ">=5.0.4 <7",
64
64
  "vscode-languageserver": "^9.0.1",
65
65
  "vscode-languageserver-textdocument": "^1.0.12",
66
66
  "vscode-uri": "^3.1.0",
67
- "oxlint-plugin-react-doctor": "0.5.1-dev.2f26228"
67
+ "oxlint-plugin-react-doctor": "0.5.1-dev.7c88165"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",
@@ -73,8 +73,8 @@
73
73
  "commander": "^14.0.3",
74
74
  "ora": "^9.4.0",
75
75
  "@react-doctor/api": "0.5.1",
76
- "@react-doctor/core": "0.5.1",
77
- "@react-doctor/language-server": "0.5.1"
76
+ "@react-doctor/language-server": "0.5.1",
77
+ "@react-doctor/core": "0.5.1"
78
78
  },
79
79
  "engines": {
80
80
  "node": "^20.19.0 || >=22.13.0"