Skip to content

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

@karlhorky

Description

@karlhorky

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):

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions