Skip to content

agama-project/eslint-plugin-agama-i18n

Repository files navigation

The ESLint Plugin

NPM Version CI

This directory contains a simple ESLint plugin which checks that only string literals are passed to the translation functions.

It is closely tied to the Agama project and probably does not make much sense for other projects.

Installation

Run

npm install --save-dev @agama-project/eslint-plugin-agama-i18n

Update your ESLint configuration:

// eslint.config.mjs
import agamaI18nEslintPlugin from "@agama-project/eslint-plugin-agama-i18n";

export default [
  {
    plugins: {
      "agama-i18n": agamaI18nEslintPlugin,
    },
  },
  {
    rules: {
      "agama-i18n/string-literals": "error",
    }
  }
];

Disabling the Check

In some rare cases using a variable instead of a string literal is correct. In that case disable the check locally:

const SIZES = [ N_("small"), N_("medium"), N_("large") ];

// returns one of the sizes above
const sz = getSize();

// eslint-disable-next-line agama-i18n/string-literals
return <span>{_(sz)}</span>;

Publishing new version

The NPM package is automatically published by a GitHub Action when a version tag is created.

To create a new tag update the version in package.json and run the npm run tag command.

Links

About

Simple ESLint plugin for checking translation functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published