- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Enforcing props destructuring #2688
Comments
I agree that a rule to enforce a default style for declaring props (especially with defaults) should be provided. At the moment there are two ways for defining default values on props: const { foo = "bar" } = defineProps<{ foo?: string }>(); // Destructuring with default assignment
const props = withDefaults(defineProps<{ foo?: string }>(), { foo: "bar" }); // Wrapping defineProps with withDefaults I'd suggest creating a configurable rule allowing the project to decide which style to use for concistency. So either destructuring should be prefered or the opposite, where props should not be destructured and |
Since reactive props destructuring has been added in Vue 3.5, I think a rule for this is important for code consistency ! |
This is certainly a useful rule. It's pretty straightforward, given that a function already exists to identify usage of prop destructuring. |
Please describe what the rule should do:
The role of this rule would be to suggest props destructuring. It could also warns on its usage if necessary.
What category should the rule belong to?
[X] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
Additional context
The text was updated successfully, but these errors were encountered: