Skip to content

Rule Proposal: vue/require-default-prop #122

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 Aug 2, 2017 · 2 comments
Closed

Rule Proposal: vue/require-default-prop #122

armano2 opened this issue Aug 2, 2017 · 2 comments

Comments

@armano2
Copy link
Contributor

armano2 commented Aug 2, 2017

Please describe what the rule should do:

This rule aims to ensure that any non-required prop declaration of a component has a corresponding default value.

What category of rule is this? (place an "X" next to just one item)

[ ] Enforces code style
[x] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

export default {
  props: {
     foo: {
         type: String
     }
  }
}
export default {
  props: {
     foo: {
         type: Array,
         required: false
     }
  }
}

based on conversation from: #117 (comment)

@michalsnik michalsnik added this to the Official release milestone Aug 3, 2017
@michalsnik
Copy link
Member

I'll pick this

@dsl101
Copy link
Contributor

dsl101 commented Feb 13, 2018

Just trying to understand this rule. Why does this code:

props: {
  id: 0
}

generate an error? Isn't a literal value for a prop the same as a default value?

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

3 participants