Registry / testing / eslint-plugin-gettext

eslint-plugin-gettext

JSON →
library1.2.0jsnpmunverified

ESLint plugin providing linting rules for gettext internationalization API usage. Version 1.2.0 (latest stable) released in 2023. It enforces best practices such as preventing non-literal arguments in gettext calls and ensuring positional markers for multiple variables. Unlike generic i18n linting, this plugin targets gettext specifically, supporting both Jed and Django JS Catalog integrations. Designed for Node.js >=6.0.0, it requires ESLint as a peer dependency and is maintained by App Annie.

npm install eslint-plugin-gettext
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-GETT
E
eslint-plugin-gettext
testingjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

plugin reference in ESLint config
"plugins": ["gettext"]
"plugins": ["eslint-plugin-gettext"]
ESLint automatically resolves the full package name; use the short form 'gettext' in plugins array.
no-variable-string rule
"gettext/no-variable-string": "error"
"no-variable-string": "error"
Rule names must be prefixed with the plugin namespace in ESLint config.
required-positional-markers-for-multiple-variables rule
"gettext/required-positional-markers-for-multiple-variables": "error"
"gettext/require-positional-markers": "error"
The full rule name is required; no shorthand alias exists.

Configures ESLint with gettext plugin and enables two rules to catch invalid gettext calls.

// .eslintrc.json { "plugins": ["gettext"], "rules": { "gettext/no-variable-string": "error", "gettext/required-positional-markers-for-multiple-variables": "error" } } // Example file that will trigger errors: gettext(variable); // Error: no-variable-string gettext('%d cats %s dogs'); // Error: missing positional markers
Debug
Known issues
gotchaRule no-variable-string rejects all non-literal arguments including computed strings like gettext('prefix' + suffix).
fix
Always use static string literals: gettext('static string').
affects: >=1.0.0
gotchaThe plugin requires ESLint as a peer dependency, not installed automatically.
fix
Run 'npm install eslint --save-dev' alongside this plugin.
affects: >=1.0.0
gotchaRule required-positional-markers-for-multiple-variables only works with %d and %s placeholders; other placeholders may bypass the rule.
fix
Ensure strings with multiple variables use positional markers like %1$s %2$d.
affects: >=1.0.0
gotchaPlugin does not support custom gettext function names; only gettext, ngettext, pgettext, npgettext are checked.
fix
If using a different function name, manually alias or wrap calls.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'gettext': Cannot find module 'eslint-plugin-gettext'
Plugin not installed or ESLint cannot resolve it.
fix
Run 'npm install eslint-plugin-gettext --save-dev' and ensure node_modules is correct.
Error: ESLint couldn't find the rule 'gettext/no-variable-string'
Rule name is misspelled or plugin not loaded in config.
fix
Add 'plugins: ["gettext"]' to ESLint config and use the full rule name 'gettext/no-variable-string'.
Error: ESLint requires that plugins be installed separately: eslint-plugin-gettext
Attempting to use plugin without installing it.
fix
Run 'npm install eslint-plugin-gettext --save-dev' and check peer dependency eslint.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources