-
-
Notifications
You must be signed in to change notification settings - Fork 29
feat(react-x): add 'no-unused-props' rule #1161
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
Conversation
|
@ulrichstark is attempting to deploy a commit to the Rel1cx's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @Rel1cx, I'm already making better progress than expected on this rule. As you can see, four basic invalid and four basic valid tests are already passing. Before continuing I wanted to confirm that the direction I'm going matches your expectation of this rule. The most important question right now is if I should count prop keys as used if they are destructered/accessed from the props object, but NOT used after that (in JSX for example). I would decide for no, because that case is already covered by https://eslint.org/docs/latest/rules/no-unused-vars. See my valid tests for reference. They currently pass because destructuring from the props object is enough to be counted as used. Some other decisions I made so far:
If you notice anything incorrect in my current changes, feel free to point that out or change it to your desire. |
You are right. This aligns with our philosophy: Each rule should have a single purpose. Make multiple rules work together to achieve more complex behaviors. So far so good, Thanks for the amazing work! |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Signed-off-by: Ulrich Stark <github@ustark.de>
Signed-off-by: REL1CX <dokimondex@gmail.com>
Signed-off-by: REL1CX <dokimondex@gmail.com>
|
Now there are 38 passing tests and I'm very happy with the progress so far. Some questions:
|
|
I think we are ready for a first round of review on this PR. If the property is declared in a different file than the component, then I don't report it and actually can't even if I want because TypeScript knows the AST node, but ESlint doesn't as far as I understand. My focus was to report very conservatively to avoid false positives. Type information is required for it to work. Class components aren't supported by this rule – should I add support for it? And please double check all the changes in docs and plugin presets and there might be something missing as this is my first contribution to your project. |
Add some test cases that are closer to real-world scenarios Signed-off-by: REL1CX <dokimondex@gmail.com>
|
Signed-off-by: REL1CX <dokimondex@gmail.com>
Signed-off-by: REL1CX <dokimondex@gmail.com>
Signed-off-by: REL1CX <dokimondex@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Sorry for bothering, but I expected my rule to be available in the published version 2.0.0-beta.18 of @eslint-react/eslint-plugin but it isn't. Manually turning it on in the rules object of my eslint.config.js gives me following error:
Is that somehow expected by you or have we missed something in this PR? |
The problem is not with this PR, but with the outdated CI configuration for publishing. Thank you for your timely feedback, it helped me discover the issue. |
|
This rule has now been released in |
|
Yes thanks! What would it take to include my rule in the recommended-type-checked preset? I think a lot of developers would benefit from this rule and it already should be very low on false positives. What do you think about changing the message from "Prop |
Sorry for the delayed reply. I’m considering adding this rule to the Regarding the wording, we’ve thought about this before. After some research, we believe it’s best to stay aligned with the terminology used on https://react.dev, so I’d prefer to keep the current "prop" (consistent with react.dev) rather than switching to "property". |
Sounds great! Let me know if you need any thoughts from me and feel free to assign me to future issues related to this rule. If you want a sponsor here on GitHub, please enable GitHub sponsorships and I will be your first sponsor. Thanks for your work! |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information