# svelte/no-goto-without-base
disallow using goto() without the base path
- β οΈ This rule was deprecated and replaced by svelte/no-navigation-without-resolve rule.
# π Rule Details
This rule reports navigation using SvelteKitβs goto()
function without prefixing a relative URL with the base path. If a non-prefixed relative URL is used for navigation, the goto
function navigates away from the base path, which is usually not what you wanted to do (for external URLs, window.location = url
should be used instead).
<script> /* eslint svelte/no-goto-without-base: "error" */ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { base as baseAlias } from '$app/paths'; // β GOOD goto(base + '/foo/'); goto(`${base}/foo/`); goto(baseAlias + '/foo/'); goto(`${baseAlias}/foo/`); goto('https://localhost/foo/'); // β BAD goto(Found a goto() call with a url that isn't prefixed with the base path. (svelte/no-goto-without-base)'/foo'); goto(Found a goto() call with a url that isn't prefixed with the base path. (svelte/no-goto-without-base)'/foo/' + base); goto(Found a goto() call with a url that isn't prefixed with the base path. (svelte/no-goto-without-base)`/foo/${base}`); </script>
# π§ Options
Nothing.
# π Further Reading
# π Version
This rule was introduced in eslint-plugin-svelte v2.36.0-next.9