fix(no-navigation-without-resolve): do not report if there is data-sveltekit-reload or rel="external" in <a>#1380
Conversation
🦋 Changeset detectedLatest commit: 35c72fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
…veltekit-reload` or `rel="external"` in `<a>`
7d946fc to
35c72fc
Compare
Try the Instant Preview in Online PlaygroundInstall the Instant Preview to Your LocalPublished Instant Preview Packages:
|
|
I understand |
| ) { | ||
| return; | ||
| } | ||
| if (anchorHasSveltekitReload(node) || anchorRelIncludesExternal(node)) { |
There was a problem hiding this comment.
Maybe add this to the previous if?
| const relAttr = startTag.attributes.find((attr): attr is AST.SvelteAttribute => { | ||
| return attr.type === 'SvelteAttribute' && attr.key.name === 'rel'; | ||
| }); | ||
| if (!relAttr) return false; |
There was a problem hiding this comment.
| if (!relAttr) return false; | |
| if (relAttr === undefined) return false; |
| } | ||
|
|
||
| function relTokenListIncludesExternal(value: string): boolean { | ||
| return /(?:^|\s)external(?:\s|$)/i.test(value); |
There was a problem hiding this comment.
| return /(?:^|\s)external(?:\s|$)/i.test(value); | |
| return value.split(" ").some((part) => part === "external"); |
| // Handle literal values like rel="external" or rel="external nofollow" | ||
| for (const v of relAttr.value) { | ||
| if (v.type === 'SvelteLiteral') { | ||
| if (relTokenListIncludesExternal(v.value)) return true; |
| // Best-effort: detect simple string literals in mustache, e.g., rel={'external'} | ||
| const expr = v.expression; | ||
| if (expr.type === 'Literal' && typeof expr.value === 'string') { | ||
| if (relTokenListIncludesExternal(expr.value)) return true; |
| expr.expressions.length === 0 && | ||
| expr.quasis.length === 1 | ||
| ) { | ||
| if (relTokenListIncludesExternal(expr.quasis[0].value.raw)) return true; |
|
|
|
@baseballyama Most of this PR (the So I think this can be closed, right? Thank you for it nonetheless, I used parts of this in #1433 😄 |
close part of #1353
There haven’t been any reports yet, but I realized we’re missing handling for another way of specifying external links.