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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-plugin-i18next-aid

v1.1.0

Published

Detects translation keys in use which are missing from translation files

Readme

eslint-plugin-i18next-no-undefined-translation-keys

Why?

This is a fork of the original eslint-plugin-i18next-no-undefined-translation-keys plugin but with some extra features.

What?

This plugin gives you two rules:

  • translation-key-string-literal - Asserts that translation keys should be string literals only - otherwise, we can't statically analyze them
  • no-undefined-translation-keys - Detects translation keys in your code which are missing from translation files

These are intended to be used in conjunction with:

  • i18n-json/valid-json (who doesn't love well-formed JSON?)
  • i18n-json/identical-keys (ensures that amongst all of your languages, the exact same set of keys is defined)
  • i18n-json/sorted-keys (optional, but it is nice to have your keys alphabetized)

Operational Note:

Since we know that translations for other languages aren't immediately available, the recommendation here is to put empty strings in place where you are still waiting for a translation. Then, on whatever cadence makes sense, you can run a recursive check on each file to source the empty strings and batch those together for the translators to work on.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-i18next-aid:

npm install eslint-plugin-i18next-aid --save-dev

Usage

Add i18next-aid to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["i18next-aid"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "i18next-aid/translation-key-string-literal": "error",
    "i18next-aid/no-undefined-translation-keys": [
      "error",
      {
        "namespaceTranslationMappingFile": "namespaceMapping.json",
        "defaultNamespace": "default"
      }
    ]
  }
}

Allowing t.has() Protected Conditionals

If you need to use dynamic translation keys that are guarded by t.has(), you can enable the allow-t-has-protected-conditionals option:

{
  "rules": {
    "i18next-aid/translation-key-string-literal": [
      "error",
      "allow-t-has-protected-conditionals"
    ]
  }
}

This allows patterns like:

// ✅ Valid with allow-t-has-protected-conditionals
const label = t.has(item.labelKey) ? t(item.labelKey) : item.labelKey;

// ✅ Also works with multi-line formatting
const label = t.has(item.labelKey) ? t(item.labelKey) : item.labelKey;

// ❌ Still invalid - keys must match
const label = t.has(keyA) ? t(keyB) : fallback;

And your namespaceMapping.json file should map your namespaces to translation file paths like so:

{
  "shared": "packages/shared/lang/en.json",
  "unitsOfMeasure": "packages/shared/lang/uom-en.json",
  "user": "packages/user/lang/en.json"
}

For those who don't use i18next namespaces (most people), you can skip defining defaultNamespace, and your namespaceMapping.json file can be as simple as this:

{
  "default": "libs/path/to/your/english.json"
}

Note: The no-undefined-translation-keys rule will ignore any non-string-literal calls to t().

Supported Rules

  • i18next-aid/translation-key-string-literal
  • i18next-aid/no-undefined-translation-keys