vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.

Home Page:https://vike.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove the obligation to capitalize `+Page`

saaymeen opened this issue · comments

Description

This issue is low priority.

When we try to create a page named +page.tsx, we are presented with the following error:

+page.tsx defines an unknown config page, did you mean to define Page instead? (The name of the config Page starts with a capital letter P because it usually defines a UI component: a ubiquitous JavaScript convention is to start the name of UI components with a capital letter.)

While it is true that JSX components must start with a capital letter (or contain a dot), the fact that capitalized files are ubiquitous is highly discussable. Yes, it is the preferred approach to file naming by a lot of developers, but React is actually unopinionated about this matter.

A library like vike should not force a specific convention on users. To show the discrepancy between naming conventions, we can check AirBnB's style guide, which is on par with vikes recommendation. When compared to Google's javascript style guide, we can see that the recommendation here is to use all lowercase letters.

Hand in hand with goes the + prepended to a page. With our convention, the .page.tsx extension was much more suitable.

These points are highly discussable, preferably vike would not force a specific convention to not interfer with conventions of users.

commented

I did consider this. But there are other constraints that made me go for the current design. Most notably: redundant syntax adds DX complexity.

Closing because it isn't a priority right now, but I'm happy to revisit if enough people show interest for this.