#586 refactor based on https://github.com/eslint/eslint/pull/590#discussion_r9476367