react-doctor 0.5.8-dev.5893a56 → 0.5.8-dev.6339f71

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.
Files changed (2) hide show
  1. package/dist/cli.js +89 -130
  2. package/package.json +5 -5
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]="eb7a01bc-f737-5207-b430-b8fee7a1895f")}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]="0efab588-a475-5d5f-a751-5b3e866685fb")}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";
@@ -45103,7 +45103,7 @@ const makeNoopConsole = () => ({
45103
45103
  });
45104
45104
  //#endregion
45105
45105
  //#region src/cli/utils/version.ts
45106
- const VERSION = "0.5.8-dev.5893a56";
45106
+ const VERSION = "0.5.8-dev.6339f71";
45107
45107
  //#endregion
45108
45108
  //#region src/cli/utils/json-mode.ts
45109
45109
  let context = null;
@@ -45472,13 +45472,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
45472
45472
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
45473
45473
  * standard `SENTRY_RELEASE` override.
45474
45474
  */
45475
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.8-dev.5893a56`;
45475
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.8-dev.6339f71`;
45476
45476
  /**
45477
45477
  * Deployment environment shown in Sentry's environment filter. Defaults to
45478
45478
  * `production` for tagged releases and `development` for dev/unbuilt versions,
45479
45479
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
45480
45480
  */
