Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the generated composable name is properly formatted #522

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

franklin-tina
Copy link
Contributor

@franklin-tina franklin-tina commented Oct 18, 2024

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The current implementation assumes users will run the command to generate a composable as follows:

  1. prefixed with use
    nuxi add composable useSomeComposable
// useSomeComposable.ts
export const useSomeComposable = () => {
  return ref()
}
  1. without use prefix
    nuxi add composable someComposable
// someComposable.ts
export const useSomeComposable = () => {
  return ref()
}

However, if the user runs these commands with the names in kebab case, the resulting function will be broken:

  1. prefixed with use
    nuxi add composable use-some-composable
// use-some-composable.ts
export const use-some-composable = () => {
  return ref()
}
  1. without use prefix
    nuxi add composable some-composable
// some-composable.ts
export const useSome-composable = () => {
  return ref()
}

This PR ensures the resulting composable function is properly formatted, regardless of whether or not the user uses kebab case or camelCase in their composable definition:

use-some-composable β†’ useSomeComposable
good β†’ useGood
someGoodComposable β†’ useSomeGoodComposable
usegood-composable β†’ useGoodComposable

@franklin-tina franklin-tina changed the title Ensure the generate composable name is properly formatted Ensure the generated composable name is properly formatted Oct 18, 2024
@franklin-tina franklin-tina marked this pull request as ready for review October 18, 2024 23:00
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you ❀️

@danielroe danielroe merged commit bf4b9a7 into nuxt:main Oct 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants