npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dxmd/eslint-plugin-i18n-messages

v1.0.0

Published

ESLint plugin to enforce identical keys across i18n message files

Downloads

22

Readme

eslint-plugin-i18n-messages

npm version License: MIT

ESLint plugin to enforce identical keys across i18n/locale message files. Helps prevent missing translations by ensuring all locale files have the same structure.

Features

  • ✅ Validates JSON locale files against a reference file
  • ✅ Detects missing keys (in reference but not in current file)
  • ✅ Detects extra keys (in current file but not in reference)
  • ✅ Supports nested object structures with dot notation
  • ✅ Glob pattern support for reference file
  • ✅ Bundles JSON parser - no additional dependencies needed
  • ✅ Works with both ESLint flat config and legacy config

Installation

npm install --save-dev eslint-plugin-i18n-messages

The plugin bundles jsonc-eslint-parser, so you don't need to install it separately.

Requirements

  • Node.js >= 16.0.0
  • ESLint >= 8.0.0

Usage

This plugin helps ensure all your locale/translation files have the same keys, preventing missing translations in your application.

Flat Config (eslint.config.js)

import i18nMessages from 'eslint-plugin-i18n-messages';

export default [
  {
    files: ['**/*.json'],
    languageOptions: {
      parser: i18nMessages.parser  // Use the bundled parser
    },
    plugins: {
      'i18n-messages': i18nMessages
    },
    rules: {
      'i18n-messages/identical-keys': ['error', {
        referenceFile: 'locales/en.json'
      }]
    }
  }
];

Or if you prefer to use your own parser installation:

import i18nMessages from 'eslint-plugin-i18n-messages';
import jsoncParser from 'jsonc-eslint-parser';

export default [
  {
    files: ['**/*.json'],
    languageOptions: {
      parser: jsoncParser
    },
    plugins: {
      'i18n-messages': i18nMessages
    },
    rules: {
      'i18n-messages/identical-keys': ['error', {
        referenceFile: 'locales/en.json'
      }]
    }
  }
];

Legacy Config (.eslintrc.js)

module.exports = {
  overrides: [
    {
      files: ['*.json'],
      parser: 'jsonc-eslint-parser',
      plugins: ['i18n-messages'],
      rules: {
        'i18n-messages/identical-keys': ['error', {
          referenceFile: 'locales/en.json'
        }]
      }
    }
  ]
};

Using the Recommended Config (Legacy only)

module.exports = {
  extends: ['plugin:i18n-messages/recommended'],
  rules: {
    'i18n-messages/identical-keys': ['error', {
      referenceFile: 'locales/en.json'  // You still need to specify your reference file
    }]
  }
};

Rule: identical-keys

Ensures all locale files have identical keys to a reference file.

Options

  • referenceFile (required): Path to the reference locale file. Supports glob patterns.
  • excludeReference (optional, default: true): Whether to exclude the reference file from linting.

Examples

Basic usage

{
  'i18n-messages/identical-keys': ['error', {
    referenceFile: 'src/locales/en.json'
  }]
}

Using glob patterns

{
  'i18n-messages/identical-keys': ['error', {
    referenceFile: 'src/locales/**/en.json'
  }]
}

Include reference file in linting

{
  'i18n-messages/identical-keys': ['error', {
    referenceFile: 'src/locales/en.json',
    excludeReference: false
  }]
}

How it works

The plugin compares the keys in each locale file against the reference file and reports:

  • Missing keys: Keys that exist in the reference file but not in the current file
  • Extra keys: Keys that exist in the current file but not in the reference file

Example

Given a reference file en.json:

{
  "welcome": "Welcome",
  "goodbye": "Goodbye"
}

And a locale file fr.json:

{
  "welcome": "Bienvenue"
}

ESLint will report:

Missing 1 key from reference file (locales/en.json): "goodbye"

Nested keys

The plugin supports nested object structures:

{
  "auth": {
    "login": "Login",
    "logout": "Logout"
  }
}

Keys are flattened as auth.login and auth.logout for comparison.

Requirements

  • Node.js >= 16.0.0
  • ESLint >= 8.0.0
  • jsonc-eslint-parser >= 2.0.0 (bundled)

Project Structure

src/
├── index.ts              # Main plugin entry point
├── types.ts              # TypeScript type definitions
├── rules/
│   └── identical-keys.ts # Main rule implementation
└── utils/
    ├── ast-helpers.ts         # AST node finding utilities
    ├── find-project-root.ts   # Project root detection
    ├── find-reference-file.ts # Reference file resolution
    ├── get-keys.ts            # Key extraction from objects
    └── index.ts               # Utility exports

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT