ecosystem/vue-router-extra-param
The route does not declare tab; Vue Router discards it.
Default severity: error
Applies to: Reachable project declarations and imported components
Options: crossFile; rule severity (off/warn/error)
Automatic fix: None
The complete installed router must be reachable from the application's createApp(...).use(router). Unknown/dynamic route tables do not prove unknown-name findings. Missing params are warnings because navigation may inherit a value from the current route.
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: { preset: "incremental", crossFile: true,
rules: { "ecosystem/vue-router-extra-param": "warn" },
},
},
});
vp run lint
Shared project files
Use these unchanged files in both Bad and Good. Install the imported packages in the project: Vue, plus vue-router or Pinia where shown. Follow any version-specific support note. The entry root makes the component relationship explicit.
index.html
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
src/main.ts
import { createApp } from "vue";
import App from "./App.vue";
import { router } from "./router";
createApp(App).use(router).mount("#app");
src/App.vue
<script setup lang="ts">
import { RouterView } from "vue-router";
</script>
<template><RouterView /></template>
src/router.ts
import { createRouter, createWebHistory } from "vue-router";
import UserPost from "./UserPost.vue";
export const router = createRouter({
history: createWebHistory(),
routes: [{ path: "/users/:userId/posts/:postId", name: "user-post", component: UserPost }],
});
Bad
The user-post path declares userId and postId, but the navigation also supplies undeclared tab as a path parameter.
src/UserPost.vue
<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
router.push({ name: "user-post", params: { userId: "1", postId: "2", tab: "a" } });
</script>
<template><p>Post</p></template>
Good
Remove tab from params and retain only the keys present in the route path. Use query separately if the application needs a tab selection.
src/UserPost.vue
<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
router.push({ name: "user-post", params: { userId: "1", postId: "2" } });
</script>
<template><p>Post</p></template>
The Good files demonstrate the change described above; other diagnostics can still apply to the complete project.