From 3f08eaf7b0a3c154f6727377ae50171ede7de7a6 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Tue, 23 Sep 2025 13:52:13 +0900 Subject: [PATCH] fix(no-navigation-without-resolve): improve error messages --- .changeset/tame-walls-sleep.md | 5 +++++ .../src/rules/no-navigation-without-resolve.ts | 8 ++++---- .../invalid/goto-aliased01-errors.yaml | 2 +- .../invalid/goto-namespace-import01-errors.yaml | 2 +- .../invalid/goto-partial-resolve01-errors.yaml | 4 ++-- .../invalid/goto-without-resolve01-errors.yaml | 4 ++-- .../invalid/link-partial-resolve01-errors.yaml | 6 +++--- .../invalid/link-with-fragment01-errors.yaml | 10 +++++----- .../invalid/link-without-resolve01-errors.yaml | 10 +++++----- .../invalid/pushState-aliased01-errors.yaml | 2 +- .../invalid/pushState-namespace-import01-errors.yaml | 2 +- .../invalid/pushState-partial-resolve01-errors.yaml | 4 ++-- .../invalid/pushState-without-resolve01-errors.yaml | 4 ++-- .../invalid/recursive-loop01-errors.yaml | 2 +- .../invalid/replaceState-aliased01-errors.yaml | 2 +- .../replaceState-namespace-import01-errors.yaml | 2 +- .../invalid/replaceState-partial-resolve01-errors.yaml | 4 ++-- .../invalid/replaceState-without-resolve01-errors.yaml | 4 ++-- 18 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 .changeset/tame-walls-sleep.md diff --git a/.changeset/tame-walls-sleep.md b/.changeset/tame-walls-sleep.md new file mode 100644 index 000000000..b53624470 --- /dev/null +++ b/.changeset/tame-walls-sleep.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-svelte': patch +--- + +fix(no-navigation-without-resolve): improve error messages diff --git a/packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts b/packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts index 0beb2aa71..1050cf106 100644 --- a/packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts +++ b/packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts @@ -35,10 +35,10 @@ export default createRule('no-navigation-without-resolve', { } ], messages: { - gotoWithoutResolve: "Found a goto() call with a url that isn't resolved.", - linkWithoutResolve: "Found a link with a url that isn't resolved.", - pushStateWithoutResolve: "Found a pushState() call with a url that isn't resolved.", - replaceStateWithoutResolve: "Found a replaceState() call with a url that isn't resolved." + gotoWithoutResolve: 'Unexpected goto() call without resolve().', + linkWithoutResolve: 'Unexpected href link without resolve().', + pushStateWithoutResolve: 'Unexpected pushState() call without resolve().', + replaceStateWithoutResolve: 'Unexpected replaceState() call without resolve().' }, type: 'suggestion', conditions: [ diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-aliased01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-aliased01-errors.yaml index ce6b7669f..f54bcdf7d 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-aliased01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-aliased01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 4 column: 8 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-namespace-import01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-namespace-import01-errors.yaml index 00c6c11c9..7b12bf5ea 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-namespace-import01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-namespace-import01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 4 column: 18 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-partial-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-partial-resolve01-errors.yaml index aa29dec0c..231482480 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-partial-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-partial-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 5 column: 7 suggestions: null -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 6 column: 7 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-without-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-without-resolve01-errors.yaml index e63634672..970db393c 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-without-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/goto-without-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 6 column: 7 suggestions: null -- message: Found a goto() call with a url that isn't resolved. +- message: Unexpected goto() call without resolve(). line: 7 column: 7 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-partial-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-partial-resolve01-errors.yaml index c9996ac7f..98768b3c2 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-partial-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-partial-resolve01-errors.yaml @@ -1,12 +1,12 @@ -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 7 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 8 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 9 column: 9 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-with-fragment01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-with-fragment01-errors.yaml index f6888e8c1..52e9ee73e 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-with-fragment01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-with-fragment01-errors.yaml @@ -1,20 +1,20 @@ -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 5 column: 10 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 6 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 7 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 8 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 9 column: 9 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-without-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-without-resolve01-errors.yaml index f6888e8c1..52e9ee73e 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-without-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/link-without-resolve01-errors.yaml @@ -1,20 +1,20 @@ -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 5 column: 10 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 6 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 7 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 8 column: 9 suggestions: null -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 9 column: 9 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-aliased01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-aliased01-errors.yaml index d2cdd8a01..6a775af9f 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-aliased01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-aliased01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 4 column: 8 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-namespace-import01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-namespace-import01-errors.yaml index 1f1d8f07c..fa2683996 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-namespace-import01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-namespace-import01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 4 column: 23 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-partial-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-partial-resolve01-errors.yaml index fb9c724ad..ff92a67b4 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-partial-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-partial-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 5 column: 12 suggestions: null -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 6 column: 12 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-without-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-without-resolve01-errors.yaml index 874b38fa2..1c80d47cd 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-without-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/pushState-without-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 6 column: 12 suggestions: null -- message: Found a pushState() call with a url that isn't resolved. +- message: Unexpected pushState() call without resolve(). line: 7 column: 12 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/recursive-loop01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/recursive-loop01-errors.yaml index 6d3676e1a..d75ac7bd1 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/recursive-loop01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/recursive-loop01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a link with a url that isn't resolved. +- message: Unexpected href link without resolve(). line: 6 column: 9 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-aliased01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-aliased01-errors.yaml index 0f9bb334f..3ba8f57e2 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-aliased01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-aliased01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 4 column: 8 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-namespace-import01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-namespace-import01-errors.yaml index d3ce4f0b3..1dcefc113 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-namespace-import01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-namespace-import01-errors.yaml @@ -1,4 +1,4 @@ -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 4 column: 26 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-partial-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-partial-resolve01-errors.yaml index 59a969704..d22c478d3 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-partial-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-partial-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 5 column: 15 suggestions: null -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 6 column: 15 suggestions: null diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-without-resolve01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-without-resolve01-errors.yaml index feee113b5..6cf6e6839 100644 --- a/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-without-resolve01-errors.yaml +++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/no-navigation-without-resolve/invalid/replaceState-without-resolve01-errors.yaml @@ -1,8 +1,8 @@ -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 6 column: 15 suggestions: null -- message: Found a replaceState() call with a url that isn't resolved. +- message: Unexpected replaceState() call without resolve(). line: 7 column: 15 suggestions: null