Skip to content

Conversation

@marekdedic
Copy link
Contributor

Since the rule is now restricted to running only on SvelteKit files, I think it's safe to add it to the recommended rule set.

@changeset-bot
Copy link

changeset-bot bot commented Sep 3, 2025

🦋 Changeset detected

Latest commit: e59f029

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 Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2025

Try the Instant Preview in Online Playground

ESLint Online Playground

Install the Instant Preview to Your Local

npm i https://pkg.pr.new/eslint-plugin-svelte@e59f029

Published Instant Preview Packages:

View Commit

@ota-meshi ota-meshi merged commit abbcfdd into sveltejs:main Sep 3, 2025
16 of 17 checks passed
@marekdedic
Copy link
Contributor Author

Wow, that was fast :D

@marekdedic marekdedic deleted the recommended-no-navigation-without-resolve branch September 3, 2025 09:59
@DePasqualeOrg
Copy link

After updating to the latest version, I'm getting errors that I'm not sure how to resolve. What should I do about mailto URLs? It's also showing an error when I use a ternary expression with both branches using resolve.

And I believe this should work, but I'm getting an error on resolve:

<a href={resolve('/blog/[slug]', { slug })}>

Error: Expected 1 arguments, but got 2.ts(2554)

@marekdedic
Copy link
Contributor Author

Hello, thanks for the comments:

  • mailto: URLs were an oversight and they should be fixed in version 3.12.1
  • In the ternary, we could add that as an exception, but it seems to me to be actually nudging you towards a better design, which is to resolve as the last operation (i.e. do resolve(condition ? "/a" : "/b") instead of condition ? resolve("/a") : resolve("/b"))
  • As for the 2 arguments: Is that an error with this plugin? Or is it a type issue (and therefore more likely an issue with SvelteKit's types)? Can you send a playground link?

@DePasqualeOrg
Copy link

I have a ternary expression in which one branch is a mailto URL and the other uses resolve. I'm guessing that will still result in an error after mailto URLs are allowed.

The type error regarding arguments might be due to the fact that I have a page route at /blog that is not linked to by any pages. The Svelte files for the route exist, but maybe resolve uses a list of routes that are discovered through links to determine which are valid?

@marekdedic
Copy link
Contributor Author

Hmm, that's an edge case if I've ever seen one :D There's already a few PRs that would conflict with this, so give us some time please.

@hyunbinseo
Copy link
Contributor

hyunbinseo commented Sep 11, 2025

If this is a recommended rule, shouldn't the SvelteKit tutorial, docs, and default templates be updated as well?

<!-- https://svelte.dev/docs/kit/load#Layout-data -->
<a href="/blog/{post.slug}">
image

@marekdedic
Copy link
Contributor Author

Hey @DePasqualeOrg I split the one hanging issue into #1389, but just a heads-up, it's mnot high on my priority list. Otherwise I consider this conversation resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants