Skip to content

Rule proposition: no-shared-component-data must be a function. #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
armano2 opened this issue Jul 15, 2017 · 4 comments
Closed

Rule proposition: no-shared-component-data must be a function. #79

armano2 opened this issue Jul 15, 2017 · 4 comments

Comments

@armano2
Copy link
Contributor

armano2 commented Jul 15, 2017

When using the data property on a component (i.e. anywhere except on new Vue), the value must be a function that returns an object.

based on style guide

Invalid:

Vue.component('some-comp', {
  data: {
    foo: 'bar'
  }
})
export default {
  data: {
    foo: 'bar'
  }
}

Valid:

new Vue({
  data: function () {
    return {
      foo: 'bar'
    }
  }
})
new Vue({
  data: {
    foo: 'bar'
  }
})
Vue.component('some-comp', {
  data: function () {
    return {
      foo: 'bar'
    }
  }
})
export default {
  data: function () {
    return {
      foo: 'bar'
    }
  }
}
@armano2 armano2 changed the title Rule component data must be a function. Rule proposition: component data must be a function. Jul 15, 2017
@armano2
Copy link
Contributor Author

armano2 commented Jul 16, 2017

Can I start working on this rule?

@armano2 armano2 changed the title Rule proposition: component data must be a function. Rule proposition: (component-data) component data must be a function. Jul 16, 2017
@armano2 armano2 changed the title Rule proposition: (component-data) component data must be a function. Rule proposition: component-data must be a function. Jul 16, 2017
@michalsnik
Copy link
Member

I definitely agree with this one 👍 It's something strongly advised in vue documentation and I think it's a must have rule in our set.

@armano2
Copy link
Contributor Author

armano2 commented Jul 16, 2017

it's already implemented and ready for review 🍡

@armano2 armano2 changed the title Rule proposition: component-data must be a function. Rule proposition: return-in-computed-property must be a function. Jul 17, 2017
@armano2 armano2 changed the title Rule proposition: return-in-computed-property must be a function. Rule proposition: component-data must be a function. Jul 17, 2017
@armano2 armano2 changed the title Rule proposition: component-data must be a function. Rule proposition: no-shared-component-data must be a function. Jul 19, 2017
@michalsnik
Copy link
Member

Released in v3.8.0. Thanks @armano2 !

@armano2 armano2 self-assigned this Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants