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

New Rule: Detect infinite loops in code and warn #36

Open
karlhorky opened this issue Jan 22, 2022 · 1 comment
Open

New Rule: Detect infinite loops in code and warn #36

karlhorky opened this issue Jan 22, 2022 · 1 comment
Assignees

Comments

@karlhorky
Copy link
Member

karlhorky commented Jan 22, 2022

Not sure if this should be an ESLint rule or a Preflight check (opened upleveled/preflight#193 for the Preflight check), but detecting infinite loops in student code would be really nice, especially when students get into using useEffect in React.

#35 will help with warning about using useEffect without a dependency array, but there are other forms of infinite loops.

One potential candidate for detecting infinite loops would be to detect if the student has an (unconditional) call to setX in a useEffect which also specifies the dependency x. If the student has the setX inside a condition, this would not trigger.

Some other, more general ideas for infinite loop detection:

Potentially helpful for getting a reference to useEffect (maybe already implemented in #35):

@karlhorky
Copy link
Member Author

karlhorky commented Aug 27, 2024

One potential candidate for detecting infinite loops would be to detect if the student has an
... call to setX in a useEffect which also specifies the dependency x.

This may be achieved by this:

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

No branches or pull requests

1 participant