Skip to content

Add ARB 4-space indent guard to pre-commit hook#5273

Merged
beastoin merged 2 commits intomainfrom
fix/arb-indent-guard
Mar 2, 2026
Merged

Add ARB 4-space indent guard to pre-commit hook#5273
beastoin merged 2 commits intomainfrom
fix/arb-indent-guard

Conversation

@beastoin
Copy link
Collaborator

@beastoin beastoin commented Mar 2, 2026

Closes the gap that let PR #5268 balloon to ~98K lines from editor reformatting ARB files.

  • Pre-commit hook now detects 2-space-indented ARB files and auto-fixes them to 4-space via jq.
  • app/.editorconfig tells editors to use 4-space indent for *.arb / *.json by default.

by AI for @beastoin

beastoin and others added 2 commits March 2, 2026 09:10
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>
Copy link
Collaborator Author

@beastoin beastoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@beastoin beastoin merged commit 64c482e into main Mar 2, 2026
2 checks passed
@beastoin beastoin deleted the fix/arb-indent-guard branch March 2, 2026 08:11
@greptile-apps
Copy link

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR adds guardrails to prevent ARB localization files from being reformatted with 2-space indent. It introduces an .editorconfig to set editor defaults and a pre-commit hook to detect and auto-fix incorrectly indented files.

Key Changes:

  • Added app/.editorconfig to enforce 4-space indent for *.arb and *.json files
  • Added pre-commit validation to detect 2-space indented ARB files and reformat with jq --indent 4

Critical Issue:

  • The detection logic on line 35 has a bug that prevents it from catching 2-space indented ARB files with nested objects (which most ARB files have). ARB files contain metadata entries like @key with nested description fields, meaning a 2-space file would have both 2-space lines (level 1 keys) and 4-space lines (level 2 nested keys). The condition && ! grep -qP '^\s{4}"' causes the check to fail for these common cases.

Confidence Score: 1/5

  • This PR has a critical logic bug that prevents it from achieving its stated goal
  • The pre-commit hook won't actually prevent the problem it's designed to solve. The detection logic fails for ARB files with nested structure (which is standard), meaning 2-space indented files would pass through undetected. This defeats the entire purpose of PR Add ARB 4-space indent guard to pre-commit hook #5273.
  • scripts/pre-commit requires immediate attention - line 35 needs the logic fix suggested in the inline comment

Important Files Changed

Filename Overview
scripts/pre-commit adds ARB indent validation but logic fails to detect 2-space files with nesting
app/.editorconfig configures editors to use 4-space indent for ARB/JSON files

Last reviewed commit: 8faa1ab

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant