react-doctor 0.5.1-dev.1ca6f0e → 0.5.1-dev.2f26228

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/cli.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]="f25bdf09-ff57-565e-b47b-46ef237158c2")}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]="4db91f1b-d88c-5feb-a6d7-b4b1a94b2537")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -21009,7 +21009,7 @@ const recurDefaults = /* @__PURE__ */ memoize((ast) => {
21009
21009
  * @since 4.0.0
21010
21010
  */
21011
21011
  function makeEffect(schema) {
21012
- const parser = run$2(recurDefaults(toType(schema.ast)));
21012
+ const parser = run$1(recurDefaults(toType(schema.ast)));
21013
21013
  return (input, options) => {
21014
21014
  return parser(input, options?.disableChecks ? options?.parseOptions ? {
21015
21015
  ...options.parseOptions,
@@ -21054,7 +21054,7 @@ function make$25(schema) {
21054
21054
  }
21055
21055
  /** @internal */
21056
21056
  function _is(ast) {
21057
- const parser = asExit(run$2(toType(ast)));
21057
+ const parser = asExit(run$1(toType(ast)));
21058
21058
  return (input) => {
21059
21059
  return isSuccess(parser(input, defaultParseOptions));
21060
21060
  };
@@ -21073,7 +21073,7 @@ function _is(ast) {
21073
21073
  * @since 4.0.0
21074
21074
  */
21075
21075
  function decodeUnknownEffect(schema, options) {
21076
- const parser = run$2(schema.ast);
21076
+ const parser = run$1(schema.ast);
21077
21077
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
21078
21078
  }
21079
21079
  /**
@@ -21104,7 +21104,7 @@ function decodeUnknownOption$1(schema, options) {
21104
21104
  * @since 4.0.0
21105
21105
  */
21106
21106
  function encodeUnknownEffect(schema, options) {
21107
- const parser = run$2(flip$1(schema.ast));
21107
+ const parser = run$1(flip$1(schema.ast));
21108
21108
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
21109
21109
  }
21110
21110
  /**
@@ -21126,7 +21126,7 @@ const mergeParseOptions = (options, overrideOptions) => overrideOptions === void
21126
21126
  ...overrideOptions
21127
21127
  };
21128
21128
  /** @internal */
21129
- function run$2(ast) {
21129
+ function run$1(ast) {
21130
21130
  const parser = recur$1(ast);
21131
21131
  return (input, options) => flatMapEager(parser(some(input), options ?? defaultParseOptions), (oa) => {
21132
21132
  if (oa._tag === "None") return fail$4(new InvalidValue(oa));
@@ -28330,7 +28330,7 @@ const ensuring = /* @__PURE__ */ dual(2, (self, finalizer) => fromChannel(ensuri
28330
28330
  * @category destructors
28331
28331
  * @since 2.0.0
28332
28332
  */
28333
- const run$1 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => sink.transform(upstream, scope)), map$3(([a]) => a))));
28333
+ const run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap$2((upstream) => sink.transform(upstream, scope)), map$3(([a]) => a))));
28334
28334
  /**
28335
28335
  * Runs the stream and collects all elements into an array.
28336
28336
  *
@@ -35068,7 +35068,7 @@ const layer$3 = /* @__PURE__ */ effect(ChildProcessSpawner, /* @__PURE__ */ gen(
35068
35068
  evaluate: () => nodeStream,
35069
35069
  onError: (error) => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)
35070
35070
  });
35071
- if (config.stream) yield* forkScoped(run$1(config.stream, sink));
35071
+ if (config.stream) yield* forkScoped(run(config.stream, sink));
35072
35072
  inputSinks.set(fd, sink);
35073
35073
  break;
35074
35074
  }
@@ -35097,7 +35097,7 @@ const layer$3 = /* @__PURE__ */ effect(ChildProcessSpawner, /* @__PURE__ */ gen(
35097
35097
  endOnDone: config.endOnDone,
35098
35098
  encoding: config.encoding
35099
35099
  });
35100
- if (isStream(config.stream)) return as(forkScoped(run$1(config.stream, sink)), sink);
35100
+ if (isStream(config.stream)) return as(forkScoped(run(config.stream, sink)), sink);
35101
35101
  return succeed$2(sink);
35102
35102
  });
35103
35103
  const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {
@@ -40271,6 +40271,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
40271
40271
  }));
40272
40272
  };
40273
40273
  };
40274
+ const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
40275
+ /**
40276
+ * Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
40277
+ * each file added or modified on the new side. Files are keyed by the path in
40278
+ * the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
40279
+ * Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
40280
+ * skipped because they have no new-side line to report on.
40281
+ */
40282
+ const parseChangedLineRanges = (patch) => {
40283
+ const rangesByFile = /* @__PURE__ */ new Map();
40284
+ let currentRanges = null;
40285
+ for (const line of patch.split("\n")) {
40286
+ if (line.startsWith("+++ ")) {
40287
+ const target = line.slice(4).trim();
40288
+ if (target === "/dev/null") {
40289
+ currentRanges = null;
40290
+ continue;
40291
+ }
40292
+ const file = target.startsWith("b/") ? target.slice(2) : target;
40293
+ currentRanges = rangesByFile.get(file) ?? [];
40294
+ rangesByFile.set(file, currentRanges);
40295
+ continue;
40296
+ }
40297
+ if (currentRanges === null) continue;
40298
+ const hunk = HUNK_HEADER_PATTERN.exec(line);
40299
+ if (hunk === null) continue;
40300
+ const start = Number(hunk[1]);
40301
+ const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
40302
+ if (lineCount <= 0) continue;
40303
+ currentRanges.push([start, start + lineCount - 1]);
40304
+ }
40305
+ return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
40306
+ file,
40307
+ ranges
40308
+ }));
40309
+ };
40274
40310
  const trimOrNull = (value) => {
40275
40311
  const trimmed = value.trim();
40276
40312
  return trimmed.length === 0 ? null : trimmed;
@@ -40636,6 +40672,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
40636
40672
  status: result.status,
40637
40673
  stdout: result.stdout
40638
40674
  };
40675
+ }),
40676
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
40677
+ if (files.length === 0) return [];
40678
+ if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
40679
+ const result = yield* runGit(directory, [
40680
+ "diff",
40681
+ "--unified=0",
40682
+ "--diff-filter=ACMR",
40683
+ "--relative",
40684
+ ...cached ? ["--cached"] : [],
40685
+ ...baseRef !== void 0 ? [baseRef] : [],
40686
+ "--",
40687
+ ...files
40688
+ ]);
40689
+ if (result.status !== 0) return null;
40690
+ return parseChangedLineRanges(result.stdout);
40639
40691
  })
40640
40692
  });
40641
40693
  })).pipe(provide$2(layer$3.pipe(provide$2(mergeAll$1(layer$2, layer$1)))));
@@ -40666,7 +40718,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
40666
40718
  status: matches.length === 0 ? 1 : 0,
40667
40719
  stdout
40668
40720
  };
40669
- })
40721
+ }),
40722
+ changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
40670
40723
  }));
40671
40724
  };
40672
40725
  const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
@@ -43366,6 +43419,21 @@ const getDiffInfo = (directory, explicitBaseBranch) => runPromise(gen(function*
43366
43419
  }).pipe(provide(Git.layerNode)));
