Skip to content
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

missing not required props #2235

Closed
3 tasks done
kibilizard opened this issue Sep 4, 2020 · 24 comments
Closed
3 tasks done

missing not required props #2235

kibilizard opened this issue Sep 4, 2020 · 24 comments
Labels

Comments

@kibilizard
Copy link

kibilizard commented Sep 4, 2020

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Win
  • Vetur version: 0.27.1
  • VS Code version: 1.48.2

Problem

in linting missed props whitch does not set as required
missing_props

Reproducible Case

https://github.com/kibilizard/missing_non_required
testmissing

@yoyo930021
Copy link
Member

yoyo930021 commented Sep 4, 2020

In #2141 ,
When no required or default, it have a warning about not have props.
So it's a feature not a bug.

@kaangokdemir
Copy link

kaangokdemir commented Sep 4, 2020

Even it might be a good feature for new projects, is there a way to close this one especially for legacy projects? Also it's not working with v-model binding for value props.

Screenshots:

Ekran Resmi 2020-09-04 11 19 28

Ekran Resmi 2020-09-04 11 19 22

Ekran Resmi 2020-09-04 11 19 11

@kibilizard
Copy link
Author

In #2141 ,
When no required or default, it have a warning about not have props.
So it's a feature not a bug.

you offer me to rewrite all projects because it your new feature?

@yoyo930021
Copy link
Member

Even it might be a good feature for new projects, is there a way to close this one especially for legacy projects? Also it's not working with v-model binding for value props.

Screenshots:

Ekran Resmi 2020-09-04 11 19 28 Ekran Resmi 2020-09-04 11 19 22 Ekran Resmi 2020-09-04 11 19 11

I add a issue about this.
#2236

@yoyo930021
Copy link
Member

yoyo930021 commented Sep 4, 2020

In #2141 ,
When no required or default, it have a warning about not have props.
So it's a feature not a bug.

you offer me to rewrite all projects because it your new feature?

It don't effect in runtime, so you can ignore it.
This feature is a reminder.
Maybe we can add a option to disable prop validator warning.
@octref

@victorgarciaesgi
Copy link

victorgarciaesgi commented Sep 4, 2020

In #2141 ,
When no required or default, it have a warning about not have props.
So it's a feature not a bug.

Why does it needs to display a warning when all the props are optional?

@ilyakamens
Copy link

ilyakamens commented Sep 4, 2020

This is a great tool, and I've really enjoyed using it for the last several months.

I also see yellow squiggly underlines for non-required properties. I personally find it very distracting. IMHO, I'm not sure a warning is necessary for omitting an optional parameter, which I think is a standard use case. For example, Python linters don't complain when omitting **kwargs to function calls. It'd be great if there was a way to opt out of these warnings!

@octref
Copy link
Member

octref commented Sep 4, 2020

@ilyakamens #2249

@Killea
Copy link

Killea commented Sep 4, 2020

The logic is wrong.

@dipasqualew
Copy link

Can reproduce on VS Code on Ubuntu 20.04, in a Vue-Cli + TypeScript project.

The implementation fails the common use case of binding value with v-model. This breaks the linter. Please provide a way to disable the rule or account for situations where props are provided via directives.

Thanks

@adlio
Copy link

adlio commented Sep 4, 2020

Here by way of Google help future searchers. When using v-model attributes, they all report:

<MyComponent> misses props: value

So if you're googling for why you're seeing "misses props: value" messages... this issue explains why.

@tobiasdalhof
Copy link

tobiasdalhof commented Sep 4, 2020

0.27.0 and 0.27.1 are broken? rolled back to 0.26.1 and the error was gone

image

@kmilogp8496
Copy link

kmilogp8496 commented Sep 5, 2020

Hi.
I've found this feature very useful, but I think you should fix this little issues with v-model and no required props. It would be nice to have type validation in template too. Thanks.

@panbehkar
Copy link

I have this issue too -_-

@rockmandash
Copy link

@yoyo930021 Are optional props need to explicitly defined required: false in props section?

I just want to know what is the standard way to write Vue components.

@octref
Copy link
Member

octref commented Sep 6, 2020

https://github.com/vuejs/vetur/releases/tag/v0.27.2

@octref octref closed this as completed Sep 6, 2020
@dipasqualew
Copy link

Thank you @octref for your quick reaction on this 🙂

@yoyo930021
Copy link
Member

@yoyo930021 Are optional props need to explicitly defined required: false in props section?

I just want to know what is the standard way to write Vue components.

I'd expect at least required or default for a serious pursuit.

props: {
  foo: {
    type: String
  }
}

But I think this case might be taken as required: false.
I will talk to @octref.

@yoyo930021
Copy link
Member

yoyo930021 commented Sep 7, 2020

In #2141 ,
When no required or default, it have a warning about not have props.
So it's a feature not a bug.

Why does it needs to display a warning when all the props are optional?

First of all, I didn't design this feature or at least not at first.
I found it in #2135 and handle some case in #2141

I think this feature is a reminder,
That's why we replace the error with a warning when it's not strictly defined.
I think VSCode's warning was too obvious and #2238 .
That's what's causing all the trouble.
But I think it's still a useful feature for strict projects.

@tomitrescak
Copy link

Sorry to write here, but I am not getting the error for required props. My prop is required, yet no warning or error is shown on the component that does not specify it.

@yoyo930021
Copy link
Member

yoyo930021 commented Oct 27, 2020

Sorry to write here, but I am not getting the error for required props. My prop is required, yet no warning or error is shown on the component that does not specify it.

Please set { "vetur.validation.templateProps": true }

@tomitrescak
Copy link

Thanks for the super fast answer. Got it!

@meatnordrink
Copy link

It's unfortunate that this is all-or-none. It would be great to have a warning when a required prop is missing; it's a hindrance to have an optional prop not passed throw a warning.

The most logical and helpful behavior would be:

  • Error when a required prop is missing;
  • No error when an optional prop isn't (because, as the property is optional, that isn't an error).

The solution above, turning off { "vetur.validation.templateProps": true }, means you have to choose between faulty validation or no validation.

(I realize Vetur is in an awkward position, as it's a volunteer project that's become fairly critical to the Vue community. .)

@IcedNet
Copy link

IcedNet commented Apr 25, 2021

The logic is incorrect, if the prop is not required, not even if you are being "strict".
There is no need for any information at all.
I enjoy this tool, and several forks implement this properly - perhaps adopt one of their fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests