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

@splunk/eslint-plugin-i18n

v0.6.0

Published

Splunk ESLint rules for i18n

Readme

@splunk/eslint-plugin-i18n

To make a given string available for translations it needs to be passed to one of those functions:

  • _
  • gettext
  • ungettext

This plugin aims to help you remember to call them and to help you use them correctly.

See ui-utils/Internationalization and Format to learn more.

This package provides extendable ESLint configuration objects. Currently, the following configs are available:

  • 'plugin:@splunk/eslint-plugin-i18n/react' - Recommended
  • 'plugin:@splunk/eslint-plugin-i18n/all' - For brand new projects
  • flatConfigs.react - Recommended flat config for ESLint 9
  • flatConfigs.all - Flat config for brand new projects

Install

Install the package and its dependencies. ESLint requires dependencies to be installed as peer dependencies. See this issue on github for more background.

Yarn

  1. Install the peer dependencies:
    yarn add -D eslint@^8
  2. Install the package:
    yarn add -D @splunk/eslint-plugin-i18n

NPM

  1. Install the peer dependencies:
    npm install --save-dev eslint@^8
  2. Install the package:
    npm install --save-dev @splunk/eslint-plugin-i18n

Usage

Legacy config (.eslintrc)

Add the appropriate entry to your eslint configuration:

{
    extends: ['plugin:@splunk/eslint-plugin-i18n/react'],
    plugins: ['@splunk/eslint-plugin-i18n'],
}

Flat config (eslint.config.js)

Import the plugin and use its flat config:

import i18nPlugin from '@splunk/eslint-plugin-i18n';

export default [
    i18nPlugin.flatConfigs.react,
];

You can enable or disable the rules independently, as well as overwrite any rules e.g.: for test files:

{
    extends: ['plugin:@splunk/eslint-plugin-i18n/react'],
    plugins: ['@splunk/eslint-plugin-i18n'],
    rules: {
        '@splunk/i18n/translating-variable': 2, // Enable additional rule
    },
    overrides: [
        {
            files: ['**/*.unit.*'],
            rules: {
                // disable them when appropriate
                '@splunk/i18n/translating-variable': 0,
                '@splunk/i18n/jsx-text': 0,
                '@splunk/i18n/jsx-attributes': 0,
                '@splunk/i18n/string-value': 0,
                '@splunk/i18n/sprintf-text': 0,
            },
        },
    ],
}

Rules

@splunk/i18n/translating-variable

Passing variables into translation won't work correctly when extracting them later for the translation.

Example of incorrect code for this rule:

    const SOME_TEXT = "Something that should be translated";
    function PrintTips2() {
        return (<h1>{_(SOME_TEXT)}</h1>)
    }

Example of correct code for this rule:

    function PrintTips2() {
        return (<h1>{_("Something that should be translated")}</h1>)
    }

Beware: it clashes with underscore library and will report on code like:

_(someArray).map(function(n){ return n * 2; });

In that case it's probably best to disable this rule.

@splunk/i18n/jsx-text

Example of incorrect code for this rule:

    function PrintTips2() {
        return (<h1>{"something2"}</h1>)
    }

Example of correct code for this rule:

    function PrintTips2() {
        return (<h1>{_("something2")}</h1>)
    }

If will ignore empty strings or one character strings like " % ". But, if you're concatenating strings then you should use variable substitution with sprintf instead.

@splunk/i18n/jsx-attributes

Translatable HTML attributes and Aria attributes must have translated values:

    'abbr',
    'alt',
    'aria-label',
    'aria-placeholder',
    'aria-roledescription',
    'aria-valuetext',
    'content',
    'download',
    'help',
    'label',
    'lang',
    'placeholder',
    'screenReaderText',
    'title',
    'tooltip',

Example of incorrect code for this rule:

    function PrintTips3() {
        return (<h1 title={'something3'}></h1>)
    }

Example of correct code for this rule:

    function PrintTips3() {
        return (<h1 title={_('something3')}></h1>)
    }

@splunk/i18n/string-value

This rule will trigger on any string variable that's not wrapped in a translation function. If will ignore empty strings or one character strings like: "", "." or "-", but it will generate a lot of false-positives if you happen to work a lot with hardcoded text values.

Example of incorrect code for this rule:

const SOME_TEXT = "Not translated";

Example of correct code for this rule:

const SOME_TEXT = _("Not translated");

@splunk/i18n/sprintf-text

This rule will trigger on any string variable passed directly to sprintf. If will ignore empty strings ones that mostly concatenate variables: "%s:%s", but you should enable it only for user-facing parts of the codebase.

Example of incorrect code for this rule:

sprintf("User %s", name)

Example of correct code for this rule:

sprintf(_("User %s"), name)