Skip to content

Commit 9355095

Browse files
committed
Merge branch 'main' into mrejdak/remove-unnecessary-types-batch-3
2 parents b5e6516 + 72e7e62 commit 9355095

685 files changed

Lines changed: 13277 additions & 4044 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/agents/code-inline-reviewer.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name: code-inline-reviewer
44
description: Reviews code and creates inline comments for specific rule violations.
5-
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
5+
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash
66
model: inherit
77
---
88

@@ -203,6 +203,7 @@ memo(ReportActionItem, (prevProps, nextProps) =>
203203
1. **First, get the list of changed files and their diffs:**
204204
- Use `gh pr diff` to see what actually changed in the PR
205205
- Focus ONLY on the changed lines, not the entire file
206+
- **CRITICAL**: Only create inline comments on lines that are part of the diff. Do NOT add comments to lines outside the diff, even if they contain violations. Comments on unchanged lines will fail to be created.
206207
2. **For analyzing changed files:**
207208
- **For large files (>5000 lines):** Use the Grep tool to search for specific violation patterns instead of reading the entire file. Focus grep searches on the changed portions shown in the diff.
208209
- **For smaller files:** You may read the full file using the Read tool
@@ -214,7 +215,7 @@ memo(ReportActionItem, (prevProps, nextProps) =>
214215
- `line`: Line number where the issue occurs
215216
- `body`: Concise and actionable description of the violation and fix, following the below Comment Format
216217
6. **Each comment must reference exactly one Rule ID.**
217-
7. **Output must consist exclusively of calls to mcp__github_inline_comment__create_inline_comment in the required format.** No other text, Markdown, or prose is allowed.
218+
7. **Output must consist exclusively of calls to createInlineComment.sh in the required format.** No other text, Markdown, or prose is allowed.
218219
8. **If no violations are found, add a reaction to the PR**:
219220
Add a 👍 (+1) reaction to the PR using the `addPrReaction` script (available in PATH from `.claude/scripts/`). The script takes ONLY the PR number as argument - it always adds a "+1" reaction, so do NOT pass any reaction type or emoji.
220221
9. **Add reaction if and only if**:
@@ -230,15 +231,13 @@ memo(ReportActionItem, (prevProps, nextProps) =>
230231

231232
## Tool Usage Example
232233

233-
For each violation, call the mcp__github_inline_comment__create_inline_comment tool like this.
234-
CRITICAL: **DO NOT** use the Bash tool for inline comments:
234+
For each violation, call the createInlineComment.sh script like this:
235235

236+
```bash
237+
createInlineComment.sh 'src/components/ReportActionsList.tsx' '<Body of the comment according to the Comment Format>' 128
236238
```
237-
mcp__github_inline_comment__create_inline_comment:
238-
path: 'src/components/ReportActionsList.tsx'
239-
line: 128
240-
body: '<Body of the comment according to the Comment Format>'
241-
```
239+
240+
**IMPORTANT**: Always use single quotes around the body argument to properly handle special characters and quotes.
242241

243242
If ZERO violations are found, use the Bash tool to add a reaction to the PR body:
244243

@@ -258,4 +257,4 @@ addPrReaction.sh <PR_NUMBER>
258257
<Suggested, specific fix preferably with a code snippet>
259258
```
260259

261-
**CRITICAL**: You must actually call the mcp__github_inline_comment__create_inline_comment tool for each violation. Don't just describe what you found - create the actual inline comments!
260+
**CRITICAL**: You must actually call the createInlineComment.sh script for each violation. Don't just describe what you found - create the actual inline comments!

.claude/commands/review-code-pr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),mcp__github_inline_comment__create_inline_comment
2+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),Bash(createInlineComment.sh:*)
33
description: Review a code contribution pull request
44
---
55

.claude/scripts/addPrReaction.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if [[ $# -lt 1 ]] || ! [[ "$1" =~ ^[0-9]+$ ]]; then
88
exit 1
99
fi
1010

11-
PR_NUMBER="$1"
12-
REPO="${GITHUB_REPOSITORY}"
11+
readonly PR_NUMBER="$1"
12+
readonly REPO="${GITHUB_REPOSITORY}"
1313

1414
gh api -X POST "/repos/$REPO/issues/$PR_NUMBER/reactions" -f content="+1"
1515

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# Secure proxy script to create an inline comment on a GitHub PR.
4+
set -eu
5+
6+
readonly ALLOWED_RULES_FILE="${GITHUB_WORKSPACE}/.claude/allowed-rules.txt"
7+
8+
# Print error and exit.
9+
die() {
10+
echo "Error: $*" >&2
11+
exit 1
12+
}
13+
14+
# Usage helper to avoid repeated text.
15+
usage() {
16+
die "Usage: $0 <path> <body> <line>"
17+
}
18+
19+
COMMENT_STATUS_REASON=""
20+
21+
# Ensure the comment body references an allowed rule tag.
22+
validate_rule() {
23+
local body="$1"
24+
local rule
25+
26+
[[ -f "$ALLOWED_RULES_FILE" ]] || die "Comment rejected: allowed rules file missing at $ALLOWED_RULES_FILE"
27+
28+
rule=$(echo "$body" | grep -oE '[A-Z]+-[0-9]+' | head -1 || true)
29+
[[ -n "$rule" ]] || die "Comment rejected: missing allowed rule reference (e.g. PERF-1)"
30+
31+
if grep -qF "$rule" "$ALLOWED_RULES_FILE"; then
32+
COMMENT_STATUS_REASON="rule $rule validated"
33+
return 0
34+
fi
35+
36+
die "Comment rejected: rule $rule not present in allowed list"
37+
}
38+
39+
readonly PATH_ARG="${1:-}"
40+
readonly BODY_ARG="${2:-}"
41+
readonly LINE_ARG="${3:-}"
42+
43+
[[ -z "$PR_NUMBER" ]] && die "Environment variable PR_NUMBER is required"
44+
[[ -z "$GITHUB_REPOSITORY" ]] && die "Environment variable GITHUB_REPOSITORY is required"
45+
[[ -z "$PATH_ARG" || -z "$BODY_ARG" || -z "$LINE_ARG" ]] && usage
46+
47+
validate_rule "$BODY_ARG"
48+
echo "Comment approved: $COMMENT_STATUS_REASON"
49+
50+
COMMIT_ID=$(gh api "/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq '.head.sha')
51+
readonly COMMIT_ID
52+
53+
PAYLOAD=$(jq -n \
54+
--arg body "$BODY_ARG" \
55+
--arg path "$PATH_ARG" \
56+
--argjson line "$LINE_ARG" \
57+
--arg commit_id "$COMMIT_ID" \
58+
'{body: $body, path: $path, line: $line, side: "RIGHT", commit_id: $commit_id}')
59+
readonly PAYLOAD
60+
61+
gh api -X POST "/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/comments" \
62+
--input - <<< "$PAYLOAD" || exit 1

.github/ISSUE_TEMPLATE/Standard.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ___
1010
**Version Number:**
1111
**Reproducible in staging?:**
1212
**Reproducible in production?:**
13-
**If this was caught during regression testing, add the test name, ID and link from TestRail:**
13+
**If this was caught during regression testing, add the test name, ID and link from BrowserStack:**
1414
**Email or phone of affected tester (no customers):**
1515
**Logs:** https://stackoverflow.com/c/expensify/questions/4856
1616
**Expensify/Expensify Issue URL:**
@@ -38,29 +38,8 @@ Select the officially supported platforms where the issue was reproduced:
3838
- [ ] iOS: mWeb Chrome
3939
- [ ] Windows: Chrome
4040
- [ ] MacOS: Chrome / Safari
41-
- [ ] MacOS: Desktop
42-
43-
<details>
44-
<summary>Platforms Tested:</summary>
45-
On which of our officially supported platforms was this issue tested:
46-
47-
- [ ] Android: App
48-
- [ ] Android: mWeb Chrome
49-
- [ ] iOS: App
50-
- [ ] iOS: mWeb Safari
51-
- [ ] iOS: mWeb Chrome
52-
- [ ] Windows: Chrome
53-
- [ ] MacOS: Chrome / Safari
54-
- [ ] MacOS: Desktop
55-
56-
</details>
5741

5842
## Screenshots/Videos
5943

60-
<details>
61-
<summary>Add any screenshot/video evidence</summary>
62-
63-
64-
</details>
6544

6645
[View all open jobs on GitHub](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22)

.github/actions/javascript/getPullRequestIncrementalChanges/index.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12624,6 +12624,7 @@ class Git {
1262412624
const files = [];
1262512625
let currentFile = null;
1262612626
let currentHunk = null;
12627+
let oldFilePath = null; // Track old file path to determine fileDiffType
1262712628
for (const line of lines) {
1262812629
// File header: diff --git a/file b/file
1262912630
if (line.startsWith('diff --git')) {
@@ -12636,13 +12637,41 @@ class Git {
1263612637
}
1263712638
currentFile = null;
1263812639
currentHunk = null;
12640+
oldFilePath = null; // Reset for next file
1263912641
continue;
1264012642
}
12641-
// File path: +++ b/file
12642-
if (line.startsWith('+++ b/')) {
12643-
const diffFilePath = line.slice(6); // Remove '+++ b/'
12643+
// Old file path: --- a/file or --- /dev/null (for new files)
12644+
// This comes before +++ in git diff output
12645+
if (line.startsWith('--- ')) {
12646+
oldFilePath = line.slice(4); // Store the old file path (remove '--- ')
12647+
continue;
12648+
}
12649+
// New file path: +++ b/file or +++ /dev/null (for removed files)
12650+
if (line.startsWith('+++ ')) {
12651+
const newFilePath = line.slice(4); // Remove '+++ '
12652+
// Determine fileDiffType based on old and new file paths
12653+
// Note: oldFilePath should always be set by the time we see +++, but handle null for type safety
12654+
let fileDiffType = 'modified';
12655+
let diffFilePath;
12656+
const oldPath = oldFilePath ?? '';
12657+
if (oldPath === '/dev/null') {
12658+
// New file: use the new file path
12659+
fileDiffType = 'added';
12660+
diffFilePath = newFilePath.startsWith('b/') ? newFilePath.slice(2) : newFilePath;
12661+
}
12662+
else if (newFilePath === '/dev/null') {
12663+
// Removed file: use the old file path
12664+
fileDiffType = 'removed';
12665+
diffFilePath = oldPath.startsWith('a/') ? oldPath.slice(2) : oldPath;
12666+
}
12667+
else {
12668+
// Modified file: use the new file path
12669+
fileDiffType = 'modified';
12670+
diffFilePath = newFilePath.startsWith('b/') ? newFilePath.slice(2) : newFilePath;
12671+
}
1264412672
currentFile = {
1264512673
filePath: diffFilePath,
12674+
diffType: fileDiffType,
1264612675
hunks: [],
1264712676
addedLines: new Set(),
1264812677
removedLines: new Set(),
@@ -12697,6 +12726,10 @@ class Git {
1269712726
// Context line - skip it (we only care about added/removed lines)
1269812727
continue;
1269912728
}
12729+
else if (firstChar === '\\') {
12730+
// "No newline at end of file" marker - skip it (metadata, not content)
12731+
continue;
12732+
}
1270012733
else {
1270112734
throw new Error(`Unknown line type! First character of line is ${firstChar}`);
1270212735
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Extract allowed rules from code-inline-reviewer.md
4+
# Rules are in format [PREFIX-NUMBER] where PREFIX is uppercase letters
5+
set -euo pipefail
6+
7+
REVIEWER_FILE="${1:-.claude/agents/code-inline-reviewer.md}"
8+
OUTPUT_FILE="${2:-.claude/allowed-rules.txt}"
9+
10+
if [[ ! -f "$REVIEWER_FILE" ]]; then
11+
echo "Error: Reviewer file not found: $REVIEWER_FILE" >&2
12+
exit 1
13+
fi
14+
15+
# Extract rules in format [CAPS-NUMBER] (e.g., [PERF-1], [SEC-1], [STYLE-1])
16+
# Remove brackets to store as PERF-1, SEC-1, etc.
17+
grep -oE '\[[A-Z]+-[0-9]+\]' "$REVIEWER_FILE" | sed 's/\[\(.*\)\]/\1/' | sort -u > "$OUTPUT_FILE"
18+
19+
if [[ ! -s "$OUTPUT_FILE" ]]; then
20+
echo "Error: No allowed rules found in $REVIEWER_FILE" >&2
21+
exit 1
22+
fi
23+
24+
echo "Extracted allowed rules:"
25+
cat "$OUTPUT_FILE"
26+

.github/workflows/claude-review.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
review:
1717
if: github.event.pull_request.draft != true && !contains(github.event.pull_request.title, 'Revert')
1818
runs-on: ubuntu-latest
19+
env:
20+
PR_NUMBER: ${{ github.event.pull_request.number }}
1921
steps:
2022
- name: Checkout repository
2123
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
@@ -37,6 +39,12 @@ jobs:
3739
run: |
3840
echo "$GITHUB_WORKSPACE/.claude/scripts" >> "$GITHUB_PATH"
3941
42+
- name: Extract allowed rules from code-inline-reviewer.md
43+
run: |
44+
"$GITHUB_WORKSPACE/.github/scripts/extractAllowedRules.sh" \
45+
"$GITHUB_WORKSPACE/.claude/agents/code-inline-reviewer.md" \
46+
"$GITHUB_WORKSPACE/.claude/allowed-rules.txt"
47+
4048
- name: Run Claude Code (code)
4149
if: steps.filter.outputs.code == 'true'
4250
uses: anthropics/claude-code-action@a7e4c51380c42dd89b127f5e5f9be7b54020bc6b # v1.0.21
@@ -46,7 +54,7 @@ jobs:
4654
allowed_non_write_users: "*"
4755
prompt: "/review-code-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}"
4856
claude_args: |
49-
--allowedTools "Task,Glob,Grep,Read,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),mcp__github_inline_comment__create_inline_comment"
57+
--allowedTools "Task,Glob,Grep,Read,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(addPrReaction.sh:*),Bash(createInlineComment.sh:*)"
5058
5159
- name: Run Claude Code (docs)
5260
if: steps.filter.outputs.docs == 'true'

.github/workflows/prettier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Verify there's no Prettier diff
3030
run: |
31-
npm run prettier -- --log-level silent
31+
npm run prettier -- --log-level error
3232
if ! git diff --name-only --exit-code; then
3333
# shellcheck disable=SC2016
3434
echo 'Error: Prettier diff detected! Please run `npm run prettier` and commit the changes.'

.github/workflows/react-compiler-compliance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
# In phase 0 of the React Compiler compliance check rollout,
2929
# we want to report failures but don't fail the check.
3030
# See https://github.com/Expensify/App/issues/68765#issuecomment-3487317881
31-
run: npm run react-compiler-compliance-check check-changed || true
31+
run: npm run react-compiler-compliance-check check-changed -- --filterByDiff --enforceNewComponents
3232
env:
3333
CI: true
3434
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)