Skip to content

Commit 9c30bbf

Browse files
committed
feat(no-navigation-without-resolve): added support for ResolvedPathname types
1 parent 26e6159 commit 9c30bbf

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/icy-mammals-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
feat(no-navigation-without-resolve): added support for ResolvedPathname types

packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FindVariableContext } from '../utils/ast-utils.js';
55
import { findVariable } from '../utils/ast-utils.js';
66
import type { RuleContext } from '../types.js';
77
import type { AST } from 'svelte-eslint-parser';
8+
import { type TSTools, getTypeScriptTools } from 'src/utils/ts-utils/index.js';
89

910
export default createRule('no-navigation-without-resolve', {
1011
meta: {
@@ -48,6 +49,8 @@ export default createRule('no-navigation-without-resolve', {
4849
]
4950
},
5051
create(context) {
52+
const tsTools = getTypeScriptTools(context);
53+
5154
let resolveReferences: Set<TSESTree.Identifier> = new Set<TSESTree.Identifier>();
5255

5356
const ignoreGoto = context.options[0]?.ignoreGoto ?? false;
@@ -66,7 +69,7 @@ export default createRule('no-navigation-without-resolve', {
6669
} = extractFunctionCallReferences(referenceTracker);
6770
if (!ignoreGoto) {
6871
for (const gotoCall of gotoCalls) {
69-
checkGotoCall(context, gotoCall, resolveReferences);
72+
checkGotoCall(context, gotoCall, resolveReferences, tsTools);
7073
}
7174
}
7275
if (!ignorePushState) {
@@ -75,6 +78,7 @@ export default createRule('no-navigation-without-resolve', {
7578
context,
7679
pushStateCall,
7780
resolveReferences,
81+
tsTools,
7882
'pushStateWithoutResolve'
7983
);
8084
}
@@ -85,6 +89,7 @@ export default createRule('no-navigation-without-resolve', {
8589
context,
8690
replaceStateCall,
8791
resolveReferences,
92+
tsTools,
8893
'replaceStateWithoutResolve'
8994
);
9095
}
@@ -185,7 +190,8 @@ function extractFunctionCallReferences(referenceTracker: ReferenceTracker): {
185190
function checkGotoCall(
186191
context: RuleContext,
187192
call: TSESTree.CallExpression,
188-
resolveReferences: Set<TSESTree.Identifier>
193+
resolveReferences: Set<TSESTree.Identifier>,
194+
tsTools: TSTools | null
189195
): void {
190196
if (
191197
call.arguments.length > 0 &&
@@ -199,6 +205,7 @@ function checkShallowNavigationCall(
199205
context: RuleContext,
200206
call: TSESTree.CallExpression,
201207
resolveReferences: Set<TSESTree.Identifier>,
208+
tsTools: TSTools | null,
202209
messageId: string
203210
): void {
204211
if (

0 commit comments

Comments
 (0)