---
title: "ESLint"
description: "Find every untyped useRuntimeConfig() call and rewrite it to useSafeRuntimeConfig() with one eslint --fix."
canonical_url: "https://nuxt-safe-runtime-config.onmax.me/guide/eslint"
---
# ESLint

> Find every untyped useRuntimeConfig() call and rewrite it to useSafeRuntimeConfig() with one eslint --fix.

After you add a schema, every existing `useRuntimeConfig()` call still returns the old, untyped config. The `prefer-safe-runtime-config` rule reports those calls, and its fix renames them to `useSafeRuntimeConfig()` with the same arguments:

```ts
const config = useRuntimeConfig(event) // reported
const config = useSafeRuntimeConfig(event) // after --fix
```

## Set it up

With [@nuxt/eslint](https://eslint.nuxt.com), the module registers the rule at `warn` as soon as it has a schema. There is nothing to add.

Without it, add the recommended config, which also sets `warn`:

```js [eslint.config.mjs]
import { configs } from 'nuxt-safe-runtime-config/eslint'

export default [
  configs.recommended,
]
```

To pick the severity, register the plugin yourself:

```js [eslint.config.mjs]
import safeRuntimeConfig from 'nuxt-safe-runtime-config/eslint'

export default [
  {
    plugins: { 'safe-runtime-config': safeRuntimeConfig },
    rules: { 'safe-runtime-config/prefer-safe-runtime-config': 'error' },
  },
]
```

## Migrate an app

Run the fix once to move every call:

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

Then set the rule to `'error'`, so a new `useRuntimeConfig()` call fails CI.


## Sitemap

See the full [sitemap](https://nuxt-safe-runtime-config.onmax.me/sitemap.md) for all pages.
