|
| 1 | +# eslint-plugin-lingui-typescript |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/eslint-plugin-lingui-typescript) |
| 4 | +[](https://github.com/user/eslint-plugin-lingui-typescript/actions/workflows/ci.yml) |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | + |
| 7 | +ESLint plugin for [Lingui](https://lingui.dev/) with TypeScript type-aware rules. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- 🔍 Detects incorrect usage of Lingui translation macros |
| 12 | +- 📝 Enforces simple, safe expressions inside translated messages |
| 13 | +- 🎯 Detects missing localization of user-visible text |
| 14 | +- 🧠 Respects TypeScript types to avoid false positives (e.g. string literal unions) |
| 15 | + |
| 16 | +## Requirements |
| 17 | + |
| 18 | +- Node.js ≥ 24 |
| 19 | +- ESLint ≥ 9 |
| 20 | +- TypeScript ≥ 5 (optional, for type-aware rules) |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +```bash |
| 25 | +npm install --save-dev eslint-plugin-lingui-typescript |
| 26 | +``` |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### ESLint Flat Config (eslint.config.ts) |
| 31 | + |
| 32 | +```ts |
| 33 | +import linguiPlugin from "eslint-plugin-lingui-typescript" |
| 34 | + |
| 35 | +export default [ |
| 36 | + // Use recommended config |
| 37 | + linguiPlugin.configs["flat/recommended"], |
| 38 | + |
| 39 | + // Or configure rules manually |
| 40 | + { |
| 41 | + plugins: { |
| 42 | + "lingui-ts": linguiPlugin |
| 43 | + }, |
| 44 | + rules: { |
| 45 | + "lingui-ts/no-single-variable-message": "error" |
| 46 | + } |
| 47 | + } |
| 48 | +] |
| 49 | +``` |
| 50 | + |
| 51 | +## Rules |
| 52 | + |
| 53 | +| Rule | Description | Recommended | |
| 54 | +|------|-------------|:-----------:| |
| 55 | +| [no-single-variable-message](docs/rules/no-single-variable-message.md) | Disallow messages that consist only of a single variable | ✅ | |
| 56 | + |
| 57 | +### Planned Rules |
| 58 | + |
| 59 | +- `no-complex-expressions-in-message` — Restrict complexity of expressions in messages |
| 60 | +- `no-nested-macros` — Disallow nesting Lingui macros |
| 61 | +- `no-single-tag-message` — Disallow messages with only a single markup tag |
| 62 | +- `valid-t-call-location` — Enforce valid locations for `t` macro calls |
| 63 | +- `no-unlocalized-strings` — Detect user-visible strings not wrapped in Lingui |
| 64 | +- `text-restrictions` — Enforce project-specific text restrictions |
| 65 | +- `consistent-plural-format` — Ensure consistent plural usage |
| 66 | + |
| 67 | +## License |
| 68 | + |
| 69 | +[MIT](LICENSE) |
| 70 | + |
0 commit comments