I have a piece of JavaScript code written for Vue that I would like to discuss. It is common practice in the JavaScript world to place the opening curly brace at the end of a line of code.
<script>
export default
{
name: 'newUser',
data () {
return {
message: 'Hello World'
}
}
}
</script>
While there is nothing inherently wrong with this approach, I personally find it a bit annoying. I prefer a different style, like this:
<script>
export default
{
name: 'newUser',
data ()
{
return
{
message: 'Hello World'
}
}
}
</script>
However, when I try to implement this style, Vue throws an error stating "Opening curly brace does not appear on the same line as controlling statement". So, my question is whether this style requirement is specific to JavaScript or just enforced by Vue. Is there a way to bypass this restriction and use the style of my choice? I suspect that not only Vue, but other JavaScript frontend frameworks like React, may also have similar preferences against the second style.