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

Warn when reserved filenames exist but have neglected the + prefix #10528

Closed
theetrain opened this issue Aug 11, 2023 · 4 comments · Fixed by #10558
Closed

Warn when reserved filenames exist but have neglected the + prefix #10528

theetrain opened this issue Aug 11, 2023 · 4 comments · Fixed by #10558
Labels
feature request New feature or request ready to implement please submit PRs for these issues!
Milestone

Comments

@theetrain
Copy link
Contributor

Describe the problem

Sometimes, users will encounter unexplainable behaviours (or lack thereof) when seemingly adding the correct files, but those files were misspelled or neglected the + prefix.

Common mistakes include:

  • hook.server.js, hook.server.ts, +hooks.server.js, +hooks.server.ts
  • page.svelte
  • page.js, page.ts, page.server.js, page.server.ts
  • server.js, server.ts

Describe the proposed solution

During dev mode or project build, log a warning if any of the above misspellings are found in the codebase.

Alternatives considered

Inform users to read the docs more closely.

Importance

nice to have

Additional Information

No response

@dummdidumm dummdidumm added feature request New feature or request ready to implement please submit PRs for these issues! labels Aug 11, 2023
@dummdidumm dummdidumm added this to the non-urgent milestone Aug 11, 2023
dummdidumm pushed a commit that referenced this issue Aug 23, 2023
closes #10528

Outputs a terminal warning if a route filename is missing a + or if the default hooks filename (src/hooks.server) mistakenly has a + prefix.

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
@205g0
Copy link

205g0 commented Sep 15, 2023

Would love to have this for REST resources, e.g., my schema has users, posts and comments and i want to get a warning if a folder is not compliant to the schema's entities + a few other custom ones, e.g. me or [lang] I could set somewhere (as an array)

Could I add such a functionality myself or is this too low level in the framework?

@theetrain
Copy link
Contributor Author

@205g0 Assuming you have an API schema and you want your folder structure to comply via build-time validations, maybe an adaptation of https://github.com/SkeLLLa/fastify-oas for SvelteKit can be made.

@205g0
Copy link

205g0 commented Sep 15, 2023

Maybe. I just want that my app breaks as much as possible if my SQL schema (=Drizzle TS schema) changes. And I want to know ofc where it broke. I achieved this already with almost everything which is entity- and/or route-related, e.g.. depends, invalidate, goto, fetch, action, href, etc. This is the beauty with TS, you can easily change a table name with Drizzle, let TS refactor and where it can't, it will break at least.

If the routes/folder names break too (or emit an error on the console), you would have a complete "picture" where to refactor yourself and can do complex refactors in minutes you couldn't do with any other framework in weeks.

Atm, I just check against an enum type of all SQL entities, so no hierarchy or relations are checked but this is already a huge win. To get latter working, I guess you need a deeper integration with something like Drizzle which could expose the relations.

@205g0
Copy link

205g0 commented Sep 15, 2023

With Drizzle you just need following to get all entities as enum type which you can use against all schema-related matters:

import type * as schema from '$lib/schema'

export type TableName = keyof typeof schema
// type TableName = "users" | "posts" | "comments" 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request ready to implement please submit PRs for these issues!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants