-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Comments
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>
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. Could I add such a functionality myself or is this too low level in the framework? |
@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. |
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. |
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" |
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
The text was updated successfully, but these errors were encountered: