chore(web): add ESLint rules for i18n JSON validation#30491
Conversation
Summary of ChangesHello @hyoban, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the internationalization (i18n) workflow by introducing new ESLint rules specifically designed for validating i18n JSON files. These rules aim to enforce consistency in key structures and prevent discrepancies between different language translations, thereby improving the maintainability and reliability of the localization process. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces valuable ESLint rules for validating i18n JSON files, which is a great step towards maintaining translation quality. The new valid-i18n-keys and no-extra-keys rules cover important validation scenarios. My review focuses on improving the robustness, efficiency, and developer experience of these new rules. I've identified opportunities to improve JSON parsing with trailing commas, refine the autofix logic to avoid conflicts, make error reporting more descriptive, and enhance the efficiency of the key validation logic. The cleanJsonText utility can also be made more robust. Please see my detailed comments for specific suggestions.
There was a problem hiding this comment.
Pull request overview
This PR adds two custom ESLint rules to validate i18n JSON files: one to ensure keys don't conflict with each other as prefixes, and another to prevent non-English translations from having extra keys not present in the English source files.
- Add
valid-i18n-keysrule to detect conflicting key structures - Add
no-extra-keysrule with autofix to remove extra keys from non-English translations - Add utility function to handle JSON files with trailing commas
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| web/eslint.config.mjs | Reorganizes i18n-related ESLint rules and adds the two new validation rules for JSON files |
| web/eslint-rules/utils.js | Adds utility function to clean trailing commas from JSON text before parsing |
| web/eslint-rules/rules/valid-i18n-keys.js | Implements rule to validate that i18n keys don't create prefix conflicts |
| web/eslint-rules/rules/no-extra-keys.js | Implements rule to detect and autofix extra keys in non-English translation files |
| web/eslint-rules/index.js | Exports the two new rules in the plugin |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
valid-i18n-keysrule to ensure i18n JSON keys are flat and don't conflict (no key can be a prefix of another key)no-extra-keysrule to ensure non-English JSON files don't have keys missing from en-US (with autofix support)Test plan
pnpm lintto verify rules work correctly🤖 Generated with Claude Code