sindresorhus/eslint-plugin-unicorn









The issue has been solved
Rule proposal: Consistent function scoping #230
futpib posted onGitHub
A function definition should be placed as close to the top level scope as possible without breaking it's captured values.
Fail
export function create(context) {
// does not capture anything from the scope, can be moved to the outer scope
function isSpecial(node) {
return node.type === 'Special';
}
return isSpecial;
}
Pass
function isSpecial(node) {
return node.type === 'Special';
}
export function create(context) {
return isSpecial;
}
export function create(context) {
function isSpecial(node) {
return node.type === 'Special' && context.isSpecial(node);
}
return isSpecial;
}