Refactors to pass JSLint