JS.VUE.NO.RESERVED.KEYS

Disallow overwriting reserved keys

Rule Details

This rule prevents to use reserved names (https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/utils/vue-reserved.json) to avoid conflicts and unexpected behavior.

{'vue/no-reserved-keys': ['error']}

Copy
<script>
/* BAD */
export default {
  props: {
    $el: String
  },
  computed: {
    $on: {
      get () {}
    }
  },
  data: {
    _foo: null
  },
  methods: {
    $nextTick () {}
  }
}
</script>

Options

Copy
{
  "vue/no-reserved-keys": ["error", {
    "reserved": [],
    "groups": []
  }]
}
  • reserved (string[]) ... Array of additional restricted attributes inside groups. Default is empty.
  • groups (string[]) ... Array of additional group names to search for duplicates in. Default is empty.

"reserved": ["foo", "foo2"], "groups": ["firebase"]

{'vue/no-reserved-keys': ['error', {reserved: ['foo', 'foo2'], groups: ['firebase']}]}

Copy
<script>
/* BAD */
export default {
  computed: {
    foo () {}
  },
  firebase: {
    foo2 () {}
  }
}
</script>

Further Reading

  • List of reserved keys (https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/utils/vue-reserved.json)

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/