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

Tooling to prevent writing code in legacy mode #14848

Closed
wilsonowilson opened this issue Dec 28, 2024 · 6 comments
Closed

Tooling to prevent writing code in legacy mode #14848

wilsonowilson opened this issue Dec 28, 2024 · 6 comments

Comments

@wilsonowilson
Copy link

Describe the problem

I've been using Svelte 5 for a few weeks now and I love it!

As someone who's been writing in the legacy syntax for years now though, I occasionally slip up and use legacy APIs when creating components.

It's also a problem working with teammates who are new to Svelte 5, as they fallback constantly to legacy APIs, and we only catch them during code reviews.

Describe the proposed solution

I've searched and I'm not sure if it exists already, but isn't there some lint rule or editor setting that creates an error warning when writing components in the legacy syntax?

VSCode has a setting to highlight when a component is written in the legacy syntax, but AFAIK there's no way to enforce that components are written in runes mode.

CleanShot 2024-12-28 at 10 47 31@2x

On an aside, it's also mildly annoying that this feature defaults to legacy mode instead of runes mode.

Importance

would make my life easier

@adiguba
Copy link
Contributor

adiguba commented Dec 28, 2024

Hello,

You can use runes: true on the compiler options : https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions

Note that will impact external library, and could be set dynamically via Vite config.

@wilsonowilson
Copy link
Author

@adiguba This is almost perfect.

@paoloricciuti
Copy link
Member

  • but I can't find a way to use this in a sveltekit project?

You can specify it in the svelte.config.js on kit.vitePlugin.dynamicCompileOption

Here's an example of how I did it on sveltelab.

@rodrigocfd
Copy link

You can use runes: true on the compiler options : https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions

Note that will impact external library, and could be set dynamically via Vite config.

I have a Vite project (no SvelteKit), can you give an example of how to set this option?

@paoloricciuti
Copy link
Member

You can use runes: true on the compiler options : https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions
Note that will impact external library, and could be set dynamically via Vite config.

I have a Vite project (no SvelteKit), can you give an example of how to set this option?

The svelte config should work the same

@paoloricciuti
Copy link
Member

Since this seem what the OP wanted I'm gonna close this issue, thanks for reporting

@paoloricciuti paoloricciuti closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
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

No branches or pull requests

4 participants