Function declarations in JavaScript are generally not block scoped. This rule prevents function declarations inside nested blocks like if statements. Move your declarations to the root of your program, body, or class.
Non-Compliant Code Examples
if(test){functiondoSomething() {}}if(foo)vara;if(foo)/* some comments */vara;if(foo){functionf(){if(bar){vara;}}}if(foo)functionf(){if(bar)vara;}if(foo){varfn=function(){}}if(foo)functionf(){}functionbar() {if(foo)vara;}if(foo){vara;}classC{method() {if(test){varfoo;}}}classC{static{if(test){functionfoo() {}}}}classC{static{if(test){varfoo;}}}classC{static{if(test){if(anotherTest){varfoo;}}}}