Skip to content

feat: add rule 'no-direct-set-state-in-use-effect', closes #628 #629

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

Merged
merged 6 commits into from
Jul 14, 2024

Conversation

Rel1cx
Copy link
Owner

@Rel1cx Rel1cx commented Jul 14, 2024

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • I have added a convincing reason for adding this feature, if necessary

Other information

Copy link

vercel bot commented Jul 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eslint-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 14, 2024 10:36am

@SukkaW
Copy link
Contributor

SukkaW commented Jul 14, 2024

The rule name is a bit unclear. The rule doesn't forbid any set state in the useEffect, it only forbids set state in the top scope of the useEffect.

Maybe no-direct-set-state-in-use-effect?

@Rel1cx
Copy link
Owner Author

Rel1cx commented Jul 14, 2024

The rule name is a bit unclear. The rule doesn't forbid any set state in the useEffect, it only forbids set state in the top scope of the useEffect.

Maybe no-direct-set-state-in-use-effect?

I understand, but that's the format we use in the no-set-state-in-component-did-update rule name (which in eslint-plugin-react is called no-did-update-set-state), and also disables only setState calls in the same scope, I'm following the naming convention that we already have in our projects. We can explain the "directly" bit in the rule description and error messages.

@Rel1cx
Copy link
Owner Author

Rel1cx commented Jul 14, 2024

Maybe no-direct-set-state-in-use-effect?

no-direct-set-state-in-use-effect sounds good, I'll consider switching to this.

@Rel1cx Rel1cx changed the title feat: add rule 'no-set-state-in-use-effect', closes #628 feat: add rule 'no-direct-set-state-in-use-effect', closes #628 Jul 14, 2024
@Rel1cx Rel1cx marked this pull request as ready for review July 14, 2024 10:58
@Rel1cx Rel1cx merged commit e3229c1 into main Jul 14, 2024
6 checks passed
@Rel1cx Rel1cx deleted the no-set-state-in-use-effect branch July 17, 2024 13:32
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.

2 participants