Registry / testing / eslint-plugin-t

eslint-plugin-t

JSON →
library1.7.1jsnpmunverified

An ESLint plugin providing lint rules for internationalization, especially for strings wrapped in `t()` calls. The current stable version is 1.7.1. It helps enforce consistent use of translation function `t()` and can detect missing translations or incorrect usage. Compared to other i18n lint plugins, it focuses specifically on the `t()` pattern used in many JavaScript projects. Release cadence is irregular as it's a smaller community project.

npm install eslint-plugin-t
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-T
E
eslint-plugin-t
testingjavascriptv1.7.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
import plugin from 'eslint-plugin-t'
const plugin = require('eslint-plugin-t')
ESM-only since v1; use import for ES modules
rules
import { rules } from 'eslint-plugin-t'
const { rules } = require('eslint-plugin-t')
Named export 'rules' is available with ESM
t-no-literal-string
import { rules: { 't-no-literal-string': rule } } from 'eslint-plugin-t'
const { t-no-literal-string } = require('eslint-plugin-t')
Rule names are not top-level exports; access via rules object

Shows basic setup of eslint-plugin-t with two rules and demonstrates linting behavior on t() usage.

// .eslintrc.js module.exports = { plugins: ['t'], rules: { 't/no-literal-string': 'error', 't/no-unused-t': 'warn', }, }; // Source code with t() const msg = t('Hello World'); // allowed const bad = 'Hello World'; // error with no-literal-string
Debug
Known issues
breakingVersion 1.0.0 changed default export from object with rules to a plugin object requiring different import
fix
Update import to use 'eslint-plugin-t' and configure rules under plugins and rules
affects: <1.0.0
deprecatedRule 't/no-literal-string' was deprecated in v1.5.0 in favor of 't/valid-t-usage'
fix
Replace 't/no-literal-string' with 't/valid-t-usage'
affects: >=1.5.0
gotchaIf using TypeScript, the plugin may not recognize t() calls without type information; need to define t() signature in global types
fix
Add declare function t(key: string): string; in your project's types
affects: >=1.0.0
breakingVersion 1.7.0 changed rule configs to use severity strings 'error'/'warn' instead of numbers 2/1
fix
Update rule configs to use 'error' or 'warn' strings
affects: <1.7.0
Errors
Common errors & fixes
Error: Failed to load plugin 't': Cannot find module 'eslint-plugin-t'
Missing dependency or not installed as a dev dependency
fix
Run npm install --save-dev eslint-plugin-t
ESLint: Rule 't/no-literal-string' is not defined
Plugin not added to plugins array in ESLint config
fix
Add 't' to the plugins array in your ESLint config
TypeError: Cannot read properties of undefined (reading 't-no-literal-string')
Incorrect import or destructuring of rules from plugin
fix
Access rules via imported plugin object: plugin.rules['t-no-literal-string']
Upgrade
Version history
1.7.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to run the plugin
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-t — npm install eslint-plugin-t · libregistry