-
Notifications
You must be signed in to change notification settings - Fork 491
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
destructure props #299
destructure props #299
Conversation
To avoid error **typescript ESLint: Getting a value from the `props` in root scope of `<script setup>`** we need to destructure the props with toRefs()
Thanks for the PR, @veerman72. Are there any real-world consequences with the current code? The full ESLint error I think we're talking about
With or without this change, the values passed to the Also, I'm not too sure how If we were to use |
Thanks for your reply @jessarcher. There are no real-world consequences with the current code and yes it is the ESLint error you mentioned. If we want the values passed to the The code (only updated or added lines) then becomes:
Does it add complexity: yes. It is up to you whether you want this (updated) PR. I am not that an expert in software development as you are. I can only ask you why we use linters if we ignore the recommended settings subsets of core rules? FYI I'm using the following ESLint extend properties: |
Hey @veerman72, I prefer the reduced complexity and overhead of My view is that the problem this rule is trying to protect us from is not a problem in this case. I see a lot of value in linters and this rule, but this case seems more like a false positive. It's also worth noting this quote from the Vue docs for accessing props:
In our case, we already are accessing the props as If we were shipping Breeze with ESLint then we would definitely need a solution for this, but I'd probably be inclined to reach out to the rule maintainers and get their view on this specific scenario and see whether it should even trigger the rule. Failing that, I'd probably be inclined to configure the linter to ignore this specific case rather than code around it. I'm going to close this for now. But I'm open to other suggestions, especially if anyone can find any official Vue documentation that covers this scenario. |
To avoid error typescript ESLint: Getting a value from the
props
in root scope of<script setup>
we need to destructure the props with toRefs()