43367
43420
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
43368
43421
  /**
43422
+ * Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
43423
+ * `files` with `--unified=0` against `baseRef` (or the index when `cached`),
43424
+ * returning per-file changed line ranges relative to `directory`. Returns
43425
+ * `null` when the ranges can't be computed (git unavailable / unsafe ref /
43426
+ * non-zero exit) so the caller degrades to file-level scope; an empty array
43427
+ * means git succeeded but the files added no lines.
43428
+ */
43429
+ const getChangedLineRanges = (input) => runPromise(gen(function* () {
43430
+ const ranges = yield* (yield* Git).changedLineRanges(input);
43431
+ return ranges === null ? null : ranges.map((entry) => ({
43432
+ file: entry.file,
43433
+ ranges: entry.ranges
43434
+ }));
43435
+ }).pipe(provide(Git.layerNode)));
43436
+ /**
43369
43437
  * Canonical URL for a rule's documentation page — its reviewer-tested fix
43370
43438
  * recipe rendered for humans — served at
43371
43439
  * `https://react.doctor/docs/rules/<plugin>/<rule>`. The CLI links here
@@ -43511,6 +43579,7 @@ const isNonInteractiveEnvironment = () => NON_INTERACTIVE_ENVIRONMENT_VARIABLES.
43511
43579
  //#region src/cli/utils/constants.ts
43512
43580
  const STAGED_FILES_TEMP_DIR_PREFIX = "react-doctor-staged-";
43513
43581
  const BASELINE_FILES_TEMP_DIR_PREFIX = "react-doctor-baseline-";
43582
+ const GH_DEFAULT_BRANCH_PROBE_TIMEOUT_MS = 5e3;
43514
43583
  const CI_TRUST_COMPANIES = "PayPal, Rippling, and Alibaba";
43515
43584
  const WELCOME_EXPLANATION_HOLD_MS = 1e3;
43516
43585
  const CATEGORY_COUNTUP_SETTLE_HOLD_MS = 1e3;
@@ -43590,7 +43659,7 @@ const makeNoopConsole = () => ({
43590
43659
  });
43591
43660
  //#endregion
43592
43661
  //#region src/cli/utils/version.ts
43593
- const VERSION = "0.5.1-dev.1ca6f0e";
43662
+ const VERSION = "0.5.1-dev.2f26228";
43594
43663
  //#endregion
43595
43664
  //#region src/cli/utils/json-mode.ts
43596
43665
  let context = null;
@@ -43948,13 +44017,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
43948
44017
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
43949
44018
  * standard `SENTRY_RELEASE` override.
43950
44019
  */
43951
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.1ca6f0e`;
44020
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.2f26228`;
43952
44021
  /**
43953
44022
  * Deployment environment shown in Sentry's environment filter. Defaults to
43954
44023
  * `production` for tagged releases and `development` for dev/unbuilt versions,
43955
44024
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
43956
44025
  */
43957
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.1ca6f0e") ? "development" : "production");
44026
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.2f26228") ? "development" : "production");
43958
44027
  /**
43959
44028
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
43960
44029
  * (set to `0` to disable tracing) and falls back to
@@ -47593,6 +47662,7 @@ const buildConfigAttributes = (input) => {
47593
47662
  const ruleKeys = Object.keys(ruleOverrides);
47594
47663
  return {
47595
47664
  mode: input.mode,
47665
+ scope: input.scope,
47596
47666
  parallel: input.parallel,
47597
47667
  workerCount: input.workerCount ?? null,
47598
47668
  lint: input.lint,
@@ -47634,6 +47704,9 @@ const recordRunEvent = (rootSpan, input) => {
47634
47704
  } catch {}
47635
47705
  };
47636
47706
  //#endregion
47707
+ //#region src/cli/utils/path-format.ts
47708
+ const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
47709
+ //#endregion
47637
47710
  //#region src/cli/utils/materialize-baseline-files.ts
47638
47711
  /**
47639
47712
  * Materializes the `ref` version of `files` into `tempDirectory` (via
@@ -48796,6 +48869,7 @@ const buildScanResultCacheKey = (input) => {
48796
48869
  ignoredTags: [...input.options.ignoredTags].sort(),
48797
48870
  concurrency: input.options.concurrency,
48798
48871
  baselineRef: input.options.baseline?.ref,
48872
+ changedLineRanges: input.options.changedLineRanges ?? void 0,
48799
48873
  noScore: input.options.noScore,
48800
48874
  isCi: input.options.isCi,
48801
48875
  suppressRendering: input.options.suppressRendering,
@@ -48844,6 +48918,16 @@ const recordOnboardingCompletion = (options) => {
48844
48918
  })) markOnboardingComplete();
48845
48919
  };
48846
48920
  const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
48921
+ const buildChangedLineMatcher = (directory, changedLineRanges) => {
48922
+ const rangesByFile = /* @__PURE__ */ new Map();
48923
+ for (const entry of changedLineRanges) rangesByFile.set(toForwardSlashes(entry.file), entry.ranges);
48924
+ return (diagnostic) => {
48925
+ const relativePath = toForwardSlashes(path.isAbsolute(diagnostic.filePath) ? path.relative(directory, diagnostic.filePath) : diagnostic.filePath);
48926
+ const ranges = rangesByFile.get(relativePath);
48927
+ if (ranges === void 0) return false;
48928
+ return ranges.some(([start, end]) => diagnostic.line >= start && diagnostic.line <= end);
48929
+ };
48930
+ };
48847
48931
  const buildIgnoredTags = (userConfig) => {
48848
48932
  const tags = /* @__PURE__ */ new Set();
48849
48933
  if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
@@ -48871,9 +48955,16 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48871
48955
  suppressRendering: inputOptions.suppressRendering ?? false,
48872
48956
  concurrency: inputOptions.concurrency,
48873
48957
  baseline: inputOptions.baseline ?? null,
48958
+ changedLineRanges: inputOptions.changedLineRanges ?? null,
48874
48959
  supplyChainManifestChanged: inputOptions.supplyChainManifestChanged ?? false
48875
48960
  });
48961
+ const deriveScope = (options) => {
48962
+ if (options.baseline) return "changed";
48963
+ if (options.changedLineRanges !== null) return "lines";
48964
+ return options.includePaths.length > 0 ? "files" : "full";
48965
+ };
48876
48966
  const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
48967
+ scope: deriveScope(options),
48877
48968
  parallel: options.concurrency !== void 0,
48878
48969
  workerCount: options.concurrency,
48879
48970
  lint: options.lint,
@@ -49095,6 +49186,9 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49095
49186
  inspectDiagnostics = comparison.displayDiagnostics;
49096
49187
  baselineDelta = comparison.baselineDelta;
49097
49188
  }
49189
+ } else if (options.changedLineRanges !== null && isDiffMode) {
49190
+ const isOnChangedLine = buildChangedLineMatcher(directory, options.changedLineRanges);
49191
+ inspectDiagnostics = output.diagnostics.filter(isOnChangedLine);
49098
49192
  }
49099
49193
  const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
49100
49194
  const score = didLintFail ? null : output.score;
@@ -49691,7 +49785,7 @@ const installReactDoctorScriptStep = (projectRoot) => {
49691
49785
  };
49692
49786
  //#endregion
49693
49787
  //#region src/cli/utils/install-github-workflow.ts
49694
- const buildWorkflowContent = () => `# React Doctor — finds security, performance, correctness, accessibility,
49788
+ const buildWorkflowContent = (defaultBranch) => `# React Doctor — finds security, performance, correctness, accessibility,
49695
49789
  # bundle-size, and architecture issues in React codebases.
49696
49790
  #
49697
49791
  # Docs: https://www.react.doctor/ci
@@ -49703,9 +49797,9 @@ on:
49703
49797
  # Scans the PR's changed files and posts a sticky summary comment listing only the new issues introduced relative to the merge base of the target branch.
49704
49798
  pull_request:
49705
49799
  types: [opened, synchronize, reopened, ready_for_review]
49706
- # Scans \`main\` on every push to track the health-score trend and catch regressions that slipped past PR review.
49800
+ # Scans \`${defaultBranch}\` on every push to track the health-score trend and catch regressions that slipped past PR review.
49707
49801
  push:
