Skip to content

chore(web): add ESLint rules for i18n JSON validation#30491

Merged
hyoban merged 1 commit intomainfrom
1-4-eslint-for-i18n-json
Jan 5, 2026
Merged

chore(web): add ESLint rules for i18n JSON validation#30491
hyoban merged 1 commit intomainfrom
1-4-eslint-for-i18n-json

Conversation

@hyoban
Copy link
Member

@hyoban hyoban commented Jan 4, 2026

Summary

  • Add valid-i18n-keys rule to ensure i18n JSON keys are flat and don't conflict (no key can be a prefix of another key)
  • Add no-extra-keys rule to ensure non-English JSON files don't have keys missing from en-US (with autofix support)
  • Add utility function to handle JSON files with trailing commas

Test plan

  • Run pnpm lint to verify rules work correctly
  • Verify rules catch invalid key structures in JSON files
  • Verify autofix removes extra keys from non-English translations

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 4, 2026 04:33
@hyoban hyoban requested a review from iamjoel as a code owner January 4, 2026 04:33
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 💪 enhancement New feature or request labels Jan 4, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 ESLint Rule: valid-i18n-keys: Introduced a new ESLint rule to ensure i18n JSON keys are flat and do not conflict, meaning no key can be a prefix of another key (e.g., 'foo' and 'foo.bar' cannot both exist).
  • New ESLint Rule: no-extra-keys: Added an ESLint rule that verifies non-English i18n JSON files do not contain keys that are missing from their en-US counterparts. This rule also includes autofix support to remove such extra keys.
  • JSON Utility Function: A new utility function has been added to robustly handle JSON files that might contain trailing commas, ensuring they can be parsed correctly.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-keys rule to detect conflicting key structures
  • Add no-extra-keys rule 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.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 5, 2026
@hyoban hyoban merged commit 52149c0 into main Jan 5, 2026
20 checks passed
@hyoban hyoban deleted the 1-4-eslint-for-i18n-json branch January 5, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

3 participants