Description
Motivation
Before migrating the Svelte Kit, it might be useful to check the migration requirements in advance and let users know that migration is necessary.
Description
Perhaps we should add some rules.
For example:
- no-export-load-in-svelte-module-in-kit-pages... Disallow exporting load functions in
*.svelte
module in Svelte Kit page components.
See SvelteKit 1.0 migration guide (from SvelteKit alpha) kit#5774 (comment) -
naming-convention-in-kit-routes ... Require route files follow naming conventions in Svelte Kit routes.Unable to check if migrated.
See SvelteKit 1.0 migration guide (from SvelteKit alpha) kit#5774 (comment)
Note that essentially, even files under routes can be named freely. It's just not treated as a page. So checking it can be difficult. https://kit.svelte.dev/docs/routing#other-files - no-not-data-props-in-kit-pages ... Disallow props other than
data
in Svelte Kit page components.
See SvelteKit 1.0 migration guide (from SvelteKit alpha) kit#5774 (comment)
It would be best to be able to automatically locate the svelte.config file if possible, read it, and locate the routes directory. If that's difficult, we'll have to ask the user to configure it with overrides in the eslint configuration.
If you have any other rules you need to migrate or ideas for rules that ESLint can check, please let me know.
Examples
<script context="module">
/* eslint svelte/no-export-load-in-svelte-module-in-kit-pages: error */
/* ✗ BAD */
export function load() { /* ... */}
export const load = () => { /* ... */}
</script>
<!-- ✗ BAD -->
<!-- Filename: index.svelte -->
<script>
/* eslint svelte/naming-convention-in-kit-routes: error */
</script>
/* ✗ BAD */
/* Filename: index.js */
/* eslint svelte/naming-convention-in-kit-routes: error */
<!-- ✓ GOOD -->
<!-- Filename: +page.svelte -->
<script>
/* eslint svelte/naming-convention-in-kit-routes: error */
</script>
/* ✓ GOOD */
/* Filename: +page.js */
/* eslint svelte/naming-convention-in-kit-routes: error */
<script>
/* eslint svelte/no-not-data-props-in-kit-pages: error */
/* ✗ BAD */
export let foo;
/* ✓ GOOD */
export let data;
$: ({foo} = data)
</script>