@putout/plugin-remove-empty
Version:
🐊Putout plugin adds ability to find and remove blocks with empty body
23 lines (15 loc) • 514 B
JavaScript
import {operator} from 'putout';
const {remove} = operator;
export const report = () => `Avoid empty nested patterns`;
export const fix = (path) => remove(path.parentPath);
export const filter = (path) => {
if (path.isArrayPattern() && path.node.elements.length)
return false;
if (path.isObjectPattern() && path.node.properties.length)
return false;
return path.parentPath.isObjectProperty();
};
export const include = () => [
'ArrayPattern',
'ObjectPattern',
];