45481
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.8-dev.5893a56") ? "development" : "production");
45481
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.8-dev.6339f71") ? "development" : "production");
45482
45482
  /**
45483
45483
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
45484
45484
  * (set to `0` to disable tracing) and falls back to
@@ -52259,11 +52259,10 @@ const rememberInstallAgents = (agents, options = {}) => writePreference(INSTALL_
52259
52259
  const CLAUDE_AGENT = "claude-code";
52260
52260
  const CURSOR_AGENT = "cursor";
52261
52261
  const CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
52262
- const CLAUDE_HOOK_RELATIVE_PATH = ".claude/hooks/react-doctor.mjs";
52263
- const CLAUDE_HOOK_COMMAND = "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/react-doctor.mjs\"";
52262
+ const CLAUDE_HOOK_RELATIVE_PATH = ".claude/hooks/react-doctor.sh";
52263
+ const CLAUDE_HOOK_COMMAND = "sh \"$CLAUDE_PROJECT_DIR/.claude/hooks/react-doctor.sh\"";
52264
52264
  const CURSOR_HOOKS_RELATIVE_PATH = ".cursor/hooks.json";
52265
- const CURSOR_HOOK_RELATIVE_PATH = ".cursor/hooks/react-doctor.mjs";
52266
- const CURSOR_HOOK_COMMAND = "node .cursor/hooks/react-doctor.mjs";
52265
+ const CURSOR_HOOK_RELATIVE_PATH = ".cursor/hooks/react-doctor.sh";
52267
52266
  const CURSOR_HOOK_MATCHER = "Write|Edit|MultiEdit|ApplyPatch";
52268
52267
  const CURSOR_HOOKS_SCHEMA_VERSION = 1;
52269
52268
  const isSupportedAgent = (agent) => agent === CLAUDE_AGENT || agent === CURSOR_AGENT;
@@ -52295,6 +52294,7 @@ const writeJsonFileWithDirectoryCheck = (filePath, value) => {
52295
52294
  const writeHookScript = (filePath) => {
52296
52295
  ensureDirectoryExists(Path.dirname(filePath));
52297
52296
  NFS.writeFileSync(filePath, buildAgentHookScript());
52297
+ NFS.chmodSync(filePath, 493);
52298
52298
  };
52299
52299
  const hasClaudeHookCommand = (groups) => groups.some((group) => (group.hooks ?? []).some((hook) => hook.command === CLAUDE_HOOK_COMMAND));
52300
52300
  const installClaudeHook = (projectRoot) => {
@@ -52315,7 +52315,7 @@ const installClaudeHook = (projectRoot) => {
52315
52315
  writeHookScript(hookPath);
52316
52316
  return [settingsPath, hookPath];
52317
52317
  };
52318
- const hasCursorHookCommand = (handlers) => handlers.some((handler) => handler.command === CURSOR_HOOK_COMMAND);
52318
+ const hasCursorHookCommand = (handlers) => handlers.some((handler) => handler.command === CURSOR_HOOK_RELATIVE_PATH);
52319
52319
  const installCursorHook = (projectRoot) => {
52320
52320
  const configPath = Path.join(projectRoot, CURSOR_HOOKS_RELATIVE_PATH);
52321
52321
  const hookPath = Path.join(projectRoot, CURSOR_HOOK_RELATIVE_PATH);
@@ -52323,7 +52323,7 @@ const installCursorHook = (projectRoot) => {
52323
52323
  const hooks = { ...config.hooks ?? {} };
52324
52324
  const postToolUseHooks = [...hooks.postToolUse ?? []];
52325
52325
  if (!hasCursorHookCommand(postToolUseHooks)) postToolUseHooks.push({
52326
- command: CURSOR_HOOK_COMMAND,
52326
+ command: CURSOR_HOOK_RELATIVE_PATH,
52327
52327
  matcher: CURSOR_HOOK_MATCHER,
52328
52328
  timeout: 120
52329
52329
  });
@@ -52337,111 +52337,102 @@ const installCursorHook = (projectRoot) => {
52337
52337
  return [configPath, hookPath];
52338
52338
  };
52339
52339
  const buildAgentHookScript = () => [
52340
- "import { readFileSync, writeFileSync, unlinkSync } from 'node:fs';",
52341
- "import { tmpdir } from 'node:os';",
52342
- "import { join, dirname } from 'node:path';",
52343
- "import { fileURLToPath } from 'node:url';",
52344
- "import { spawnSync } from 'node:child_process';",
52340
+ "#!/bin/sh",
52341
+ "set -u",
52345
52342
  "",
52346
- "const __filename = fileURLToPath(import.meta.url);",
52347
- "const __dirname = dirname(__filename);",
52343
+ "input_file=$(mktemp \"${TMPDIR:-/tmp}/react-doctor-agent-hook.XXXXXX\")",
52344
+ "output_file=$(mktemp \"${TMPDIR:-/tmp}/react-doctor-agent-hook-output.XXXXXX\")",
52345
+ "trap 'rm -f \"$input_file\" \"$output_file\"' EXIT",
52346
+ "cat > \"$input_file\"",
52348
52347
  "",
52349
- "const EDIT_TOOL_NAMES = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit', 'ApplyPatch']);",
52348
+ "script_dir=$(CDPATH= cd \"$(dirname \"$0\")\" && pwd)",
52349
+ "project_root=${CLAUDE_PROJECT_DIR:-}",
52350
+ "if [ -z \"$project_root\" ]; then",
52351
+ " project_root=$(CDPATH= cd \"$script_dir/../..\" && pwd)",
52352
+ "fi",
52353
+ "if ! cd \"$project_root\"; then",
52354
+ " exit 0",
52355
+ "fi",
52350
52356
  "",
52351
- "const readStdin = () => {",
52352
- " try {",
52353
- " return readFileSync(0, 'utf8');",
52354
- " } catch {",
52355
- " return '';",
52356
- " }",
52357
- "};",
52357
+ "should_scan() {",
52358
+ " if ! command -v node >/dev/null 2>&1; then",
52359
+ " return 0",
52360
+ " fi",
52358
52361
  "",
52359
- "const shouldScan = (input) => {",
52362
+ " node - \"$input_file\" <<'NODE'",
52363
+ "const fs = require('node:fs');",
52364
+ "const inputPath = process.argv[2];",
52365
+ "const editToolNames = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit', 'ApplyPatch']);",
52366
+ "try {",
52367
+ " const input = JSON.parse(fs.readFileSync(inputPath, 'utf8') || '{}');",
52360
52368
  " const eventName = input.hook_event_name || input.eventName || input.event_name;",
52361
52369
  " if (eventName === 'PostToolBatch') {",
52362
52370
  " const toolCalls = Array.isArray(input.tool_calls) ? input.tool_calls : [];",
52363
- " return toolCalls.some((toolCall) => EDIT_TOOL_NAMES.has(toolCall.tool_name));",
52371
+ " process.exit(toolCalls.some((toolCall) => editToolNames.has(toolCall.tool_name)) ? 0 : 10);",
52364
52372
  " }",
52365
52373
  " const toolName = input.tool_name || input.toolName || input.tool;",
52366
- " return !toolName || EDIT_TOOL_NAMES.has(toolName);",
52367
- "};",
52374
+ " process.exit(!toolName || editToolNames.has(toolName) ? 0 : 10);",
52375
+ "} catch {",
52376
+ " process.exit(0);",
52377
+ "}",
52378
+ "NODE",
52379
+ "}",
52368
52380
  "",
52369
- "const runReactDoctor = (outputPath) => {",
52370
- " // Each candidate is a single shell command string (not an args array):",
52371
- " // `shell: true` is required to run the Windows `.cmd` shims, and an args",
52372
- " // array with `shell: true` trips Node's DEP0190. A missing command exits",
52373
- " // 127 via the shell (no ENOENT error), so fall through on that. With no",
52374
- " // runner found, exit 0 silently — stdout is parsed as the hook's JSON.",
52375
- " const commands = [",
52376
- " './node_modules/.bin/react-doctor --verbose --scope changed --blocking warning --no-score',",
52377
- " 'react-doctor --verbose --scope changed --blocking warning --no-score',",
52378
- " 'pnpm dlx react-doctor@latest --verbose --scope changed --blocking warning --no-score',",
52379
- " 'npx --yes react-doctor@latest --verbose --scope changed --blocking warning --no-score',",
52380
- " ];",
52381
+ "run_react_doctor() {",
52382
+ " if [ -x ./node_modules/.bin/react-doctor ]; then",
52383
+ " ./node_modules/.bin/react-doctor --verbose --scope changed --blocking warning --no-score",
52384
+ " return",
52385
+ " fi",
52381
52386
  "",
52382
- " for (const command of commands) {",
52383
- " const result = spawnSync(command, { encoding: 'utf8', shell: true });",
52384
- " if (result.error?.code === 'ENOENT' || result.status === 127) continue;",
52385
- " try {",
52386
- " writeFileSync(outputPath, (result.stdout || '') + (result.stderr || ''));",
52387
- " } catch {}",
52388
- " return result.status;",
52389
- " }",
52387
+ " if command -v react-doctor >/dev/null 2>&1; then",
52388
+ " react-doctor --verbose --scope changed --blocking warning --no-score",
52389
+ " return",
52390
+ " fi",
52390
52391
  "",
52391
- " return 0;",
52392
- "};",
52392
+ " if command -v pnpm >/dev/null 2>&1; then",
52393
+ " pnpm dlx react-doctor@latest --verbose --scope changed --blocking warning --no-score",
52394
+ " return",
52395
+ " fi",
52393
52396
  "",
52394
- "const cleanup = (...paths) => {",
52395
- " for (const path of paths) {",
52396
- " try { unlinkSync(path); } catch {}",
52397
- " }",
52398
- "};",
52397
+ " if command -v npx >/dev/null 2>&1; then",
52398
+ " npx --yes react-doctor@latest --verbose --scope changed --blocking warning --no-score",
52399
+ " return",
52400
+ " fi",
52399
52401
  "",
52400
- "const main = () => {",
52401
- " let input;",
52402
- " try {",
52403
- " const stdinContent = readStdin();",
52404
- " input = JSON.parse(stdinContent || '{}');",
52405
- " } catch {",
52406
- " input = {};",
52407
- " }",
52402
+ " printf '%s\\n' 'react-doctor: command not found; skipping agent hook scan.'",
52403
+ " return 0",
52404
+ "}",
52408
52405
  "",
52409
- " if (!shouldScan(input)) {",
52410
- " process.exit(0);",
52411
- " }",
52406
+ "if ! should_scan; then",
52407
+ " exit 0",
52408
+ "fi",
52412
52409
  "",
52413
- " const projectRoot = process.env.CLAUDE_PROJECT_DIR || join(__dirname, '../..');",
52414
- " const outputPath = join(tmpdir(), `react-doctor-agent-hook-output-${process.pid}.txt`);",
52410
+ "if run_react_doctor > \"$output_file\" 2>&1; then",
52411
+ " exit 0",
52412
+ "fi",
52415
52413
  "",
52414
+ "node - \"$input_file\" \"$output_file\" <<'NODE'",
52415
+ "const fs = require('node:fs');",
52416
+ "const inputPath = process.argv[2];",
52417
+ "const outputPath = process.argv[3];",
52418
+ "const readInput = () => {",
52416
52419
  " try {",
52417
- " process.chdir(projectRoot);",
52420
+ " return JSON.parse(fs.readFileSync(inputPath, 'utf8') || '{}');",
52418
52421
  " } catch {",
52419
- " process.exit(0);",
52420
- " }",
52421
- "",
52422
- " const scanResult = runReactDoctor(outputPath);",
52423
- " if (scanResult === 0) {",
52424
- " cleanup(outputPath);",
52425
- " process.exit(0);",
52426
- " }",
52427
- "",
52428
- " const scanOutput = readFileSync(outputPath, 'utf8').trim();",
52429
- " cleanup(outputPath);",
52430
- "",
52431
- " if (!scanOutput) {",
52432
- " process.exit(0);",
52433
- " }",
52434
- "",
52435
- " const message = `React Doctor found issues in the changed files. Review this output and fix the regressions before finishing. For confirmed issues that cannot be fixed now, create GitHub issues with the rule, file/line, confidence, impact, and proposed fix.\\n\\n${scanOutput}`;",
52436
- "",
52437
- " if (input.hook_event_name === 'PostToolBatch') {",
52438
- " console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PostToolBatch', additionalContext: message } }));",
52439
- " } else {",
52440
- " console.log(JSON.stringify({ additional_context: message }));",
52422
+ " return {};",
52441
52423
  " }",
52442
52424
  "};",
52443
- "",
52444
- "main();"
52425
+ "const input = readInput();",
52426
+ "const scanOutput = fs.readFileSync(outputPath, 'utf8').trim();",
52427
+ "if (!scanOutput) process.exit(0);",
52428
+ "const message = `React Doctor found issues in the changed files. Review this output and fix the regressions before finishing. For confirmed issues that cannot be fixed now, create GitHub issues with the rule, file/line, confidence, impact, and proposed fix.\\n\\n${scanOutput}`;",
52429
+ "if (input.hook_event_name === 'PostToolBatch') {",
52430
+ " console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PostToolBatch', additionalContext: message } }));",
52431
+ "} else {",
52432
+ " console.log(JSON.stringify({ additional_context: message }));",
52433
+ "}",
52434
+ "NODE",
52435
+ ""
52445
52436
  ].join("\n");
52446
52437
  const installReactDoctorAgentHooks = (options) => {
52447
52438
  const installedAgents = [];
@@ -53267,26 +53258,6 @@ const CLI_AGENT_AUTO_FLAGS = {
53267
53258
  codex: ["--yolo"],
53268
53259
  cursor: ["--force"]
53269
53260
  };
53270
- const resolveCursorBundledNode = () => {
53271
- if (!isWindows) return null;
53272
- const localAppData = process.env.LOCALAPPDATA;
53273
- if (!localAppData) return null;
53274
- const cursorAgentRoot = Path.join(localAppData, "cursor-agent", "versions");
53275
- try {
53276
- const versions = NFS.readdirSync(cursorAgentRoot);
53277
- if (versions.length === 0) return null;
53278
- const sortedVersions = versions.sort((a, b) => b.localeCompare(a, void 0, { numeric: true }));
53279
- for (const version of sortedVersions) try {
53280
- const bundledNodePath = Path.join(cursorAgentRoot, version, "node.exe");
53281
- const entryScriptPath = Path.join(cursorAgentRoot, version, "index.js");
53282
- if (NFS.statSync(bundledNodePath).isFile() && NFS.statSync(entryScriptPath).isFile()) return {
53283
- command: bundledNodePath,
53284
- args: [entryScriptPath]
53285
- };
53286
- } catch {}
53287
- } catch {}
53288
- return null;
53289
- };
53290
53261
  const resolveWindowsCmdEntryScript = (command) => {
53291
53262
  if (!isWindows) return null;
53292
53263
  const pathDirectories = (process.env.PATH ?? "").split(Path.delimiter).filter(Boolean);
@@ -53306,10 +53277,11 @@ const resolveWindowsCmdEntryScript = (command) => {
53306
53277
  }
53307
53278
  return null;
53308
53279
  };
53309
- const spawnAgent = (command, args, cwd) => new Promise((resolve, reject) => {
53280
+ const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
53310
53281
  const child = spawn(command, [...args], {
53311
53282
  cwd,
53312
- stdio: "inherit"
53283
+ stdio: "inherit",
53284
+ shell
53313
53285
  });
53314
53286
  child.on("error", reject);
53315
53287
  child.on("close", (code) => resolve(code ?? 0));
@@ -53318,10 +53290,6 @@ const launchCliAgent = async (agentId, prompt, cwd) => {
53318
53290
  const binary = CLI_AGENT_BINARIES[agentId];
53319
53291
  const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
53320
53292
  if (isWindows) {
53321
- if (agentId === "cursor") {
53322
- const cursorResolution = resolveCursorBundledNode();
53323
- if (cursorResolution) return spawnAgent(cursorResolution.command, [...cursorResolution.args, ...agentArgs], cwd);
53324
- }
53325
53293
  const entryScript = resolveWindowsCmdEntryScript(binary);
53326
53294
  if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
53327
53295
  }
@@ -55379,14 +55347,6 @@ const applyColorPreference = (argv, env = process.env) => {
55379
55347
  setColorEnabled(enabled);
55380
55348
  };
55381
55349
  //#endregion
55382
- //#region src/cli/utils/ensure-windows-utf8-console.ts
55383
- const ensureWindowsUtf8Console = () => {
55384
- if (process.platform !== "win32" || !process.stdout.isTTY) return;
55385
- try {
55386
- execFileSync("chcp.com", ["65001"], { stdio: "ignore" });
55387
- } catch {}
55388
- };
55389
- //#endregion
55390
55350
  //#region src/cli/utils/exit-gracefully.ts
55391
55351
  const exitGracefully = () => {
55392
55352
  try {
@@ -55745,7 +55705,6 @@ if (process.argv.includes("-V") && !strippedArgv.includes("-V")) {
55745
55705
  process.exit(0);
55746
55706
  }
55747
55707
  applyColorPreference(strippedArgv);
55748
- ensureWindowsUtf8Console();
55749
55708
  const argv = normalizeHelpInvocation(strippedArgv, knownCommands);
55750
55709
  Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => program.parseAsync(argv)).then(() => flushSentry()).catch(async (error) => {
55751
55710
  const isUserError = isExpectedUserError(error);
@@ -55764,4 +55723,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
55764
55723
  export {};
55765
55724
 
55766
55725
  //# sourceMappingURL=cli.js.map
55767
- //# debugId=eb7a01bc-f737-5207-b430-b8fee7a1895f
55726
+ //# debugId=0efab588-a475-5d5f-a751-5b3e866685fb
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.8-dev.5893a56",
3
+ "version": "0.5.8-dev.6339f71",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -60,12 +60,12 @@
60
60
  "magicast": "^0.5.3",
61
61
  "oxlint": ">=1.66.0 <1.67.0",
62
62
  "prompts": "^2.4.2",
63
- "typescript": ">=5.0.4 <6",
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
67
  "deslop-js": "0.5.8",
68
- "oxlint-plugin-react-doctor": "0.5.8-dev.5893a56"
68
+ "oxlint-plugin-react-doctor": "0.5.8-dev.6339f71"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/babel__code-frame": "^7.27.0",
@@ -74,8 +74,8 @@
74
74
  "commander": "^14.0.3",
75
75
  "ora": "^9.4.0",
76
76
  "@react-doctor/api": "0.5.8",
77
- "@react-doctor/core": "0.5.8",
78
- "@react-doctor/language-server": "0.5.8"
77
+ "@react-doctor/language-server": "0.5.8",
78
+ "@react-doctor/core": "0.5.8"
79
79
  },
80
80
  "engines": {
81
81
  "node": "^20.19.0 || >=22.13.0"