vue/prop-name-casing
enforce specific casing for the Prop name in Vue components
- ⚙️ This rule is included in all of
"plugin:vue/strongly-recommended"
,*.configs["flat/strongly-recommended"]
,"plugin:vue/vue2-strongly-recommended"
,*.configs["flat/vue2-strongly-recommended"]
,"plugin:vue/recommended"
,*.configs["flat/recommended"]
,"plugin:vue/vue2-recommended"
and*.configs["flat/vue2-recommended"]
.
📖 Rule Details
This rule enforce proper casing of props in vue components(camelCase).
<script>
export default {
props: {
/* ✓ GOOD */
greetingText: String,
/* ✗ BAD */
'greeting-text': String,
greeting_text: String
}
}
</script>
🔧 Options
json
{
"vue/prop-name-casing": ["error",
"camelCase" | "snake_case",
{
"ignoreProps": []
}
]
}
"camelCase"
(default) ... Enforce property names inprops
to camel case."snake_case"
... Enforce property names inprops
to snake case.ignoreProps
(string[]
) ... An array of prop names (or patterns) that don't need to follow the specified casing.
"snake_case"
<script>
export default {
props: {
/* ✓ GOOD */
greeting_text: String,
/* ✗ BAD */
'greeting-text': String,
greetingText: String
}
}
</script>
"ignoreProps": ["foo-bar", "/^_[a-z]+/u"]
<script>
export default {
props: {
/* ✓ GOOD */
greetingText: String,
'foo-bar': String,
_uid: String,
/* ✗ BAD */
'greeting-text': String,
greeting_text: String,
foo_bar: String
}
}
</script>
👫 Related Rules
📚 Further Reading
🚀 Version
This rule was introduced in eslint-plugin-vue v4.3.0