Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-i18next

edvardchen937.6kISC6.1.1TypeScript support: included

ESLint plugin for i18n

eslint, eslintplugin, eslint-plugin, i18n, i10next, internationalization, localization

readme

eslint-plugin-i18next

ESLint plugin for i18n

For old versions below v6, plz refer this document

Installation

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

Usage

For ESLint 9 flat configuration,

// eslint.config.mjs
import i18next from 'eslint-plugin-i18next';

export default [
  // your other configs
  i18next.configs['flat/recommended'],
];

For ESLint 8 and below,

// .eslintrc
{
  "extends": ["plugin:i18next/recommended"]
}

Rule no-literal-string

This rule aims to avoid developers to display literal string directly to users without translating them.

Note: Disable auto-fix because key in the call i18next.t(key) usually was not the same as the literal

Example of incorrect code:

/*eslint i18next/no-literal-string: "error"*/
<div>hello world</div>

Example of correct code:

/*eslint i18next/no-literal-string: "error"*/
<div>{i18next.t('HELLO_KEY')}</div>

More options can be found here

Breaking change

By default, it will only validate the plain text in JSX markup instead of all literal strings in previous versions. You can change it easily

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

6.1.1 (2024-11-24)

6.1.0 (2024-09-14)

Features

6.0.11 (2024-09-12)

6.0.10 (2024-07-20)

6.0.9 (2024-07-13)

6.0.8 (2024-07-13)

6.0.7 (2024-07-07)

6.0.6 (2024-05-14)

6.0.5 (2023-10-26)

6.0.4 (2023-08-01)

6.0.3 (2023-06-13)

6.0.2 (2023-06-06)

6.0.1 (2023-05-05)

6.0.0 (2023-04-26)

6.0.0-8 (2023-03-23)

6.0.0-7 (2023-03-20)

Features

  • treat template literals without expressions as normal strings (f740c1f)

Bug Fixes

6.0.0-6 (2022-11-21)

6.0.0-5 (2022-07-14)

Bug Fixes

  • corrected typo (9fba5c2)
  • remove the problematic typescript validation (a021fe0)

6.0.0-4 (2022-05-31)

6.0.0-3 (2022-05-18)

Bug Fixes

  • support to ignore member expression in assignments (178b703)

6.0.0-2 (2022-05-15)

Bug Fixes

  • validate correctly call chains (dc33346), closes #54

6.0.0-1 (2022-05-15)

Features

6.0.0-0 (2022-05-15)

Features

  • make mode defaults to jsx-text-only (7cc75ab)
  • support callees option (1934216)
  • support option jsx-attributes (08ae48b)
  • support option jsx-components (99af7e1)
  • support option mode (3193108)
  • support option object-properties (484fcfb)
  • support option words (874a694)

5.2.1 (2022-05-05)

5.2.0 (2022-05-05)

Features

  • adding message as config option (4ce1b18)

5.1.3 (2022-05-05)

5.1.2 (2021-09-12)

5.1.1 (2021-04-08)

Bug Fixes

  • ignore strings as object property name (e70bb8f), closes #42

5.1.0 (2021-03-28)

Features

5.0.0 (2020-09-17)

Features

5.0.0-1 (2020-09-02)

Bug Fixes

  • recognize react JSXFragment (719f496)

5.0.0-0 (2020-08-28)

⚠ BREAKING CHANGES

  • maybe break in some cases although all test cases passed

  • reuse all rules to template literal (b5cdda6), closes #20

4.5.0 (2020-08-11)

Features

  • add option validateTemplate (ba0ec60)

4.4.0 (2020-08-03)

Bug Fixes

Features

4.3.0 (2020-07-21)

Features

4.2.0 (2020-07-01)

Bug Fixes

Features

  • allow ignoring lists of components (eebb338)

4.1.0 (2020-06-30)

Features

  • support multibyte characters (99ed9f2)

4.0.0 (2020-06-28)

⚠ BREAKING CHANGES

  • all patterns in ignoreCallee would be treated as regular expression

Features

  • allow regex in ignore and ignoreCallee (0cfe340), closes #19

3.8.0 (2020-06-03)

Features

3.7.0 (2020-05-06)

Features

3.6.0 (2020-04-17)

Features

  • support to access enum value through string like Enum['key'] (db68147)

3.5.0 (2020-04-16)

Features

  • ignore JSX attrs style and key (34a5d6d)

3.4.0 (2020-04-14)

Features

  • recognize ImportExpresion (e54daee)

3.3.0 (2020-02-11)

Features

3.2.0 (2019-10-21)

Features

  • allow displayName property in classes (5362281)

3.1.1 (2019-10-10)

Bug Fixes

  • add missing plugin in recommended config (dde83ed)

3.1.0 (2019-10-10)

Features

3.0.0 (2019-10-09)

⚠ BREAKING CHANGES

  • SInce the whitelist was cut short, it would complain when the removed attributes were added to custom component like <Foo src="hello" />

Features

2.5.0 (2019-10-08)

Features

  • add more ignored attributes and callee (0f9e2ec)

2.4.0 (2019-10-08)

Features

  • add ignoreAttribute option (c854313)

2.3.1 (2019-09-16)

Bug Fixes

  • whitelist addEventListener and few SVG attributes (46241a6)

2.3.0 (2019-07-26)

Features

  • skip literal in SwitchCase statement (d270343), closes #2

2.2.0 (2019-07-24)

Bug Fixes

  • enhance ExportNamedDeclaration (29e9f29)

Features

  • allow string comparison (a78d150)

2.1.1 (2019-07-24)

2.1.0 (2019-07-11)

Features

2.0.0 (2019-07-10)

Bug Fixes

  • wrongly handle Literal node in VExpressionContainer (dd279c6)

Features

  • dont check literal in export declaration (1527eae)
  • dont check TSLiteralType (fd93861)

refactor

  • use rule selectors to reduce code complexity (28d73ff)

BREAKING CHANGES

  • Disable fix because key in the call i18next.t(key) ussally was not same as the plain text

1.2.0 (2019-06-20)

Features

  • skip checking import(...) (7306038)

1.1.3 (2019-04-08)

Bug Fixes

  • disallow uppercase strings in JSX (715cba4)

1.1.2 (2019-04-08)