-
-
Notifications
You must be signed in to change notification settings - Fork 696
Description
Please describe what the rule should do:
This rule warns about using potentially reserved property names for props, data, computed properties, and methods. There's an ongoing discussion here, but tentatively, we're thinking of warning for any names that match the regex: /^(\$[^_]|_)/
.
We've yet to reach consensus on the exact strategy, but we'd also like to suggest a different naming strategy for private property names used in mixins/plugins. One idea is the $_
prefix, with a suggested namespace like $_pluginOrMixinName_propertyName
to avoid conflicts with other mixins/plugins.
What category of rule is this?
[ ] Enforces code style
[x] Warns about a potential error
[x] Suggests an alternate way of doing something
[ ] Other (please specify:)
Provide code examples that this rule will warn about:
A few examples to match:
new Vue({
data: {
_foo: ''
}
})
new Vue({
data: {
$foo: ''
}
})
// In a .vue file
export default {
data: function () {
return {
_foo: ''
}
}
}
// In a .vue file
export default {
data: function () {
return {
$foo: ''
}
}
}
// In a .vue file
export default {
props: ['_foo']
}
// In a .vue file
export default {
props: ['$foo']
}
// In a .vue file
export default {
props: {
_foo: {}
}
}
// In a .vue file
export default {
props: {
$foo: {}
}
}
// In a .vue file
export default {
computed: {
_foo: function () { ... }
}
}
// In a .vue file
export default {
computed: {
$foo: function () { ... }
}
}
// In a .vue file
export default {
methods: {
_foo: function () { ... }
}
}
// In a .vue file
export default {
methods: {
$foo: function () { ... }
}
}
A few examples NOT to match:
// In a .vue file
export default {
data: function () {
return {
$_foo: ''
}
}
}
// In a .vue file
export default {
props: ['$_foo']
}
// In a .vue file
export default {
props: {
$_foo: {}
}
}
// In a .vue file
export default {
computed: {
$_foo: function () { ... }
}
}
// In a .vue file
export default {
methods: {
$_foo: function () { ... }
}
}