Skip to content

vue/prop-name-casing should allow "onUpdate:fooBar" #1911

Open
@Fuzzyma

Description

@Fuzzyma

What rule do you want to change?

vue/prop-name-casing
vue/attribute-hyphenation

Does this change cause the rule to produce more or fewer warnings?

Fewer

How will the change be implemented? (New option, new default behavior, etc.)?

New default behavior

Please provide some example code that this change will affect:

<script lang="ts" setup>
const props = defineProps({
  data: {
    type: Array as PropType<Data>,
    required: true,
  },
  'onUpdate:data': {
    type: Function as PropType<(data: Data) => any | Promise<any>>,
  },
})
</script>

What does the rule currently do for this code?

This shows a warning for 'onUpdate:data' because it is not considered camelCase. However, this is the normal description of an update handler defined via v-model

What will the rule do after it's changed?

It shouldn't warn. This is a valid prop and used if you want to have more control about the v-model cycle (e.g. awaiting a promise as in this example).

This could easily be fixed by treating : as an uppercase letter.

Additional context

vue/attribute-hyphenation is related and should also be changed. It is impossible to pass a prop like :on-update:model-value because i will complain. However, its a valid prop! I am not sure if vue supports on-update as replacement for onUpdate. If not, it should be always allowed to write onUpdate

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions