eslint-plugin-t

1.7.1 • Public • Published

eslint-plugin-t

This plugin contains lint rules related to internationalization, particularly for strings wrapped in t().

Installation

  1. Add eslint-plugin-t to your devDependencies.

  2. Add t to the plugins section of your ESLint configuration.

{
  "plugins": ["t"]
}
  1. Enable the rule(s) that you want ESLint to enforce.
{
  "rules": {
    "t/string-literal": "warn"
  }
}

Rules

There's currently just one lint rule in this package.

string-literal

This rule enforces that the first argument to t() is a string literal. This is useful if you intend to statically extract language strings because static tooling can't evaluate expressions.

Example:

// Correct usage (no lint warning)
alert(t('Hello World!'));

// Incorrect usage (raises lint warning)
alert(t('Hello ' + Math.random().toString()));

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-t

Weekly Downloads

484

Version

1.7.1

License

ISC

Unpacked Size

5.91 kB

Total Files

3

Last publish

Collaborators

  • eslint-tools