enable eslint block-scoped-var rule

This rule treats all `var` declarations as if they were `let` and then checks for reference errors. A few declarations had to be lifted out of their blocks.