# General Translation React SDKs (gt-react, gt-next, gt-react-native): Linting your code
URL: https://generaltranslation.com/en-US/docs/react/guides/linting-your-code.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: How to catch common internationalization mistakes with the General Translation ESLint plugin.

The General Translation ESLint plugin, `@generaltranslation/react-core-linter`, catches common integration mistakes — dynamic content inside [`<T>`](/docs/react/reference/components/t), non-static strings in translation functions, and unsupported attributes — and can auto-fix many of them. It works across `gt-react`, `gt-next`, and `gt-react-native`.

*Note: The plugin is pre-1.0 (`0.1.x`) and its rules may change.*

## Install the plugin [#install]

Add the plugin as a development dependency.

<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
  <Tab value="npm">
    ```bash
    npm install --save-dev @generaltranslation/react-core-linter
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add --dev @generaltranslation/react-core-linter
    ```
  </Tab>

  <Tab value="bun">
    ```bash
    bun add --dev @generaltranslation/react-core-linter
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm add --save-dev @generaltranslation/react-core-linter
    ```
  </Tab>
</Tabs>

## Configure ESLint [#configure]

Add the plugin's `recommended` config to your flat ESLint config. It enables every rule as an error.

<Tabs items={['React', 'Next.js', 'TanStack Start', 'React Native']}>
  <Tab value="React">
    ```js title="eslint.config.js"
    import gtLint from '@generaltranslation/react-core-linter';

    export default [
      gtLint.configs.recommended,
    ];
    ```
  </Tab>

  <Tab value="Next.js">
    Compose the recommended config alongside `eslint-config-next`.

    ```js title="eslint.config.mjs"
    import { defineConfig, globalIgnores } from 'eslint/config';
    import nextVitals from 'eslint-config-next/core-web-vitals';
    import nextTs from 'eslint-config-next/typescript';
    import gtLint from '@generaltranslation/react-core-linter';

    export default defineConfig([
      ...nextVitals,
      ...nextTs,
      gtLint.configs.recommended,
      globalIgnores(['.next/**', 'out/**', 'build/**', 'next-env.d.ts', 'eslint.config.*']),
    ]);
    ```
  </Tab>

  <Tab value="TanStack Start">
    The rules detect translation components and functions by their import source. `gt-tanstack-start` is not in the default list, so add it with the [`libs`](/docs/react/reference/lint-rules#libs) option on each rule.

    ```js title="eslint.config.js"
    import gtLint from '@generaltranslation/react-core-linter';

    const libs = ['gt-tanstack-start'];

    export default [
      {
        plugins: { '@generaltranslation/react-core-linter': gtLint },
        rules: {
          '@generaltranslation/react-core-linter/static-jsx': ['error', { libs }],
          '@generaltranslation/react-core-linter/static-string': ['error', { libs }],
          '@generaltranslation/react-core-linter/no-data-attrs-on-branch': ['error', { libs }],
        },
      },
    ];
    ```
  </Tab>

  <Tab value="React Native">
    ```js title="eslint.config.js"
    import gtLint from '@generaltranslation/react-core-linter';

    export default [
      gtLint.configs.recommended,
    ];
    ```
  </Tab>
</Tabs>

Run ESLint as usual; add `--fix` to apply the auto-fixes.

```bash
npx eslint . --fix
```

## What the rules catch [#rules]

The `recommended` config turns on three rules, all as errors:

- **[`static-jsx`](/docs/react/reference/lint-rules#static-jsx)** — flags dynamic content inside [`<T>`](/docs/react/reference/components/t) and requires it to be wrapped in a variable component ([`<Var>`](/docs/react/reference/components/var), [`<Num>`](/docs/react/reference/components/num), [`<Currency>`](/docs/react/reference/components/currency), or [`<DateTime>`](/docs/react/reference/components/datetime)). Auto-fixable.
- **[`static-string`](/docs/react/reference/lint-rules#static-string)** — requires translation functions ([`useGT`](/docs/react/reference/hooks/use-gt), [`getGT`](/docs/node/reference/functions/get-gt), [`msg`](/docs/react/reference/functions/msg)) to receive static string literals, and steers dynamic values into ICU interpolation such as `gt('Hello, {name}!', { name })`. Auto-fixable.
- **[`no-data-attrs-on-branch`](/docs/react/reference/lint-rules#no-data-attrs)** — flags `data-*` attributes on [`<Branch>`](/docs/react/reference/components/branch), which the component ignores.

See the [lint rules reference](/docs/react/reference/lint-rules) for each rule's options and examples.

## Next steps

- /docs/react/guides/translating-jsx
- /docs/react/guides/translating-strings
- /docs/react/guides/formatting-variables
- /docs/react/guides/handling-plurals-and-branches

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
