@slippy-lint/slippy
Version:
A simple but powerful linter for Solidity
27 lines • 895 B
JavaScript
export function getAppliableFixes(fixes) {
const sortedFixes = fixes
.map((fix) => fix.slice().sort((a, b) => b.range[0] - a.range[0]))
.sort((a, b) => b[0].range[0] - a[0].range[0]);
const appliableFixes = sortedFixes.slice(0, 1);
for (const existingFix of sortedFixes.slice(1)) {
if (appliableFixes.some((fix) => fixOverlaps(existingFix, fix))) {
continue;
}
appliableFixes.push(existingFix);
}
return appliableFixes;
}
function fixOverlaps(fixA, fixB) {
for (const changeA of fixA) {
for (const changeB of fixB) {
if (changeOverlaps(changeA.range, changeB.range)) {
return true;
}
}
}
return false;
}
export function changeOverlaps(changeA, changeB) {
return changeA[0] < changeB[1] && changeB[0] < changeA[1];
}
//# sourceMappingURL=autofix.js.map