Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
fail-on:
description: "Exit with error code on diagnostics: error, warning, none"
default: "error"
offline:
description: "Skip sending diagnostics to the react.doctor API and calculate score locally"
default: "false"
node-version:
description: "Node.js version to use"
default: "20"
Expand All @@ -47,11 +50,13 @@ runs:
INPUT_DIFF: ${{ inputs.diff }}
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
INPUT_FAIL_ON: ${{ inputs.fail-on }}
INPUT_OFFLINE: ${{ inputs.offline }}
run: |
FLAGS="--fail-on $INPUT_FAIL_ON"
if [ "$INPUT_VERBOSE" = "true" ]; then FLAGS="$FLAGS --verbose"; fi
if [ -n "$INPUT_PROJECT" ]; then FLAGS="$FLAGS --project $INPUT_PROJECT"; fi
if [ -n "$INPUT_DIFF" ]; then FLAGS="$FLAGS --diff $INPUT_DIFF"; fi
if [ "$INPUT_OFFLINE" = "true" ]; then FLAGS="$FLAGS --offline"; fi

if [ -n "$INPUT_GITHUB_TOKEN" ]; then
npx -y react-doctor@latest "$INPUT_DIRECTORY" $FLAGS | tee /tmp/react-doctor-output.txt
Expand All @@ -64,8 +69,11 @@ runs:
shell: bash
env:
INPUT_DIRECTORY: ${{ inputs.directory }}
INPUT_OFFLINE: ${{ inputs.offline }}
run: |
SCORE=$(npx -y react-doctor@latest "$INPUT_DIRECTORY" --score 2>/dev/null | tail -1 | tr -d '[:space:]')
OFFLINE_FLAG=""
if [ "$INPUT_OFFLINE" = "true" ]; then OFFLINE_FLAG="--offline"; fi
SCORE=$(npx -y react-doctor@latest "$INPUT_DIRECTORY" --score $OFFLINE_FLAG 2>/dev/null | tail -1 | tr -d '[:space:]')
if [[ -n "$SCORE" && "$SCORE" =~ ^[0-9]+$ ]]; then
echo "score=$SCORE" >> "$GITHUB_OUTPUT"
fi
Expand Down
2 changes: 2 additions & 0 deletions packages/react-doctor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Supports Cursor, Claude Code, Amp Code, Codex, Gemini CLI, OpenCode, Windsurf, a
| `project` | | Workspace project(s) to scan (comma-separated) |
| `diff` | | Base branch for diff mode. Only changed files are scanned |
| `github-token` | | When set on `pull_request` events, posts findings as a PR comment |
| `fail-on` | `error` | Exit with error code on diagnostics: `error`, `warning`, `none` |
| `offline` | `false` | Skip sending diagnostics to the react.doctor API |
| `node-version` | `20` | Node.js version to use |

The action outputs a `score` (0–100) you can use in subsequent steps.
Expand Down