{"id":19951,"library":"eslint-plugin-string-to-lingui","title":"ESLint Plugin String to Lingui","description":"An ESLint plugin (v0.25.0, actively maintained) that enforces proper usage of the Lingui internationalization library. It includes rules to detect untranslated strings, enforce `t` calls inside functions for dynamic language switching, prevent incorrect i18n macro usage, and validate message consistency against a reference JSON file. Key differentiators include support for JSX text, template literals, and customizable ignore patterns, making it suitable for large codebases migrating to Lingui v3+.","status":"active","version":"0.25.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eslint","eslintplugin","eslint-plugin"],"install":[{"cmd":"npm install eslint-plugin-string-to-lingui","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-string-to-lingui","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-string-to-lingui","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin functionality","package":"eslint","optional":false}],"imports":[{"note":"ESLint automatically strips the 'eslint-plugin-' prefix when referencing in .eslintrc","wrong":"plugins: ['eslint-plugin-string-to-lingui']","symbol":"plugin","correct":"plugins: ['string-to-lingui']"}],"quickstart":{"code":"// .eslintrc.json\n{\n  \"plugins\": [\"string-to-lingui\"],\n  \"rules\": {\n    \"string-to-lingui/missing-lingui-transformation\": \"error\",\n    \"string-to-lingui/t-call-in-function\": \"warn\",\n    \"string-to-lingui/macro-inside-t-and-i18\": \"error\",\n    \"string-to-lingui/t-should-be-before-macro\": \"warn\",\n    \"string-to-lingui/no-single-variables-to-translate\": \"warn\",\n    \"string-to-lingui/check-en-messages\": [\"warn\", {\n      \"sourcePath\": \"path/to/en/messages.json\",\n      \"similarityThreshold\": 0.9,\n      \"maxSuggestions\": 3\n    }],\n    \"string-to-lingui/text-restrictions\": [\"error\", {\n      \"rules\": [{\n        \"patterns\": [\"''\", \"’\", \"“\"],\n        \"message\": \"Use straight quotes and apostrophes.\"\n      }]\n    }],\n    \"string-to-lingui/forbid-i18n-calls\": [\"error\", {\n      \"rules\": [\n        { \"handlerName\": \"_\", \"message\": \"Use t`` from '@lingui/macro' instead\" },\n        { \"handlerName\": \"number\", \"message\": \"Use formatCurrency or formatNumber instead\" }\n      ]\n    }]\n  }\n}","lang":"json","description":"Configure all 8 ESLint rules to enforce Lingui best practices: detect untranslated strings, ensure t calls in functions, validate macros, and check messages against a reference file."},"warnings":[{"fix":"Use the exact rule name 'string-to-lingui/no-single-varibles-to-translate' in your configuration.","message":"The rule 'no-single-varibles-to-translate' has a typo in its name ('varibles' instead of 'variables'). This is intentional for backward compatibility, but may cause confusion.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'string-to-lingui/t-call-in-function' instead.","message":"The rule 'i18n-number-call-in-function' is deprecated and likely replaced by 't-call-in-function' or a more general rule.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Add additional rules for any i18n methods you want to forbid.","message":"The 'forbid-i18n-calls' rule may not cover all i18n methods (e.g., 'i18n.date'). Custom rules may be needed.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Replace the array with an object: [\"warn\", { \"sourcePath\": \"...\" }]","cause":"The 'check-en-messages' rule expects an object, not an array.","error":"Configuration for rule \"string-to-lingui/check-en-messages\" is invalid: value.forEach is not a function"},{"fix":"Ensure the rule configuration includes an object: [\"error\", { \"ignore\": [\"rgba\"] }]","cause":"The 'missing-lingui-transformation' rule is missing its options object when using sub-options like 'ignore'.","error":"Cannot read property 'some' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}