Skip to content

Add unused i18n keys detection to pre-commit hook #4328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

christian-byrne
Copy link
Contributor

@christian-byrne christian-byrne commented Jul 2, 2025

Summary

  • Adds TypeScript script to detect unused i18n keys in staged locale files
  • Integrates with pre-commit hook to block commits with unused keys
  • Only checks NEW keys added in commits (ignores existing unused keys)
  • Smart filtering to avoid false positives for dynamically constructed keys

Test plan

  • Tested script detects unused keys and blocks commits
  • Tested script allows commits when no unused keys present
  • Verified integration with existing pre-commit workflow

┆Issue is synchronized with this Notion page by Unito

@christian-byrne christian-byrne requested a review from a team as a code owner July 2, 2025 09:21
@christian-byrne
Copy link
Contributor Author

This is just a pre-commit script so let's merge this for now. If it is giving false positives or causing trouble we can disable later.

It was tested as described in the PR description.

@christian-byrne christian-byrne merged commit 7befec5 into main Jul 3, 2025
10 checks passed
@christian-byrne christian-byrne deleted the feat/unused-i18n-keys-detection branch July 3, 2025 17:53
@@ -3,3 +3,6 @@ if [[ "$OS" == "Windows_NT" ]]; then
else
npx lint-staged
fi

# Check for unused i18n keys in staged files
npx tsx scripts/check-unused-i18n-keys.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks on windows; please mimic above (ridiculous) if/else workaround.

Copy link
Contributor Author

@christian-byrne christian-byrne Jul 4, 2025

Choose a reason for hiding this comment

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

got it, making PR now!

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.

2 participants