Vize

script/no-dupe-keys

Disallow duplicate keys across Options API props/data/computed/methods/setup/inject

Bad · Good

Default severity: error
Presets: essential, happy-path, ecosystem, nuxt, opinionated
Automatic fix: None; review the suggested change
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form
Options: No rule-specific options. Severity and preset selection are configurable.

Configuration (Vite+)

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

export default defineConfig({
  lint: {
    vize: {
      "preset": "incremental",
      "rules": {
        "script/no-dupe-keys": "error"
      }
    },
  },
});
vp run lint

Bad

foo is declared by both props and data, and bar by both computed and methods. Those declarations compete for the same component instance keys.

<script lang="ts">
export default {
props: ['foo'],
data() {
return { foo: 1 } // duplicate of prop `foo`
},
computed: {
bar() { return 2 }
},
methods: {
bar() {} // duplicate of computed `bar`
}
}
</script>

Good

The prop, data, and computed declarations use distinct names (foo, bar, and baz), eliminating both cross-option collisions.

<script lang="ts">
export default {
props: ['foo'],
data() {
return { bar: 1 }
},
computed: {
baz() { return 2 }
}
}
</script>

Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.

Implementation · All rules