Match composable exports to their file name
nuxt/composables/export-name-matches-filesrc/rule-packs/nuxt/rules/nuxt/export-name-matches-file.ts Upstream docs 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.
Recommended fix
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.
Useful links
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')
}