You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -370,7 +370,7 @@ These rules relate to SvelteKit and its best Practices.
370
370
| Rule ID | Description ||
371
371
|:--------|:------------|:---|
372
372
|[svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/)| disallow exporting load functions in `*.svelte` module in SvelteKit page components. |:star:|
373
-
|[svelte/no-navigation-without-resolve](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-resolve/)| disallow using navigation (links, goto, pushState, replaceState) without a resolve() |:star:|
373
+
|[svelte/no-navigation-without-resolve](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-resolve/)| disallow internal navigation (links, `goto()`, `pushState()`, `replaceState()`) without a `resolve()`|:star:|
374
374
|[svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/)| disallow props other than data or errors in SvelteKit page components. |:star:|
|[svelte/no-export-load-in-svelte-module-in-kit-pages](./rules/no-export-load-in-svelte-module-in-kit-pages.md)| disallow exporting load functions in `*.svelte` module in SvelteKit page components. |:star:|
124
-
|[svelte/no-navigation-without-resolve](./rules/no-navigation-without-resolve.md)| disallow using navigation (links, goto, pushState, replaceState) without a resolve() |:star:|
125
-
|[svelte/valid-prop-names-in-kit-pages](./rules/valid-prop-names-in-kit-pages.md)| disallow props other than data or errors in SvelteKit page components. |:star:|
|[svelte/no-export-load-in-svelte-module-in-kit-pages](./rules/no-export-load-in-svelte-module-in-kit-pages.md)| disallow exporting load functions in `*.svelte` module in SvelteKit page components. |:star:|
124
+
|[svelte/no-navigation-without-resolve](./rules/no-navigation-without-resolve.md)| disallow internal navigation (links, `goto()`, `pushState()`, `replaceState()`) without a `resolve()`|:star:|
125
+
|[svelte/valid-prop-names-in-kit-pages](./rules/valid-prop-names-in-kit-pages.md)| disallow props other than data or errors in SvelteKit page components. |:star:|
Copy file name to clipboardExpand all lines: docs/rules/no-navigation-without-resolve.md
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,41 +2,53 @@
2
2
pageClass: 'rule-details'
3
3
sidebarDepth: 0
4
4
title: 'svelte/no-navigation-without-resolve'
5
-
description: 'disallow using navigation (links, goto, pushState, replaceState) without a resolve()'
5
+
description: 'disallow internal navigation (links, `goto()`, `pushState()`, `replaceState()`) without a `resolve()`'
6
6
since: 'v3.12.0'
7
7
---
8
8
9
9
# svelte/no-navigation-without-resolve
10
10
11
-
> disallow using navigation (links, goto, pushState, replaceState) without a resolve()
11
+
> disallow internal navigation (links, `goto()`, `pushState()`, `replaceState()`) without a `resolve()`
12
12
13
13
-:gear: This rule is included in `"plugin:svelte/recommended"`.
14
14
15
15
## :book: Rule Details
16
16
17
-
This rule reports navigation using HTML `<a>` tags, SvelteKit's `goto()`, `pushState()` and `replaceState()` functions without resolving a relative URL. All four of these may be used for navigation, with `goto()`, `pushState()` and `replaceState()` being intended solely for internal navigation (i.e. not leaving the site), while `<a>` tags may be used for both internal and external navigation. When using any way of internal navigation, the URL must be resolved using SvelteKit's `resolve()`, otherwise the site may break. For programmatic navigation to external URLs, using `window.location` is advised.
18
-
19
-
This rule checks all 4 navigation options for the presence of the `resolve()` function call, with an exception for `<a>` links to absolute URLs (and fragment URLs), which are assumed to be used for external navigation and so do not require the `resolve()` function, and for shallow routing functions with an empty string as the path, which keeps the current URL.
17
+
This rule ensures internal navigation via HTML `<a>` tags, SvelteKit's `goto()`, `pushState()` and `replaceState()` uses `resolve()`. `<a>` tags will skip this check when it has an absolute URL or `rel="external"`. For programmatic external navigation, use `window.location`. Enforcing this rule ensures the base path is prefixed and internal links are type-checked.
0 commit comments