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):
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
useEffectin React.#35 will help with warning about using
useEffectwithout 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
setXin auseEffectwhich also specifies the dependencyx. If the student has thesetXinside 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):useState- can use this as a basis for this and also #35 - fromeslint-plugin-react: https://github.com/yannickcr/eslint-plugin-react/blob/5f49f51dd237dd4c6758bc0c3e5b300a28770966/lib/rules/hook-use-state.js