49708
- branches: [main]
49802
+ branches: ["${defaultBranch}"]
49709
49803
 
49710
49804
  permissions:
49711
49805
  contents: read
@@ -49725,10 +49819,15 @@ jobs:
49725
49819
  - uses: actions/checkout@v5
49726
49820
 
49727
49821
  - uses: millionco/react-doctor@v2
49728
- # Common configuration knobs — uncomment any to override the default.
49822
+ # Advisory by default: React Doctor reports findings on every PR — a
49823
+ # sticky summary comment, inline review comments, and a commit status
49824
+ # with the health score — but never fails the check, so it won't red-X
49825
+ # a teammate's PR on day one. When your team trusts the signal, graduate
49826
+ # the gate: uncomment the block below and set blocking to "error" (fail
49827
+ # on new error-severity findings) or "warning" (fail on any finding).
49729
49828
  # Full reference: https://www.react.doctor/ci
49730
49829
  # with:
49731
- # blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
49830
+ # blocking: error # Gate level: "none" (advisory, the default) | "warning" | "error"
49732
49831
  # scope: full # On PRs, scan the whole project instead of just changed files
49733
49832
  # comment: false # Disable the sticky PR summary comment
49734
49833
  # review-comments: false # Disable inline review comments on changed lines
@@ -49760,7 +49859,7 @@ const upgradeWorkflowActionToV2 = (content) => {
49760
49859
  changed: upgraded !== content
49761
49860
  };
49762
49861
  };
