The module includes an ESLint plugin that warns when using useRuntimeConfig() instead of the type-safe useSafeRuntimeConfig().
If you use @nuxt/eslint, the rule is auto-registered. No configuration needed.
npx nuxi module add @nuxt/eslint
The rule works immediately.
Add to your eslint.config.mjs:
import { configs } from 'nuxt-safe-runtime-config/eslint'
export default [
configs.recommended,
// ... your other configs
]
import plugin from 'nuxt-safe-runtime-config/eslint'
export default [
{
plugins: { 'safe-runtime-config': plugin },
rules: { 'safe-runtime-config/prefer-safe-runtime-config': 'warn' },
},
]
Warns when using useRuntimeConfig() and suggests useSafeRuntimeConfig().
const config = useRuntimeConfig()
const config = useSafeRuntimeConfig()
The rule supports auto-fix. Run:
eslint --fix .
All useRuntimeConfig() calls are replaced with useSafeRuntimeConfig().
rules: {
'safe-runtime-config/prefer-safe-runtime-config': ['warn', {
// No options currently
}]
}
'warn' (recommended) - shows warning, doesn't fail CI'error' - fails lint, blocks CI'off' - disables the rule