@@ -14,7 +14,26 @@ export default createRule('no-navigation-without-base', {
14
14
category : 'SvelteKit' ,
15
15
recommended : false
16
16
} ,
17
- schema : [ ] ,
17
+ schema : [
18
+ {
19
+ type : 'object' ,
20
+ properties : {
21
+ ignoreGoto : {
22
+ type : 'boolean'
23
+ } ,
24
+ ignoreLinks : {
25
+ type : 'boolean'
26
+ } ,
27
+ ignorePushState : {
28
+ type : 'boolean'
29
+ } ,
30
+ ignoreReplaceState : {
31
+ type : 'boolean'
32
+ }
33
+ } ,
34
+ additionalProperties : false
35
+ }
36
+ ] ,
18
37
messages : {
19
38
gotoNotPrefixed : "Found a goto() call with a url that isn't prefixed with the base path." ,
20
39
linkNotPrefixed : "Found a link with a url that isn't prefixed with the base path." ,
@@ -38,23 +57,35 @@ export default createRule('no-navigation-without-base', {
38
57
pushState : pushStateCalls ,
39
58
replaceState : replaceStateCalls
40
59
} = extractFunctionCallReferences ( referenceTracker ) ;
41
- for ( const gotoCall of gotoCalls ) {
42
- checkGotoCall ( context , gotoCall , basePathNames ) ;
60
+ if ( context . options [ 0 ] ?. ignoreGoto !== true ) {
61
+ for ( const gotoCall of gotoCalls ) {
62
+ checkGotoCall ( context , gotoCall , basePathNames ) ;
63
+ }
43
64
}
44
- for ( const pushStateCall of pushStateCalls ) {
45
- checkShallowNavigationCall ( context , pushStateCall , basePathNames , 'pushStateNotPrefixed' ) ;
65
+ if ( context . options [ 0 ] ?. ignorePushState !== true ) {
66
+ for ( const pushStateCall of pushStateCalls ) {
67
+ checkShallowNavigationCall (
68
+ context ,
69
+ pushStateCall ,
70
+ basePathNames ,
71
+ 'pushStateNotPrefixed'
72
+ ) ;
73
+ }
46
74
}
47
- for ( const replaceStateCall of replaceStateCalls ) {
48
- checkShallowNavigationCall (
49
- context ,
50
- replaceStateCall ,
51
- basePathNames ,
52
- 'replaceStateNotPrefixed'
53
- ) ;
75
+ if ( context . options [ 0 ] ?. ignoreReplaceState !== true ) {
76
+ for ( const replaceStateCall of replaceStateCalls ) {
77
+ checkShallowNavigationCall (
78
+ context ,
79
+ replaceStateCall ,
80
+ basePathNames ,
81
+ 'replaceStateNotPrefixed'
82
+ ) ;
83
+ }
54
84
}
55
85
} ,
56
86
SvelteAttribute ( node ) {
57
87
if (
88
+ context . options [ 0 ] ?. ignoreLinks === true ||
58
89
node . parent . parent . type !== 'SvelteElement' ||
59
90
node . parent . parent . kind !== 'html' ||
60
91
node . parent . parent . name . type !== 'SvelteName' ||
0 commit comments