gt-next Lint
ESLint plugin for gt-next components.
GT Next Lint
This is in alpha. Subject to change.
An ESLint plugin that catches common translation errors in gt-next components.
Installation
npm install --save-dev @generaltranslation/gt-next-lintConfiguration
Add to your eslint.config.mjs:
import gtNext from "@generaltranslation/gt-next-lint";
export default [
{
plugins: { 'gt-next': gtNext },
rules: {
'gt-next/no-dynamic-jsx': 'warn',
'gt-next/no-dynamic-string': 'warn',
},
},
];Rules
no-dynamic-jsx
Wrap dynamic content in <T> components using variable components.
// ❌ Wrong
<T>Hello {userName}!</T>
// ✅ Correct
<T>Hello <Var>{userName}</Var>!</T>no-dynamic-string
Allows only string literals in translation functions.
const t = useGT();
// ❌ Wrong
t(`Hello ${name}`)
t('Hello ' + name)
// ✅ Correct
t('Hello, {name}!', { name })Supported components
<Var>- Variables<DateTime>- Dates<Num>- Numbers<Currency>- Currency
Supported functions
useGT- Client-side translations
How is this guide?