Nuxt · NUXT0079 · NUXT0080

Match composable exports to their file name

Finds Nuxt composable files whose auto-imported names do not match the file name or do not start with use.
NUXT0079NUXT0080vite-doctor/nuxtcomposablesinfoSuggestion

Run this rule

pnpm nuxt doctor --extends auto,nuxt/strict --rules nuxt/composables/export-name-matches-file

Why it matters

Nuxt auto-imports named exports from top-level composables/ files under their own names, and a default export under a name derived from the file name. When useCart.ts exports useShoppingCart, or fetch-user.ts default-exports a function that becomes fetchUser, readers cannot find a composable from its name or tell it is a composable at all.

Name the main export after the file (useCart.ts exports useCart; use-cart.ts also maps to useCart), and name files with default exports so the derived name starts with use. Run Nuxt prepare with the Doctor module to capture current composable scan evidence. Only files in that inventory are checked, respecting resolved layer source directories, disabled scanning, and ignored files. Index files, files without use* exports, and files where any use* export matches are not reported.

Example

Export the composable the file name promises

Before

// app/composables/useCart.ts
export function useShoppingCart() {
  return useState('cart', () => [])
}

After

// app/composables/useCart.ts
export function useCart() {
  return useState('cart', () => [])
}

Name default-export files with use

Before

// app/composables/fetch-user.ts (auto-imported as fetchUser)
export default function () {
  return useFetch('/api/user')
}

After

// app/composables/use-user.ts (auto-imported as useUser)
export default function () {
  return useFetch('/api/user')
}
Copyright © 2026