JS.VUE.PROP.NAME.CASING

Enforce specific casing for the Prop name in Vue components

Rule Details

This rule enforce proper casing of props in vue components(camelCase).

{'vue/prop-name-casing': ['error']}

Copy
<script>
export default {
  props: {
    /* GOOD */
    greetingText: String,

    /* BAD */
    'greeting-text': String,
    greeting_text: String
  }
}
</script>

Options

Copy
{
  "vue/prop-name-casing": ["error", "camelCase" | "snake_case"]
}
  • "camelCase" (default) ... Enforce property names in props to camel case.
  • "snake_case" ... Enforce property names in props to snake case.

"snake_case"

{'vue/prop-name-casing': ['error', 'snake_case']}

Copy
<script>
export default {
  props: {
    /* GOOD */
    greeting_text: String,

    /* BAD */
    'greeting-text': String,
    greetingText: String
  }
}
</script>

Further Reading

  • Style guide - Prop name casing (https://vuejs.org/style-guide/rules-strongly-recommended.html#prop-name-casing)

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/