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

Add No Props Destructure rule issue #143 #158

Merged
merged 4 commits into from
Aug 21, 2024
Merged

Conversation

sagi-daniel
Copy link
Contributor

@sagi-daniel sagi-daniel commented Aug 19, 2024

Summary

I have created a new rule that checks the practice of props destructuring in Vue components. The goal of this rule is to ensure code readability, maintainability, and functionality by preventing issues arising from improper handling of props changes.

I also prepared documentation that details the problems associated with props destructuring and its impact on Vue components, following the style of other documentation examples.

Description

Basic Destructuring Check: Verifies that props destructuring is not done directly with defineProps, which can lead to reactivity issues.

Related Issues

Fixes #143

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

@sagi-daniel
Copy link
Contributor Author

sagi-daniel commented Aug 19, 2024 via email

@David-Pena
Copy link
Collaborator

No no I deleted my comment. It was my mistake 🫡

@rrd108
Copy link
Owner

rrd108 commented Aug 20, 2024

@sagi-daniel I have a few requests and comments about the PR.

Are you ok with English or should I do it in Hungarian?

@sagi-daniel
Copy link
Contributor Author

sagi-daniel commented Aug 20, 2024

@sagi-daniel I have a few requests and comments about the PR.

Are you ok with English or should I do it in Hungarian?

Yes, totaly. We can speak in english. It s good opportunity improve my soft skills and hard skills at the same time.

But i couldn't find your comments and requests. :S can you tell me where i can found exactly.

@rrd108
Copy link
Owner

rrd108 commented Aug 20, 2024

I didn't commented yet as was waiting for your answer.

The first thing:
When you open the project it supposed to ask you to install the recommended extensions. One of them is eslint.

It helps us to follow the same formatting.

Please install it.

When you open any of the files you changed and do formatting it should remove the semicolumns.

Now it is harder to review the pr because I do not see what is code change at what is code change.

After you fixed it you should just commit the changes, it will update the pr and I will review that.

I am in a car this afternoon so I may need some time to check it.

And the most important part, thanks for the contribution!

@sagi-daniel
Copy link
Contributor Author

I didn't commented yet as was waiting for your answer.

The first thing: When you open the project it supposed to ask you to install the recommended extensions. One of them is eslint.

It helps us to follow the same formatting.

Please install it.

When you open any of the files you changed and do formatting it should remove the semicolumns.

Now it is harder to review the pr because I do not see what is code change at what is code change.

After you fixed it you should just commit the changes, it will update the pr and I will review that.

I am in a car this afternoon so I may need some time to check it.

And the most important part, thanks for the contribution!

Thank you! I m going to install it, I thought npm install added all necessary depedency... maybe i didnt recognize some npm warning while the project initialization.

question: Do I have to make a new branch before the PR? or just push it to the main?

@rrd108
Copy link
Owner

rrd108 commented Aug 20, 2024

It is not npm, they are vscode extensions.

You can create a new branch, but not necesarry as the PR will be merged in one step anyway.

docs/.vitepress/config.ts Outdated Show resolved Hide resolved
docs/rules/rrd/no-props-destructure.md Outdated Show resolved Hide resolved
docs/rules/rrd/no-props-destructure.md Outdated Show resolved Hide resolved
docs/rules/rrd/no-props-destructure.md Outdated Show resolved Hide resolved
docs/rules/rrd/no-props-destructure.md Show resolved Hide resolved
docs/rules/rrd/no-props-destructure.md Show resolved Hide resolved
src/rules/rrd/noPropDestructure.ts Outdated Show resolved Hide resolved
src/rules/rules.ts Outdated Show resolved Hide resolved
src/rulesReport.ts Outdated Show resolved Hide resolved
@David-Pena
Copy link
Collaborator

David-Pena commented Aug 20, 2024

I think its important to add that is possible to destructure props but using toRefs()

Example

<script setup>
const props = defineProps<{ name: string }>()
const { name } = toRefs(props) // It will keep reactivity
</script>

What do you think? @rrd108 @sagi-daniel

@rrd108
Copy link
Owner

rrd108 commented Aug 20, 2024

I think its important to add that is possible to destructure props but using toRefs()

Example

<script setup>
const props = defineProps<{ name: string }>()
const { name } = toRefs(props) // It will keep reactivity
</script>

What do you think? @rrd108 @sagi-daniel

toRefs approach is worth a dedicated rule. Keep this one here clear and simple.

@rrd108 rrd108 merged commit a7f013b into rrd108:main Aug 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add rule (rrd) props destructed
3 participants