Skip to content

False positive with svelte/no-navigation-without-resolve when importing typed path #1370

@thobson

Description

@thobson

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.36.0

What version of eslint-plugin-svelte are you using?

3.12.3

What did you do?

This works

<script lang"ts>
  import { resolve } from '$app/paths';
</script>

<a href={resolve("/")}>home</a>

This also works

<script lang="ts">
  import { resolve } from '$app/paths';
  const home = resolve("/");
</script>

<a href={home}>home</a>

However this generates a Found a link with a url that isn't resolved error:

// src/lib/routes
import { resolve } from '$app/paths';
export const home = resolve("/");
<script lang="ts">
  import { home } from '$lib/routes';
</script>

<a href={home}>home</a>

What did you expect to happen?

I would expect the externalised route to be treated the same as the one that is resolved inline.

What actually happened?

Found a link with a url that isn't resolved svelte/no-navigation-without-resolve

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/thobson/svelte-eslint-errors

See src/routes/+page.svelte

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions