Add ARB 4-space indent guard to pre-commit hook#5273
Merged
Conversation
Auto-fixes staged ARB files that use 2-space indent back to 4-space using jq, preventing large whitespace-only diffs in PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tells editors (VS Code, IntelliJ, etc.) to use 4-space indent for ARB and JSON files, matching the existing codebase convention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 tasks
Greptile SummaryThis PR adds guardrails to prevent ARB localization files from being reformatted with 2-space indent. It introduces an Key Changes:
Critical Issue:
Confidence Score: 1/5
Important Files Changed
Last reviewed commit: 8faa1ab |
| if [ -n "$STAGED_ARB_FILES" ]; then | ||
| BAD_ARB="" | ||
| for f in $STAGED_ARB_FILES; do | ||
| if grep -qP '^\s{2}"' "$f" && ! grep -qP '^\s{4}"' "$f"; then |
There was a problem hiding this comment.
this logic won't detect 2-space indented ARB files with nested objects. ARB files have metadata like @key with nested description fields, so a 2-space file would have lines with both 2 spaces (level 1) and 4 spaces (level 2). the condition fails because ! grep -qP '^\s{4}"' returns false
Suggested change
| if grep -qP '^\s{2}"' "$f" && ! grep -qP '^\s{4}"' "$f"; then | |
| if grep -qP '^\s{2}"' "$f"; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the gap that let PR #5268 balloon to ~98K lines from editor reformatting ARB files.
jq.app/.editorconfigtells editors to use 4-space indent for*.arb/*.jsonby default.by AI for @beastoin