@putout/plugin-remove-useless-continue
Version:
🐊Putout plugin adds ability to remove useless 'continue'
31 lines (22 loc) • 636 B
JavaScript
import {operator} from 'putout';
const {remove} = operator;
const isLoop = (path) => path.isLoop() || path.parentPath.isLoop();
export const report = () => `Avoid useless 'continue'`;
export const fix = (path) => {
remove(path);
};
export const traverse = ({push}) => ({
ContinueStatement(path) {
const {parentPath} = path;
if (!isLoop(parentPath))
return;
if (parentPath.get('body') === path) {
push(path);
return;
}
if (parentPath.isBlockStatement()) {
push(path);
return;
}
},
});