fix(no-navigation-without-resolve): check complete external rel tokens
#1380
Pull request
no-navigation-without-resolve currently checks only the first chunk of a rel attribute, so rel="external{suffix}" can incorrectly exempt an internal link even when its complete value has no external token.
Check the complete string value instead, using static evaluation where possible. Unknown interpolations cannot create a token boundary; a known, separately delimited external token remains allowed. This also handles template literals and shorthand attributes, avoids a crash on a bare rel attribute, and stops relying on an initializer after the variable has been reassigned.
Internal links with data-sveltekit-reload still require resolve(), including "false", {false}, and enabled reload values. This retains the existing behavior on main and the external-link handling introduced in #1443.
Validation:
- Full suite: 1467 passing.
- All 95 rule fixtures independently checked with ESLint 8.57.1, 9.39.1, and 10.0.0, including message locations.
- JavaScript and TypeScript regression fixtures cover rel token boundaries, unknown interpolations, empty attributes, reassigned variables, and reload values.
- TypeScript build, ESLint (0 errors; 2 existing unrelated warnings), type coverage (99.06%), Prettier, and diff checks pass.
Related: #1353.
🦋 Changeset detected
Latest commit: 3bfc4fb
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@3bfc4fb
Published Instant Preview Packages:
- eslint-plugin-svelte:
I understand rel="external" (and it was actually reported in some related issue), but not the data-sveltekit-reload - why should that one be treated as external?
data-sveltekit-reload causes a hard refresh, but if the target is an internal link, it should still be linted.
@baseballyama Most of this PR (the rel="external" part) has been solved in the meantime by #1443. As @sacrosanctic points out, data-sveltekit-reload shouldn't be automatically allowed.
So I think this can be closed, right? Thank you for it nonetheless, I used parts of this in #1433 😄
Thanks! #1443 already covers the basic external-link handling, so I rebased onto main and reused it.
In 3bfc4fb, I removed the reload exemption and fixed the remaining rel-token issue, bare-rel crash, and reassigned-variable handling. The inline refactoring suggestions are also addressed.
All 95 rule fixtures pass on ESLint 8/9/10, and the full suite passes with 1,467 tests.
fix(no-navigation-without-resolve): check complete external rel tokens
• Sep 23, 2025, 1:11 PM