Skip to content

Add rule no-goto-without-base #675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marekdedic opened this issue Jan 24, 2024 · 1 comment · Fixed by #679
Closed

Add rule no-goto-without-base #675

marekdedic opened this issue Jan 24, 2024 · 1 comment · Fixed by #679
Labels
enhancement New feature or request new rule

Comments

@marekdedic
Copy link
Contributor

Motivation

In SvelteKit, the goto function is used for internal navigation. That means, that you basically almost always want to prefix the url with the base path.

Description

Add a rule that would trigger on any goto without a base path. However, there are quite some edge cases

Examples

<script>
  import { base } from "$app/paths";
  import { base as whatever } from "$app/paths";
  import { goto } from "$app/navigation";

  <!--GOOD -->
  goto(base + "/foo");
  goto(`${base}/foo`)
  goto(whatever + "/foo");
  goto(`${whatever}/foo`)
  goto("https://absolute.url");

  <!--BAD -->
  goto("/foo");
  goto("foo/" + base);
  goto(`foo/${base}`);
</svelte>

Additional comments

Is this plugin the right place to put SvelteKit rules?

@marekdedic marekdedic added enhancement New feature or request new rule labels Jan 24, 2024
@ota-meshi
Copy link
Member

Thank you for posting proposed rule!

Is this plugin the right place to put SvelteKit rules?

I think it's good that the rules regarding what svelte official provides are provided by this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants