# svelte/no-goto-without-base

disallow using goto() without the base path

# πŸ“– 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

# πŸ” Implementation