Skip to content

no-dupe-keys

Reports a name defined twice in props, computed, data, methods and setup of a component object, and a prop or defineModel of <script setup> that a top-level name of the script (a const, a function, an import) repeats, unless that name reads from the props object (const a = props.a, toRef(props, 'a')).

All of these names are put on one object that the template reads, so one of them hides the other and the template shows the wrong value.

To fix, rename one of them.

Reported
...
},
data() {
return { a: 1, h: 2 }
},
computed: {
h() { return 1 },
get k() { return 1 },
set k(v) {},
},
...
angular:
lint:
rules:
no-dupe-keys: error # off, warn, error (default)
html:
lint:
rules:
no-dupe-keys: error # off, warn, error (default)
svelte:
lint:
rules:
no-dupe-keys: error # off, warn, error (default)
vue:
lint:
rules:
no-dupe-keys: error # off, warn, error (default)

Enabled by the presets: html/eslint-plugin-vue-recommended.

Suppress one line with sudsy-disable-next-line no-dupe-keys in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
eslint-plugin-vue no-dupe-keys partial the groups option is not read; a component object only as export default, defineComponent, defineNuxtComponent or Vue.extend at the top level