Next.js Discord

Discord Forum

How do you guys name your components?

Answered
Chartreux posted this in #help-forum
Open in Discord
ChartreuxOP
I usually name my component files using PascalCase, but I’ve noticed that most code uses kebab-case. Using a different naming method won’t cause any specific issues later, right? Is there a convention for this? This got me overthinking
Answered by Asian black bear
This is why many devs have elected to go with kebab case ensuring there is no possiblity for issues caused by inconsistent casing.
View full answer

10 Replies

Asian black bear
Pascal case was popular in the last decade but there are tons of issues with case insensitive file systems.
When you commit a file and change the casing locally it's not necessarily reflected in the repo and will cause bespoke build errors.
Asian black bear
This is why many devs have elected to go with kebab case ensuring there is no possiblity for issues caused by inconsistent casing.
Answer
I think I need to refactor my code
Asian black bear
If you do that you will pretty much experience the issues mentioned if you don't pay attention. For files with a single word such as Foo.ts you'll notice that renaming them to foo.ts might not appear as a change. You will need to git rm these to punch the cache and recommit them.
Asian black bear
Pascal case is okay as well for as long you know what you're doing.
It's just too easy to overlook accidental mistakes while renaming / chaging casing.