fix(no-navigation-without-resolve): allow empty URL in shallow goto()
#1610
Closing issue
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
What version of ESLint are you using?
9.39.5
What version of eslint-plugin-svelte are you using?
3.23.1
What did you do?
Configuration
import svelte from 'eslint-plugin-svelte';
export default [
...svelte.configs.recommended,
{
files: ['**/*.svelte'],
rules: { 'svelte/no-navigation-without-resolve': 'error' }
}
];
<script>
import { goto, pushState, replaceState } from '$app/navigation';
pushState('', {});
replaceState('', {});
goto('', { shallow: true, state: {} });
goto('', { shallow: true, replace: true, state: {} });
</script>
SvelteKit 3 deprecates pushState / replaceState in favour of goto(url, { state, shallow: true }) / goto(url, { state, shallow: true, replace: true }) (see the @deprecated notes in @sveltejs/kit/types/index.d.ts). The rule accepts an empty URL for pushState('') / replaceState(''), which the rule docs list as valid shallow routing, but reports the same call written the way Kit 3 recommends.
What did you expect to happen?
No errors: the two goto calls are the Kit 3 replacements for the pushState / replaceState calls above them, which the rule already accepts.
What actually happened?
src/Repro.svelte
6:7 error Unexpected goto() call without resolve() svelte/no-navigation-without-resolve
7:7 error Unexpected goto() call without resolve() svelte/no-navigation-without-resolve
✖ 2 problems (2 errors, 0 warnings)
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/jose-manuel-silva/repro-eslint-goto-shallow
Additional comments
In the source, checkGotoCall passes {} to isValueAllowed while checkShallowNavigationCall passes { allowEmpty: true }, and goto's options argument is never read. Same on main (90d7b09). Draft #1605 keeps allowEmpty limited to pushState / replaceState, so it doesn't change this. A possible fix: pass { allowEmpty: true } in checkGotoCall when the second argument is an object literal with shallow: true (or allow '' for goto in general, since it resolves to the current URL). @sveltejs/kit 3.1.0, svelte 5.57.2. Related: #1481.
Pull request
Fixes #1609
SvelteKit 3 deprecates pushState() / replaceState() in favour of goto(url, { state, shallow: true }) (see the ). The rule already allowed pushState('') / replaceState(''), but reported the equivalent goto('', { shallow: true }).
goto() now allows an empty URL when its options have a truthy shallow (matching SvelteKit's if (opts.shallow)). The options are resolved with the existing lookupProperty() helper, so they can be inline, in a variable or nested in an object (e.g. goto('', config.opts)), and spreads and computed keys are applied in order. Still reported:
- non-empty URLs, even with
shallow: true(e.g.goto('/foo', { shallow: true })) goto('')without a truthyshallow- options where
shallow: truemay be overridden by a later spread or a computed key that cannot be statically resolved
While addressing review, two fixes that apply to the whole rule (each in its own commit, with its own changeset):
- Variables are only followed if they are
constor never reassigned (likegetStaticValue()), so e.g.let url = resolve('/'); url = '/foo'; goto(url);is now reported. - TypeScript
as,satisfies,!and<T>wrappers are looked through, so e.g.goto('', { shallow: true } as const)orconst paths = [resolve('/')] as constare no longer reported.
Docs and changesets are included.
🦋 Changeset detected
Latest commit: 25ccc60
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| eslint-plugin-svelte | Patch |
Not sure what this means? .
Click here if you're a maintainer who wants to add another changeset to this PR
Try the Instant Preview in Online Playground
Install the Instant Preview to Your Local
npm i https://pkg.pr.new/eslint-plugin-svelte@25ccc60
Published Instant Preview Packages:
- eslint-plugin-svelte:
Hey, @ota-meshi @baseballyama, sorry to ping you, but out of the PRs for this rule, could you please give this one the priority? I suspect the issue is going to be breaking SvelteKit 3 upgrades for a lot of users :/
Thanks, I added both.
Thanks, incorporated!
fix(no-navigation-without-resolve): allow empty URL in shallow goto()
• Oct 17, 2026, 7:40 PMSvelteKit 3 deprecates pushState() and replaceState() in favour of
goto(url, { state, shallow: true }). Allow goto('', { shallow: true }),
matching the existing handling of pushState('') and replaceState('').
Fixes #1609fix(no-navigation-without-resolve): respect spreads overriding shallow in goto()
• Oct 19, 2026, 1:55 PMA spread after `shallow: true` may override it at runtime, so no longer treat such options as shallow. Document that goto() options must be an inline object literal.
feat(no-navigation-without-resolve): follow goto() options in variables
• Oct 19, 2026, 2:00 PMResolve goto() options through the existing lookupProperty() helper when
checking for `shallow`, so options passed via a variable or nested in an
object (e.g. `goto('', config.opts)`) are recognised. Like SvelteKit,
any truthy `shallow` value enables shallow routing.fix(no-navigation-without-resolve): follow all assignments to variables
• Nov 3, 2026, 9:29 AMFollow a variable to its initializer and to the right-hand side of every
`=` assignment to it, and require all of them to be allowed. Previously
only the initializer was used, so `let url = resolve('/'); url = '/foo';
goto(url);` was allowed. Variables without an initializer, or written to
in any other way (e.g. `+=`, destructuring or `bind:`), are not followed.
goto() options are still only followed through variables with a single
value.fix(no-navigation-without-resolve): look through TypeScript type wrappers
• Nov 3, 2026, 9:39 AM`x as T`, `x satisfies T`, `x!` and `<T>x` don't change the runtime
value, but they hid the underlying literal from the rule, so e.g.
`goto('', { shallow: true } as const)`, `const paths = [resolve('/')] as const`
or `goto(resolve('/') as string)` were reported. Unwrap them when
resolving options objects, arrays and navigated values.