Skip to content

Commit 52a7ad0

Browse files
committed
feat: added the no-navigation-without-resolve rule
1 parent 965569f commit 52a7ad0

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

.changeset/huge-taxis-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
feat: added the no-navigation-without-resolve rule

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ These rules relate to SvelteKit and its best Practices.
363363
| Rule ID | Description | |
364364
|:--------|:------------|:---|
365365
| [svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | :star: |
366+
| [svelte/no-navigation-without-resolve](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-resolve/) | disallow using navigation (links, goto, pushState, replaceState) without a resolve() | |
366367
| [svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in SvelteKit page components. | :star: |
367368

368369
## Experimental

docs/rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ These rules relate to SvelteKit and its best Practices.
120120
| Rule ID | Description | |
121121
| :------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- | :----- |
122122
| [svelte/no-export-load-in-svelte-module-in-kit-pages](./rules/no-export-load-in-svelte-module-in-kit-pages.md) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | :star: |
123+
| [svelte/no-navigation-without-resolve](./rules/no-navigation-without-resolve.md) | disallow using navigation (links, goto, pushState, replaceState) without a resolve() | |
123124
| [svelte/valid-prop-names-in-kit-pages](./rules/valid-prop-names-in-kit-pages.md) | disallow props other than data or errors in SvelteKit page components. | :star: |
124125

125126
## Experimental

packages/eslint-plugin-svelte/src/rule-types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ export interface RuleOptions {
192192
* @deprecated
193193
*/
194194
'svelte/no-navigation-without-base'?: Linter.RuleEntry<SvelteNoNavigationWithoutBase>
195+
/**
196+
* disallow using navigation (links, goto, pushState, replaceState) without a resolve()
197+
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-resolve/
198+
*/
199+
'svelte/no-navigation-without-resolve'?: Linter.RuleEntry<SvelteNoNavigationWithoutResolve>
195200
/**
196201
* disallow use of not function in event handler
197202
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-not-function-handler/
@@ -519,6 +524,13 @@ type SvelteNoNavigationWithoutBase = []|[{
519524
ignorePushState?: boolean
520525
ignoreReplaceState?: boolean
521526
}]
527+
// ----- svelte/no-navigation-without-resolve -----
528+
type SvelteNoNavigationWithoutResolve = []|[{
529+
ignoreGoto?: boolean
530+
ignoreLinks?: boolean
531+
ignorePushState?: boolean
532+
ignoreReplaceState?: boolean
533+
}]
522534
// ----- svelte/no-reactive-reassign -----
523535
type SvelteNoReactiveReassign = []|[{
524536
props?: boolean

packages/eslint-plugin-svelte/src/utils/rules.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import noInlineStyles from '../rules/no-inline-styles.js';
3737
import noInnerDeclarations from '../rules/no-inner-declarations.js';
3838
import noInspect from '../rules/no-inspect.js';
3939
import noNavigationWithoutBase from '../rules/no-navigation-without-base.js';
40+
import noNavigationWithoutResolve from '../rules/no-navigation-without-resolve.js';
4041
import noNotFunctionHandler from '../rules/no-not-function-handler.js';
4142
import noObjectInTextMustaches from '../rules/no-object-in-text-mustaches.js';
4243
import noRawSpecialElements from '../rules/no-raw-special-elements.js';
@@ -117,6 +118,7 @@ export const rules = [
117118
noInnerDeclarations,
118119
noInspect,
119120
noNavigationWithoutBase,
121+
noNavigationWithoutResolve,
120122
noNotFunctionHandler,
121123
noObjectInTextMustaches,
122124
noRawSpecialElements,

0 commit comments

Comments
 (0)