feat(no-navigation-without-resolve): recognizing resolved values with queries and fragments

#1605

Closing issues

Pull request

Merged at Nov 16, 2026, 5:15 AM by ota-meshi
M
marekdedic
Oct 9, 2026, 2:01 PM

Continuation of (originally ), rebased onto current main, with the review feedback from addressed.

Closes Closes

What this does

svelte/no-navigation-without-resolve no longer reports:

  • Resolved URLs followed by a query string or a fragment, e.g. resolve('/foo') + '?page=2', `${resolve('/foo')}#section`, resolve('/') + (searchParams.size ? `?${searchParams}` : ''), or <a href="{resolve('/foo')}?page=2">. A URL counts as resolved if it starts with resolve()/asset() or a ResolvedPathname value.
  • Query-only and fragment-only URLs, e.g. goto('?page=2'), <a href="?{searchParams}"> or replaceState('#top', {}), as they keep the current path. Fragment-only URLs were previously only allowed in links.

A resolved value followed by anything other than a query or a fragment (e.g. resolve('/foo') + '/bar') is still reported, since it bypasses the route type-checking of resolve(). This follows the discussion in .

URLs may be built with + concatenation, template literals, multi-part href attributes, variables, array elements, object properties, {#each} items and ternaries, in any combination.

Behaviour change for href attributes

Previously, only the first part of a multi-part href attribute was checked, so <a href="{resolve('/foo')}/bar"> was not reported. All parts are now checked, so it is reported. To fix such links, pass the whole path to resolve() (e.g. resolve('/blog/[slug]', { slug })) and start a query or fragment with a literal ? or # (e.g. href="{resolve('/search')}?{params}").

Leading and trailing whitespace in an href is ignored, as browsers strip it, so <a href=" {resolve('/foo')} "> is not reported. Whitespace between the parts is kept, as it stays in the URL.

Review feedback from

  • Fixed a crash on template literals containing only resolve() (or nothing).
  • Concatenation is only recognised for the + operator.
  • Replaced the separate BinaryExpression/TemplateLiteral handling with a single check over the URL's parts. Variables, member accesses and {#each} items are expanded along the way. Cyclic definitions are guarded by a set of the variables expanded on the current path, rather than a FindVariableContext, because a shared one would make the branches of a ternary interfere with each other, and a fresh one per branch loops forever on cyclic definitions.
  • Documented queries, fragments and ResolvedPathname in the rule docs.

Related: adds suffix support behind an option; this PR enables it by default.

👍 1