Skip to content

Calling goto with a URL object with a ResolvedPathname shows error #1450

@felix-schindler

Description

@felix-schindler

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.39.1

What version of eslint-plugin-svelte are you using?

3.13.1

What did you do?

Configuration
import prettier from 'eslint-config-prettier';
import { fileURLToPath } from 'node:url';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';

const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));

export default defineConfig(
	includeIgnoreFile(gitignorePath),
	js.configs.recommended,
	...ts.configs.recommended,
	...svelte.configs.recommended,
	prettier,
	...svelte.configs.prettier,
	{
		languageOptions: { globals: { ...globals.browser, ...globals.node } },

		rules: {
			// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
			// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
			'no-undef': 'off'
		}
	},
	{
		files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],

		languageOptions: {
			parserOptions: {
				projectService: true,
				extraFileExtensions: ['.svelte'],
				parser: ts.parser,
				svelteConfig
			}
		}
	}
);
const abc: URL & {
    pathname: ResolvedPathname;
}

await goto(abc, { invalidateAll: true });

What did you expect to happen?

Recognizing the pathname is resolved

What actually happened?

Unexpected goto() call without resolve(). (eslint svelte/no-navigation-without-resolve)

Link to GitHub Repo with Minimal Reproducible Example

<script lang="ts">
  import { page } from '$app/state';

  function filter(f: string) {
    const someUrl = page.url;
    someUrl.searchParams.set('filter', f);
    await goto(someUrl, { invalidateAll: true });
  }
</script>

<button type="button" onclick={() => filter("abc")}>do sth</button>

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions