Vize

ecosystem/router-link-require-to

Require a to target on RouterLink and NuxtLink components.

Default severity Presets Automatic fix Options
error ecosystem No None

Applies to: Vue SFC templates and blocks, with script context where the rule requires it.

A single SFC root link may inherit its target from parent attributes. This example uses a nested link, whose target must be explicit.

Bad

The nested RouterLink has no to destination; it cannot rely on root attribute fallthrough.

<template>
<nav><RouterLink>Settings</RouterLink></nav>
</template>

Good

to="/settings" explicitly supplies the nested link destination.

<template>
<nav><RouterLink to="/settings">Settings</RouterLink></nav>
</template>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "ecosystem/router-link-require-to": "error"
    }
  },
});

Then run vp run lint.