---
source: https://cli.eloqnt.dev/docs/lint-rules/orphan-message
docs_index: https://cli.eloqnt.dev/llms.txt
---

# orphan-message

Flags a message in your source locale that is not referenced by source code.

This rule is detected by scanning [`srcPath`](https://cli.eloqnt.dev/docs/configuration#srcPath) (currently limited to `next-intl`), or from formats that track this state themselves, like the stale entries of [Apple String Catalogs](https://cli.eloqnt.dev/docs/formats/apple-xcstrings#workflow-states).

## Why this is bad

A message nothing references becomes dead code and should be removed.

## Examples

Given source code that only ever calls `t('save')`.

Examples of **incorrect** code for this rule:

```json title="messages/en.json"
{
  "save": "Save",
  "discard": "Discard"
}
```

Examples of **correct** code for this rule:

```json title="messages/en.json"
{
  "save": "Save"
}
```

## False positives

The `orphan-message` rule depends on your app being [statically analyzable](https://cli.eloqnt.dev/docs/guides/static-analysis).

For example, this call site can not track which messages you actually reference:

```tsx
import navigationItems from './navigationItems';

function Navigation() {
  const t = useTranslations();

  return (
    <nav aria-label={t('navigation.label')}>
      {navigationItems.map((item) => (
        // ❌ Not statically analyzable
        <a key={item.key} href={item.href}>
          {t(item.key)}
        </a>
      ))}
    </nav>
  );
}
```

When adopting eloqnt/cli later on in a project, it can be time-consuming to restructure your app to follow these rules. At first, you might get a number of violations here if the corresponding call sites can't be found.

While it's suggested to restructure your code to avoid the violations, you can alternatively turn the rule off in general via [`lint.rules`](https://cli.eloqnt.dev/docs/configuration#lint-rules), or disable it granularly via [`lint.overrides`](https://cli.eloqnt.dev/docs/configuration#lint-overrides):

```ts title=".eloqnt/config.ts"
import {defineConfig} from '@eloqnt/cli';

export default defineConfig({
  lint: {
    overrides: [
      {
        // Keys under `navigation.items` come from a data file
        keys: 'navigation.items.*',
        rules: {'orphan-message': 'off'}
      }
    ]
  }
  // ...
});
```

Note however, that this also degrades the available context that is available for [`eloqnt translate`](https://cli.eloqnt.dev/docs/cli/translate).

---

For an index of every eloqnt/cli documentation page, see [https://cli.eloqnt.dev/llms.txt](https://cli.eloqnt.dev/llms.txt).