49763
- const installReactDoctorWorkflow = (projectRoot) => {
49862
+ const installReactDoctorWorkflow = (projectRoot, defaultBranch = "main") => {
49764
49863
  const workflowPath = getReactDoctorWorkflowPath(projectRoot);
49765
49864
  if (NFS.existsSync(workflowPath)) return {
49766
49865
  status: "exists",
@@ -49768,7 +49867,7 @@ const installReactDoctorWorkflow = (projectRoot) => {
49768
49867
  };
49769
49868
  try {
49770
49869
  NFS.mkdirSync(Path.dirname(workflowPath), { recursive: true });
49771
- NFS.writeFileSync(workflowPath, buildWorkflowContent());
49870
+ NFS.writeFileSync(workflowPath, buildWorkflowContent(defaultBranch));
49772
49871
  return {
49773
49872
  status: "created",
49774
49873
  workflowPath
@@ -49944,19 +50043,14 @@ const askUpgradeActionVersion = async (prompt = prompts) => {
49944
50043
  return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
49945
50044
  };
49946
50045
  //#endregion
49947
- //#region src/cli/utils/open-workflow-pull-request.ts
49948
- const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
49949
- const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
49950
- const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
49951
- const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
49952
-
49953
- Docs: https://www.react.doctor/ci`;
50046
+ //#region src/cli/utils/run-command.ts
49954
50047
  const execFileAsync$1 = promisify(execFile);
49955
- const run = async (command, args, cwd) => {
50048
+ const runCommand = async (command, args, cwd, timeoutMs) => {
49956
50049
  try {
49957
50050
  const { stdout, stderr } = await execFileAsync$1(command, [...args], {
49958
50051
  cwd,
49959
- encoding: "utf8"
50052
+ encoding: "utf8",
50053
+ timeout: timeoutMs
49960
50054
  });
49961
50055
  return {
49962
50056
  success: true,
@@ -49972,7 +50066,18 @@ const run = async (command, args, cwd) => {
49972
50066
  };
49973
50067
  }
49974
50068
  };
49975
- const detectDefaultBranch = async (cwd) => {
50069
+ //#endregion
50070
+ //#region src/cli/utils/detect-default-branch.ts
50071
+ const detectDefaultBranch = async (cwd, run = runCommand) => {
50072
+ const repoView = await run("gh", [
50073
+ "repo",
50074
+ "view",
50075
+ "--json",
50076
+ "defaultBranchRef",
50077
+ "--jq",
50078
+ ".defaultBranchRef.name"
50079
+ ], cwd, GH_DEFAULT_BRANCH_PROBE_TIMEOUT_MS);
50080
+ if (repoView.success && repoView.stdout !== "" && repoView.stdout !== "null") return repoView.stdout;
49976
50081
  const symRef = await run("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], cwd);
49977
50082
  if (symRef.success) {
49978
50083
  const branchMatch = symRef.stdout.match(/refs\/remotes\/origin\/(.+)$/);
@@ -49990,8 +50095,16 @@ const detectDefaultBranch = async (cwd) => {
49990
50095
  ], cwd)).success) return "master";
49991
50096
  return null;
49992
50097
  };
50098
+ //#endregion
50099
+ //#region src/cli/utils/open-workflow-pull-request.ts
50100
+ const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
50101
+ const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
50102
+ const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
50103
+ const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
50104
+
50105
+ Docs: https://www.react.doctor/ci`;
49993
50106
  const findUniqueBranchName = async (cwd) => {
49994
- if (!(await run("git", [
50107
+ if (!(await runCommand("git", [
49995
50108
  "rev-parse",
49996
50109
  "--verify",
49997
50110
  NEW_BRANCH_PREFIX
@@ -50003,7 +50116,7 @@ const openWorkflowPullRequest = async (params) => {
50003
50116
  const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
50004
50117
  const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
50005
50118
  const prBody = params.prBody ?? DEFAULT_PR_BODY;
50006
- const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50119
+ const repoRootProbe = await runCommand("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50007
50120
  if (!repoRootProbe.success) return {
50008
50121
  status: "not-attempted",
50009
50122
  reason: "not-a-git-repo"
@@ -50013,16 +50126,16 @@ const openWorkflowPullRequest = async (params) => {
50013
50126
  status: "not-attempted",
50014
50127
  reason: "gh-not-installed"
50015
50128
  };
50016
- if (!(await run("gh", ["auth", "status"], cwd)).success) return {
50129
+ if (!(await runCommand("gh", ["auth", "status"], cwd)).success) return {
50017
50130
  status: "not-attempted",
50018
50131
  reason: "gh-not-authenticated"
50019
50132
  };
50020
- const defaultBranch = await detectDefaultBranch(cwd);
50133
+ const defaultBranch = params.baseBranch ?? await detectDefaultBranch(cwd);
50021
50134
  if (!defaultBranch) return {
50022
50135
  status: "not-attempted",
50023
50136
  reason: "no-default-branch"
50024
50137
  };
50025
- const previousBranchProbe = await run("git", [
50138
+ const previousBranchProbe = await runCommand("git", [
50026
50139
  "rev-parse",
50027
50140
  "--abbrev-ref",
50028
50141
  "HEAD"
@@ -50032,13 +50145,13 @@ const openWorkflowPullRequest = async (params) => {
50032
50145
  reason: "detached-head"
50033
50146
  };
50034
50147
  const previousBranch = previousBranchProbe.stdout;
50035
- await run("git", [
50148
+ await runCommand("git", [
50036
50149
  "fetch",
50037
50150
  "origin",
50038
50151
  defaultBranch
50039
50152
  ], cwd);
50040
50153
  const newBranch = await findUniqueBranchName(cwd);
50041
- if (!(await run("git", [
50154
+ if (!(await runCommand("git", [
50042
50155
  "checkout",
50043
50156
  "-b",
50044
50157
  newBranch,
@@ -50048,14 +50161,14 @@ const openWorkflowPullRequest = async (params) => {
50048
50161
  reason: "checkout-failed"
50049
50162
  };
50050
50163
  const restoreToPreviousBranch = async (deleteNewBranch) => {
50051
- await run("git", ["checkout", previousBranch], cwd);
50052
- if (deleteNewBranch) await run("git", [
50164
+ await runCommand("git", ["checkout", previousBranch], cwd);
50165
+ if (deleteNewBranch) await runCommand("git", [
50053
50166
  "branch",
50054
50167
  "-D",
50055
50168
  newBranch
50056
50169
  ], cwd);
50057
50170
  };
50058
- if (!(await run("git", [
50171
+ if (!(await runCommand("git", [
50059
50172
  "add",
50060
50173
  "--",
50061
50174
  Path.relative(cwd, workflowPath)
@@ -50066,7 +50179,7 @@ const openWorkflowPullRequest = async (params) => {
50066
50179
  reason: "git-add-failed"
50067
50180
  };
50068
50181
  }
50069
- if (!(await run("git", [
50182
+ if (!(await runCommand("git", [
50070
50183
  "commit",
50071
50184
  "-m",
50072
50185
  commitMessage
@@ -50077,7 +50190,7 @@ const openWorkflowPullRequest = async (params) => {
50077
50190
  reason: "git-commit-failed"
50078
50191
  };
50079
50192
  }
50080
- if (!(await run("git", [
50193
+ if (!(await runCommand("git", [
50081
50194
  "push",
50082
50195
  "-u",
50083
50196
  "origin",
@@ -50089,7 +50202,7 @@ const openWorkflowPullRequest = async (params) => {
50089
50202
  reason: "git-push-failed"
50090
50203
  };
50091
50204
  }
50092
- const prCreate = await run("gh", [
50205
+ const prCreate = await runCommand("gh", [
50093
50206
  "pr",
50094
50207
  "create",
50095
50208
  "--title",
@@ -50113,9 +50226,9 @@ const openWorkflowPullRequest = async (params) => {
50113
50226
  };
50114
50227
  const stageWorkflowFile = async (params) => {
50115
50228
  const workflowPath = Path.resolve(params.workflowPath);
50116
- const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50229
+ const repoRootProbe = await runCommand("git", ["rev-parse", "--show-toplevel"], Path.dirname(workflowPath));
50117
50230
  if (!repoRootProbe.success) return false;
50118
- return (await run("git", [
50231
+ return (await runCommand("git", [
50119
50232
  "add",
50120
50233
  "--",
50121
50234
  Path.relative(repoRootProbe.stdout, workflowPath)
@@ -50144,7 +50257,8 @@ const setUpGitHubActions = async (options) => {
50144
50257
  installReactDoctorScriptStep(projectRoot);
50145
50258
  } catch {}
50146
50259
  const workflowSpinner = spinner("Adding GitHub Actions workflow...").start();
50147
- const workflowResult = installReactDoctorWorkflow(projectRoot);
50260
+ const defaultBranch = await detectDefaultBranch(projectRoot) ?? "main";
50261
+ const workflowResult = installReactDoctorWorkflow(projectRoot, defaultBranch);
50148
50262
  const didCreateWorkflow = reportWorkflowResult(workflowSpinner, workflowResult, projectRoot);
50149
50263
  cliLogger.break();
50150
50264
  if (workflowResult.status === "failed") {
@@ -50153,7 +50267,10 @@ const setUpGitHubActions = async (options) => {
50153
50267
  }
50154
50268
  if (workflowResult.status === "created") {
50155
50269
  const pullRequestSpinner = spinner("Opening a pull request for review...").start();
50156
- const pullRequestResult = await openWorkflowPullRequest({ workflowPath: workflowResult.workflowPath });
50270
+ const pullRequestResult = await openWorkflowPullRequest({
50271
+ workflowPath: workflowResult.workflowPath,
50272
+ baseBranch: defaultBranch
50273
+ });
50157
50274
  if (pullRequestResult.status === "pr-opened") pullRequestSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
50158
50275
  else if (pullRequestResult.status === "branch-pushed") pullRequestSpinner.warn(`Pushed branch ${highlighter.bold(pullRequestResult.branch)} but couldn't open a PR. Open one with: gh pr create --head ${pullRequestResult.branch}`);
50159
50276
  else {
@@ -50994,8 +51111,8 @@ const installReactDoctorAgentHooksStep = (projectRoot, selectedAgents) => {
50994
51111
  throw error;
50995
51112
  }
50996
51113
  };
50997
- const installReactDoctorWorkflowStep = (projectRoot) => {
50998
- return reportWorkflowResult(spinner("Adding GitHub Actions workflow...").start(), installReactDoctorWorkflow(projectRoot), projectRoot);
51114
+ const installReactDoctorWorkflowStep = async (projectRoot) => {
51115
+ return reportWorkflowResult(spinner("Adding GitHub Actions workflow...").start(), installReactDoctorWorkflow(projectRoot, await detectDefaultBranch(projectRoot) ?? void 0), projectRoot);
50999
51116
  };
51000
51117
  const upgradeReactDoctorWorkflowStep = (projectRoot) => {
51001
51118
  const workflowSpinner = spinner("Upgrading GitHub Actions workflow to v2...").start();
@@ -51063,7 +51180,7 @@ const runInstallReactDoctor = async (options = {}) => {
51063
51180
  let didInstallWorkflow = false;
51064
51181
  if (!options.dryRun && (shouldInstallWorkflow || shouldUpgradeWorkflow)) {
51065
51182
  cliLogger.break();
51066
- if (shouldInstallWorkflow) didInstallWorkflow = installReactDoctorWorkflowStep(projectRoot);
51183
+ if (shouldInstallWorkflow) didInstallWorkflow = await installReactDoctorWorkflowStep(projectRoot);
51067
51184
  else if (upgradeReactDoctorWorkflowStep(projectRoot)) recordActionUpgradeDecision(projectRoot, "accepted");
51068
51185
  }
51069
51186
  const setupActionChoices = [...gitHookPath === null || gitHookPath === void 0 ? [] : [{
@@ -51530,9 +51647,6 @@ const reportErrorToSentry = async (error) => {
51530
51647
  }
51531
51648
  };
51532
51649
  //#endregion
51533
- //#region src/cli/utils/path-format.ts
51534
- const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
51535
- //#endregion
51536
51650
  //#region src/cli/utils/read-changed-files-from.ts
51537
51651
  const isSafeRelativePath = (filePath) => {
51538
51652
  if (filePath.length === 0) return false;
@@ -51729,22 +51843,101 @@ const resolveCliInspectOptions = (flags, userConfig) => {
51729
51843
  };
51730
51844
  };
51731
51845
  //#endregion
51732
- //#region src/cli/utils/resolve-diff-mode.ts
51733
- const resolveDiffMode = async (diffInfo, effectiveDiff, shouldSkipPrompts, isQuiet) => {
51734
- if (effectiveDiff !== void 0 && effectiveDiff !== false) {
51735
- if (diffInfo) return true;
51736
- if (!isQuiet) {
51737
- if (typeof effectiveDiff === "string") cliLogger.warn(`Could not compute diff against "${effectiveDiff}" (merge-base failed or HEAD has no history). Running full scan.`);
51738
- else cliLogger.warn("No feature branch or uncommitted changes detected. Running full scan.");
51739
- cliLogger.break();
51740
- }
51741
- return false;
51846
+ //#region src/cli/utils/resolve-scope.ts
51847
+ const SCOPE_VALUES = new Set([
51848
+ "full",
51849
+ "files",
51850
+ "changed",
51851
+ "lines"
51852
+ ]);
51853
+ const isScopeValue = (value) => SCOPE_VALUES.has(value);
51854
+ const coerceDeprecatedDiff = (value) => {
51855
+ if (value === void 0) return void 0;
51856
+ if (value === false || value === "false") return { scope: "full" };
51857
+ if (value === true || value === "true") return { scope: "changed" };
51858
+ if (value === "") return void 0;
51859
+ return {
51860
+ scope: "changed",
51861
+ base: value
51862
+ };
51863
+ };
51864
+ /**
51865
+ * Resolves the *requested* scope from flags + config without touching git.
51866
+ * Precedence mirrors `pickBlockingLevel`: flags win over config, and the new
51867
+ * `--scope` wins over the deprecated `--diff` alias on each side
51868
+ * (`flags.scope` > `flags.diff` > `config.scope` > `config.diff`). Returns
51869
+ * `scope: undefined` when nothing is set so the caller can default to `full`
51870
+ * or offer the interactive prompt.
51871
+ */
51872
+ const resolveScope = (flags, userConfig) => {
51873
+ const base = flags.base ?? userConfig?.base;
51874
+ if (typeof flags.scope === "string" && flags.scope.length > 0) {
51875
+ if (isScopeValue(flags.scope)) return {
51876
+ scope: flags.scope,
51877
+ base,
51878
+ usedDeprecatedDiff: false
51879
+ };
51880
+ cliLogger.warn(`Invalid --scope "${flags.scope}". Expected one of: full, files, changed, lines. Ignoring.`);
51742
51881
  }
51743
- if (effectiveDiff === false || !diffInfo) return false;
51744
- const changedSourceFiles = filterSourceFiles(diffInfo.changedFiles);
51745
- if (changedSourceFiles.length === 0) return false;
51746
- if (shouldSkipPrompts) return false;
51747
- if (isQuiet) return false;
51882
+ const flagDiff = coerceDeprecatedDiff(flags.diff);
51883
+ if (flagDiff !== void 0) return {
51884
+ scope: flagDiff.scope,
51885
+ base: base ?? flagDiff.base,
51886
+ usedDeprecatedDiff: true
51887
+ };
51888
+ if (userConfig?.scope !== void 0) {
51889
+ if (isScopeValue(userConfig.scope)) return {
51890
+ scope: userConfig.scope,
51891
+ base,
51892
+ usedDeprecatedDiff: false
51893
+ };
51894
+ cliLogger.warn(`Invalid scope "${userConfig.scope}" in config. Expected one of: full, files, changed, lines. Ignoring.`);
51895
+ }
51896
+ const configDiff = coerceDeprecatedDiff(userConfig?.diff);
51897
+ if (configDiff !== void 0) return {
51898
+ scope: configDiff.scope,
51899
+ base: base ?? configDiff.base,
51900
+ usedDeprecatedDiff: true
51901
+ };
51902
+ return {
51903
+ scope: void 0,
51904
+ base,
51905
+ usedDeprecatedDiff: false
51906
+ };
51907
+ };
51908
+ const warnDeprecatedDiff = (flags, userConfig) => {
51909
+ const usedFlag = flags.diff !== void 0;
51910
+ if (!usedFlag && userConfig?.diff === void 0) return;
51911
+ const targetScope = coerceDeprecatedDiff(usedFlag ? flags.diff : userConfig?.diff)?.scope ?? "changed";
51912
+ if (usedFlag) {
51913
+ const baseHint = targetScope === "changed" ? " (add `--base <ref>` to pin the base)" : "";
51914
+ cliLogger.warn(`The \`--diff\` flag is deprecated; use \`--scope ${targetScope}\`${baseHint} instead.`);
51915
+ return;
51916
+ }
51917
+ cliLogger.warn(`The \`diff\` config option is deprecated; use \`scope: "${targetScope}"\` instead.`);
51918
+ };
51919
+ const warnDiffUnavailable = (requested, isQuiet) => {
51920
+ if (isQuiet) return;
51921
+ if (typeof requested.base === "string") cliLogger.warn(`Could not compute diff against "${requested.base}" (merge-base failed or HEAD has no history). Running full scan.`);
51922
+ else cliLogger.warn("No feature branch or uncommitted changes detected. Running full scan.");
51923
+ cliLogger.break();
51924
+ };
51925
+ /**
51926
+ * Resolves the requested scope against the detected diff into the final scope.
51927
+ * An explicit non-`full` scope needs a usable `diffInfo`; without one it warns
51928
+ * and falls back to `full`. When nothing was requested, an interactive run on a
51929
+ * branch with changed source files is offered the "full vs changed" prompt.
51930
+ */
51931
+ const finalizeScope = async ({ requested, diffInfo, skipPrompts, isQuiet }) => {
51932
+ if (requested.scope !== void 0) {
51933
+ if (requested.scope === "full") return "full";
51934
+ if (diffInfo !== null) return requested.scope;
51935
+ warnDiffUnavailable(requested, isQuiet);
51936
+ return "full";
51937
+ }
51938
+ if (diffInfo === null || skipPrompts || isQuiet) return "full";
51939
+ const changedSourceFiles = filterSourceFiles([...diffInfo.changedFiles]);
51940
+ if (changedSourceFiles.length === 0) return "full";
51748
51941
  const { scanScope } = await prompts({
51749
51942
  type: "select",
51750
51943
  name: "scanScope",
@@ -51756,29 +51949,13 @@ const resolveDiffMode = async (diffInfo, effectiveDiff, shouldSkipPrompts, isQui
51756
51949
  }, {
51757
51950
  title: diffInfo.isCurrentChanges ? `Uncommitted changes (${changedSourceFiles.length})` : `Changed files on ${diffInfo.currentBranch ?? "this branch"} (${changedSourceFiles.length})`,
51758
51951
  description: diffInfo.isCurrentChanges ? "Compare working tree changes against HEAD" : `Compare against ${diffInfo.baseBranch} from the branch merge-base`,
51759
- value: "branch"
51952
+ value: "changed"
51760
51953
  }],
51761
51954
  initial: diffInfo.isCurrentChanges ? 0 : 1
51762
51955
  });
51763
- return scanScope === "branch";
51764
- };
51765
- //#endregion
51766
- //#region src/cli/utils/coerce-diff-value.ts
51767
- const coerceDiffValue = (value) => {
51768
- if (value === void 0) return void 0;
51769
- if (typeof value === "boolean") return value;
51770
- if (typeof value === "string") {
51771
- if (value.length === 0) return void 0;
51772
- if (value === "false") return false;
51773
- if (value === "true") return true;
51774
- return value;
51775
- }
51776
- process.stderr.write(`[react-doctor] invalid diff value (expected boolean or string): ${typeof value}. Falling back to no diff.\n`);
51956
+ return scanScope === "changed" ? "changed" : "full";
51777
51957
  };
51778
51958
  //#endregion
51779
- //#region src/cli/utils/resolve-effective-diff.ts
51780
- const resolveEffectiveDiff = (flags, userConfig) => coerceDiffValue(flags.diff ?? userConfig?.diff);
51781
- //#endregion
51782
51959
  //#region src/cli/utils/resolve-project-relative-directory.ts
51783
51960
  /**
51784
51961
  * The scanned project's directory relative to the diff root, forward-slashed —
@@ -51809,6 +51986,30 @@ const resolveProjectDiffIncludePaths = (rootDirectory, projectDirectory, diffInf
51809
51986
  return projectRelativePath.length > 0 ? [projectRelativePath] : [];
51810
51987
  });
51811
51988
  };
51989
+ /**
51990
+ * Re-keys repo-relative changed line ranges (from `getChangedLineRanges`) to
51991
+ * the scanned project, mirroring `resolveProjectDiffIncludePaths`'s boundary
51992
+ * rule so the `lines` scope filter inside `inspect()` matches the project-
51993
+ * relative diagnostic paths. Files outside the project are dropped.
51994
+ */
51995
+ const resolveProjectChangedLineRanges = (rootDirectory, projectDirectory, ranges) => {
51996
+ const relativeProjectDirectory = resolveProjectRelativeDirectory(rootDirectory, projectDirectory);
51997
+ if (relativeProjectDirectory === null) return [];
51998
+ if (relativeProjectDirectory.length === 0) return ranges.map((entry) => ({
51999
+ file: toForwardSlashes(entry.file),
52000
+ ranges: entry.ranges
52001
+ }));
52002
+ const projectPrefix = `${relativeProjectDirectory}/`;
52003
+ return ranges.flatMap((entry) => {
52004
+ const normalizedFilePath = toForwardSlashes(entry.file);
52005
+ if (!normalizedFilePath.startsWith(projectPrefix)) return [];
52006
+ const projectRelativePath = normalizedFilePath.slice(projectPrefix.length);
52007
+ return projectRelativePath.length > 0 ? [{
52008
+ file: projectRelativePath,
52009
+ ranges: entry.ranges
52010
+ }] : [];
52011
+ });
52012
+ };
51812
52013
  //#endregion
51813
52014
  //#region src/cli/utils/build-diagnostic-issue-url.ts
51814
52015
  const formatRuleIdentifier = (diagnostic) => `${diagnostic.plugin}/${diagnostic.rule}`;
@@ -52041,10 +52242,12 @@ const warnDeprecatedFailOn = (flags, userConfig) => {
52041
52242
  };
52042
52243
  //#endregion
52043
52244
  //#region src/cli/utils/validate-mode-flags.ts
52245
+ const usedDiffAlias = (flags) => flags.diff !== void 0 && flags.diff !== false && flags.diff !== "false" && flags.diff !== "";
52246
+ const usedScope = (flags) => typeof flags.scope === "string" && flags.scope.length > 0;
52044
52247
  const validateModeFlags = (flags) => {
52045
- const coercedDiff = coerceDiffValue(flags.diff);
52046
- const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
52047
- if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
52248
+ if (usedScope(flags) && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --scope and --diff; --diff is the deprecated alias.");
52249
+ if (flags.staged && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --staged and --diff; pick one mode.");
52250
+ if (flags.staged && (flags.scope === "full" || flags.scope === "changed")) throw new CliInputError(`Cannot combine --staged with --scope ${flags.scope}; use --scope files or --scope lines, or drop --scope.`);
52048
52251
  if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
52049
52252
  if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
52050
52253
  if (flags.sfw) {
@@ -52052,7 +52255,8 @@ const validateModeFlags = (flags) => {
52052
52255
  flags.json ? "--json" : null,
52053
52256
  flags.score ? "--score" : null,
52054
52257
  flags.staged ? "--staged" : null,
52055
- coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null
52258
+ usedScope(flags) ? "--scope" : null,
52259
+ usedDiffAlias(flags) ? "--diff" : null
52056
52260
  ].find((name) => name !== null);
52057
52261
  if (conflictingFlag) throw new CliInputError(`Cannot combine --sfw with ${conflictingFlag}; --sfw is a standalone demo listing.`);
52058
52262
  }
@@ -52148,6 +52352,7 @@ const inspectAction = async (directory, flags) => {
52148
52352
  const resolvedDirectory = scanTarget.resolvedDirectory;
52149
52353
  setJsonReportDirectory(resolvedDirectory);
52150
52354
  warnDeprecatedFailOn(flags, userConfig);
52355
+ warnDeprecatedDiff(flags, userConfig);
52151
52356
  if (scanTarget.didRedirectViaRootDir && !isQuiet) {
52152
52357
  cliLogger.dim(`Redirected to ${highlighter.info(toRelativePath(resolvedDirectory, requestedDirectory))} via react-doctor config "rootDir".`);
52153
52358
  cliLogger.break();
@@ -52209,11 +52414,22 @@ const inspectAction = async (directory, flags) => {
52209
52414
  });
52210
52415
  throw error;
52211
52416
  });
52417
+ const stagedWantsLines = resolveScope(flags, userConfig).scope === "lines";
52418
+ const stagedLineRanges = stagedWantsLines ? await getChangedLineRanges({
52419
+ directory: resolvedDirectory,
52420
+ cached: true,
52421
+ files: snapshot.stagedFiles
52422
+ }) : null;
52423
+ if (stagedWantsLines && stagedLineRanges === null && !isQuiet) {
52424
+ cliLogger.warn("Could not determine staged changed lines; reporting all issues in staged files.");
52425
+ cliLogger.break();
52426
+ }
52212
52427
  try {
52213
52428
  const scanResult = await inspect(snapshot.tempDirectory, {
52214
52429
  ...scanOptions,
52215
52430
  includePaths: snapshot.stagedFiles,
52216
- configOverride: userConfig
52431
+ configOverride: userConfig,
52432
+ changedLineRanges: stagedLineRanges ?? void 0
52217
52433
  });
52218
52434
  const remappedDiagnostics = scanResult.diagnostics.map((diagnostic) => ({
52219
52435
  ...diagnostic,
@@ -52250,10 +52466,33 @@ const inspectAction = async (directory, flags) => {
52250
52466
  }
52251
52467
  const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
52252
52468
  const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
52253
- const effectiveDiff = resolveEffectiveDiff(flags, userConfig);
52254
- const diffInfo = changedFilesDiffInfo ?? (changedFilesDiffInfo === null && (effectiveDiff !== void 0 && effectiveDiff !== false || !skipPrompts && !isQuiet) ? await getDiffInfo(resolvedDirectory, typeof effectiveDiff === "string" ? effectiveDiff : void 0) : null);
52255
- const isDiffMode = changedFilesDiffInfo !== null || await resolveDiffMode(diffInfo, effectiveDiff, skipPrompts, isQuiet);
52256
- const baselineRef = isDiffMode && diffInfo && !diffInfo.isCurrentChanges ? diffInfo.baseSha ? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseSha) : diffInfo.diffBaseRef ?? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseBranch) : null;
52469
+ const requestedScope = resolveScope(flags, userConfig);
52470
+ const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
52471
+ ...requestedScope,
52472
+ scope: "changed"
52473
+ } : requestedScope;
52474
+ const wantsDiffMode = scopeRequest.scope !== void 0 && scopeRequest.scope !== "full";
52475
+ const shouldDetectDiff = changedFilesDiffInfo === null && (wantsDiffMode || scopeRequest.scope === void 0 && !skipPrompts && !isQuiet);
52476
+ const diffInfo = changedFilesDiffInfo ?? (shouldDetectDiff ? await getDiffInfo(resolvedDirectory, scopeRequest.base) : null);
52477
+ const scope = await finalizeScope({
52478
+ requested: scopeRequest,
52479
+ diffInfo,
52480
+ skipPrompts,
52481
+ isQuiet
52482
+ });
52483
+ const isDiffMode = scope !== "full";
52484
+ const comparisonBaseRef = isDiffMode && diffInfo && !diffInfo.isCurrentChanges ? diffInfo.baseSha ? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseSha) : diffInfo.diffBaseRef ?? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseBranch) : null;
52485
+ const baselineRef = scope === "changed" ? comparisonBaseRef : null;
52486
+ const linesBaseRef = diffInfo?.isCurrentChanges ? "HEAD" : comparisonBaseRef;
52487
+ const changedLineRanges = scope === "lines" && diffInfo !== null && (diffInfo.isCurrentChanges || linesBaseRef !== null) && diffInfo !== null ? await getChangedLineRanges({
52488
+ directory: resolvedDirectory,
52489
+ baseRef: linesBaseRef ?? void 0,
52490
+ files: [...diffInfo.changedFiles]
52491
+ }) : null;
52492
+ if (scope === "lines" && changedLineRanges === null && !isQuiet) {
52493
+ cliLogger.warn("Could not determine changed lines (no base ref or git diff failed); reporting all issues in changed files.");
52494
+ cliLogger.break();
52495
+ }
52257
52496
  setJsonReportMode(baselineRef ? "baseline" : isDiffMode ? "diff" : "full");
52258
52497
  if (isDiffMode && diffInfo && !isQuiet) {
52259
52498
  if (diffInfo.isCurrentChanges) cliLogger.log("Scanning uncommitted changes");
@@ -52290,6 +52529,7 @@ const inspectAction = async (directory, flags) => {
52290
52529
  configOverride: userConfig,
52291
52530
  suppressRendering: isMultiProject,
52292
52531
  baseline: baselineRef ? { ref: baselineRef } : void 0,
52532
+ changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, projectDirectory, changedLineRanges) : void 0,
52293
52533
  supplyChainManifestChanged
52294
52534
  });
52295
52535
  allDiagnostics.push(...scanResult.diagnostics);
@@ -52315,7 +52555,7 @@ const inspectAction = async (directory, flags) => {
52315
52555
  completedScans,
52316
52556
  mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
52317
52557
  diff: isDiffMode ? diffInfo : null,
52318
- baselineIntended: isDiffMode && diffInfo !== null && !diffInfo.isCurrentChanges,
52558
+ baselineIntended: scope === "changed" && diffInfo !== null && !diffInfo.isCurrentChanges,
52319
52559
  isJsonMode,
52320
52560
  isScoreOnly,
52321
52561
  flags,
@@ -53122,11 +53362,13 @@ const ROOT_FLAG_SPEC = {
53122
53362
  "--yes"
53123
53363
  ]),
53124
53364
  longOptionsWithRequiredValues: new Set([
53365
+ "--base",
53125
53366
  "--category",
53126
53367
  "--changed-files-from",
53127
53368
  "--blocking",
53128
53369
  "--fail-on",
53129
- "--project"
53370
+ "--project",
53371
+ "--scope"
53130
53372
  ]),
53131
53373
  longOptionsWithOptionalValues: new Set(["--diff"]),
53132
53374
  shortOptionsWithoutValues: new Set([
@@ -53309,7 +53551,7 @@ ${highlighter.dim("Learn more:")}
53309
53551
  ${highlighter.info(CANONICAL_GITHUB_URL)}
53310
53552
  `;
53311
53553
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
53312
- const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53554
+ const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53313
53555
  program.action(inspectAction);
53314
53556
  program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select workspace project (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
53315
53557
  program.command("install").alias("setup").description("Install the react-doctor skill into your coding agents and optional git hook").option("-y, --yes", "skip prompts, install for all detected agents").option("--dry-run", "show what would be installed without writing files").option("--agent-hooks", "install native non-blocking agent hooks for Claude Code and Cursor").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderInstallHelpEpilog).action(installAction);
@@ -53352,4 +53594,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53352
53594
  export {};
53353
53595
 
53354
53596
  //# sourceMappingURL=cli.js.map
53355
- //# debugId=f25bdf09-ff57-565e-b47b-46ef237158c2
53597
+ //# debugId=4db91f1b-d88c-5feb-a6d7-b4b1a94b2537
package/dist/index.d.ts CHANGED
@@ -8989,6 +8989,20 @@ declare namespace Annotations {
8989
8989
  * - `"none"` — never block; the scan is advisory (still reports + scores).
8990
8990
  */
8991
8991
  type BlockingLevel = "error" | "warning" | "none";
8992
+ /**
8993
+ * How much of the project a scan looks at and reports on — the single knob the
8994
+ * CLI `--scope` flag, the GitHub Action `scope` input, and this config field
8995
+ * all share. Ordered widest to narrowest:
8996
+ *
8997
+ * - `"full"` — whole project, every issue (the default). Whole-project checks
8998
+ * (dead-code, environment, supply-chain) run only at this scope.
8999
+ * - `"files"` — only the files changed vs the base, with ALL issues in them
9000
+ * (no compare-to-main). What `--staged` and an uncommitted `--diff` do today.
9001
+ * - `"changed"` — only issues the change INTRODUCED vs the base (the baseline
9002
+ * delta). What `--diff <base>` and the action's `scope: changed` do today.
9003
+ * - `"lines"` — only issues on the lines the change actually touched.
9004
+ */
9005
+ type ScopeValue = "full" | "files" | "changed" | "lines";
8992
9006
  interface ReactDoctorIgnoreOverride {
8993
9007
  /** Glob patterns the override applies to (e.g. `["src/legacy/**"]`). */
8994
9008
  files: string[];
@@ -9166,6 +9180,23 @@ interface ReactDoctorConfig {
9166
9180
  * `rules` / `categories`) still shows even when `warnings` is `false`.
9167
9181
  */
9168
9182
  warnings?: boolean;
9183
+ /**
9184
+ * Scan scope. Defaults to `"full"`. See `ScopeValue` for the four values.
9185
+ * The CLI `--scope` flag and the GitHub Action `scope` input set the same
9186
+ * thing; flags win over config.
9187
+ */
9188
+ scope?: ScopeValue;
9189
+ /**
9190
+ * Base git ref the `"files"` / `"changed"` / `"lines"` scopes compare
9191
+ * against. Auto-detected from the default branch / merge-base when unset.
9192
+ */
9193
+ base?: string;
9194
+ /**
9195
+ * @deprecated Use `scope` instead. Still honored as an alias when `scope`
9196
+ * is unset: `diff: "<base>"` / `diff: true` → `scope: "changed"`,
9197
+ * `diff: false` → `scope: "full"`. Using it emits a one-time deprecation
9198
+ * warning. Prefer `scope` (+ `base`).
9199
+ */
9169
9200
  diff?: boolean | string;
9170
9201
  /**
9171
9202
  * Severity threshold at which the scan blocks CI (exits non-zero).
@@ -9969,8 +10000,15 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
9969
10000
  * `GitBaseBranchMissing`) as clean user errors instead of crashes.
9970
10001
  */
9971
10002
  declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
9972
- declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
9973
- //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/types.d.ts
10003
+ declare const filterSourceFiles: (filePaths: string[]) => string[];
10004
+ /**
10005
+ * Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
10006
+ * `files` with `--unified=0` against `baseRef` (or the index when `cached`),
10007
+ * returning per-file changed line ranges relative to `directory`. Returns
10008
+ * `null` when the ranges can't be computed (git unavailable / unsafe ref /
10009
+ * non-zero exit) so the caller degrades to file-level scope; an empty array
10010
+ * means git succeeded but the files added no lines.
10011
+ */
9974
10012
  //#endregion
9975
10013
  //#region src/summarize-diagnostics.d.ts
9976
10014
  declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
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]="a4054417-b813-5ebe-8feb-dce2d3571fbc")}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]="dc9a4bab-aa8a-5831-97ae-77b1f28179d6")}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";
@@ -37034,6 +37034,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
37034
37034
  }));
37035
37035
  };
37036
37036
  };
37037
+ const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
37038
+ /**
37039
+ * Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
37040
+ * each file added or modified on the new side. Files are keyed by the path in
37041
+ * the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
37042
+ * Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
37043
+ * skipped because they have no new-side line to report on.
37044
+ */
37045
+ const parseChangedLineRanges = (patch) => {
37046
+ const rangesByFile = /* @__PURE__ */ new Map();
37047
+ let currentRanges = null;
37048
+ for (const line of patch.split("\n")) {
37049
+ if (line.startsWith("+++ ")) {
37050
+ const target = line.slice(4).trim();
37051
+ if (target === "/dev/null") {
37052
+ currentRanges = null;
37053
+ continue;
37054
+ }
37055
+ const file = target.startsWith("b/") ? target.slice(2) : target;
37056
+ currentRanges = rangesByFile.get(file) ?? [];
37057
+ rangesByFile.set(file, currentRanges);
37058
+ continue;
37059
+ }
37060
+ if (currentRanges === null) continue;
37061
+ const hunk = HUNK_HEADER_PATTERN.exec(line);
37062
+ if (hunk === null) continue;
37063
+ const start = Number(hunk[1]);
37064
+ const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
37065
+ if (lineCount <= 0) continue;
37066
+ currentRanges.push([start, start + lineCount - 1]);
37067
+ }
37068
+ return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
37069
+ file,
37070
+ ranges
37071
+ }));
37072
+ };
37037
37073
  const trimOrNull = (value) => {
37038
37074
  const trimmed = value.trim();
37039
37075
  return trimmed.length === 0 ? null : trimmed;
@@ -37399,6 +37435,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
37399
37435
  status: result.status,
37400
37436
  stdout: result.stdout
37401
37437
  };
37438
+ }),
37439
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
37440
+ if (files.length === 0) return [];
37441
+ if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
37442
+ const result = yield* runGit(directory, [
37443
+ "diff",
37444
+ "--unified=0",
37445
+ "--diff-filter=ACMR",
37446
+ "--relative",
37447
+ ...cached ? ["--cached"] : [],
37448
+ ...baseRef !== void 0 ? [baseRef] : [],
37449
+ "--",
37450
+ ...files
37451
+ ]);
37452
+ if (result.status !== 0) return null;
37453
+ return parseChangedLineRanges(result.stdout);
37402
37454
  })
37403
37455
  });
37404
37456
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
@@ -37429,7 +37481,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
37429
37481
  status: matches.length === 0 ? 1 : 0,
37430
37482
  stdout
37431
37483
  };
37432
- })
37484
+ }),
37485
+ changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
37433
37486
  }));
37434
37487
  };
37435
37488
  const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
@@ -40107,4 +40160,4 @@ const toJsonReport = (result, options) => buildJsonReport({
40107
40160
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
40108
40161
 
40109
40162
  //# sourceMappingURL=index.js.map
40110
- //# debugId=a4054417-b813-5ebe-8feb-dce2d3571fbc
40163
+ //# debugId=dc9a4bab-aa8a-5831-97ae-77b1f28179d6
package/dist/lsp.js CHANGED
@@ -37020,6 +37020,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
37020
37020
  }));
37021
37021
  };
37022
37022
  };
37023
+ const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
37024
+ /**
37025
+ * Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
37026
+ * each file added or modified on the new side. Files are keyed by the path in
37027
+ * the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
37028
+ * Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
37029
+ * skipped because they have no new-side line to report on.
37030
+ */
37031
+ const parseChangedLineRanges = (patch) => {
37032
+ const rangesByFile = /* @__PURE__ */ new Map();
37033
+ let currentRanges = null;
37034
+ for (const line of patch.split("\n")) {
37035
+ if (line.startsWith("+++ ")) {
37036
+ const target = line.slice(4).trim();
37037
+ if (target === "/dev/null") {
37038
+ currentRanges = null;
37039
+ continue;
37040
+ }
37041
+ const file = target.startsWith("b/") ? target.slice(2) : target;
37042
+ currentRanges = rangesByFile.get(file) ?? [];
37043
+ rangesByFile.set(file, currentRanges);
37044
+ continue;
37045
+ }
37046
+ if (currentRanges === null) continue;
37047
+ const hunk = HUNK_HEADER_PATTERN.exec(line);
37048
+ if (hunk === null) continue;
37049
+ const start = Number(hunk[1]);
37050
+ const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
37051
+ if (lineCount <= 0) continue;
37052
+ currentRanges.push([start, start + lineCount - 1]);
37053
+ }
37054
+ return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
37055
+ file,
37056
+ ranges
37057
+ }));
37058
+ };
37023
37059
  const trimOrNull = (value) => {
37024
37060
  const trimmed = value.trim();
37025
37061
  return trimmed.length === 0 ? null : trimmed;
@@ -37385,6 +37421,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
37385
37421
  status: result.status,
37386
37422
  stdout: result.stdout
37387
37423
  };
37424
+ }),
37425
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
37426
+ if (files.length === 0) return [];
37427
+ if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
37428
+ const result = yield* runGit(directory, [
37429
+ "diff",
37430
+ "--unified=0",
37431
+ "--diff-filter=ACMR",
37432
+ "--relative",
37433
+ ...cached ? ["--cached"] : [],
37434
+ ...baseRef !== void 0 ? [baseRef] : [],
37435
+ "--",
37436
+ ...files
37437
+ ]);
37438
+ if (result.status !== 0) return null;
37439
+ return parseChangedLineRanges(result.stdout);
37388
37440
  })
37389
37441
  });
37390
37442
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
@@ -37415,7 +37467,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
37415
37467
  status: matches.length === 0 ? 1 : 0,
37416
37468
  stdout
37417
37469
  };
37418
- })
37470
+ }),
37471
+ changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
37419
37472
  }));
37420
37473
  };
37421
37474
  const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
@@ -41985,5 +42038,5 @@ const startLanguageServer = () => {
41985
42038
  };
41986
42039
  //#endregion
41987
42040
  export { startLanguageServer };
41988
- !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]="217c2f1d-b087-575b-ba00-b912f07ad825")}catch(e){}}();
41989
- //# debugId=217c2f1d-b087-575b-ba00-b912f07ad825
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
@@ -10,13 +10,13 @@ Scans React codebases for security, performance, correctness, and architecture i
10
10
 
11
11
  ## After making React code changes:
12
12
 
13
- Run `npx react-doctor@latest --verbose --diff` and check the score did not regress.
13
+ Run `npx react-doctor@latest --verbose --scope changed` and check the score did not regress.
14
14
 
15
15
  If the score dropped, fix the regressions before committing.
16
16
 
17
17
  ## For general cleanup or code improvement:
18
18
 
19
- Run `npx react-doctor@latest --verbose` (without `--diff`) to scan the full codebase. Fix issues by severity — errors first, then warnings.
19
+ Run `npx react-doctor@latest --verbose` (the default `--scope full`) to scan the full codebase. Fix issues by severity — errors first, then warnings.
20
20
 
21
21
  ## /doctor — full local triage workflow
22
22
 
@@ -39,12 +39,13 @@ When the user wants to understand a rule, disagrees with one, or wants to disabl
39
39
  ## Command
40
40
 
41
41
  ```bash
42
- npx react-doctor@latest --verbose --diff
42
+ npx react-doctor@latest --verbose --scope changed
43
43
  ```
44
44
 
45
- | Flag | Purpose |
46
- | ----------- | --------------------------------------------- |
47
- | `.` | Scan current directory |
48
- | `--verbose` | Show affected files and line numbers per rule |
49
- | `--diff` | Only scan changed files vs base branch |
50
- | `--score` | Output only the numeric score |
45
+ | Flag | Purpose |
46
+ | ----------------- | ---------------------------------------------------------------- |
47
+ | `.` | Scan current directory |
48
+ | `--verbose` | Show affected files and line numbers per rule |
49
+ | `--scope changed` | Only report issues introduced vs the base branch (default: full) |
50
+ | `--scope lines` | Only report issues on the changed lines |
51
+ | `--score` | Output only the numeric score |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.1-dev.1ca6f0e",
3
+ "version": "0.5.1-dev.2f26228",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -64,7 +64,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.1ca6f0e"
67
+ "oxlint-plugin-react-doctor": "0.5.1-dev.2f26228"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",
@@ -72,12 +72,12 @@
72
72
  "@xterm/headless": "^6.0.0",
73
73
  "commander": "^14.0.3",
74
74
  "ora": "^9.4.0",
75
+ "@react-doctor/api": "0.5.1",
75
76
  "@react-doctor/core": "0.5.1",
76
- "@react-doctor/language-server": "0.5.1",
77
- "@react-doctor/api": "0.5.1"
77
+ "@react-doctor/language-server": "0.5.1"
78
78
  },
79
79
  "engines": {
80
- "node": "^20.19.0 || >=22.12.0"
80
+ "node": "^20.19.0 || >=22.13.0"
81
81
  },
82
82
  "scripts": {
83
83
  "dev": "vp pack --watch",