declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
22 lines • 1.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequiredActionForFile = void 0;
const type_fns_1 = require("type-fns");
const domain_1 = require("../../../domain");
/**
* returns what the required action is for a file, based on all of the evaluations for that file
*/
const getRequiredActionForFile = ({ evaluations, }) => {
// if the file passed all of the practice evaluations, then no change
const passedAll = evaluations.every(domain_1.hasPassed);
if (passedAll)
return domain_1.RequiredAction.NO_CHANGE; // nothing to do if passed everything
// if the file failed some evaluations, see if all of the failed ones are fixable
const failedEvaluations = evaluations.filter((0, type_fns_1.withNot)(domain_1.hasPassed));
const allFailedEvaluationsAreAutomaticallyFixable = failedEvaluations.every(domain_1.isFixablePractice);
if (allFailedEvaluationsAreAutomaticallyFixable)
return domain_1.RequiredAction.FIX_AUTOMATIC;
return domain_1.RequiredAction.FIX_MANUAL;
};
exports.getRequiredActionForFile = getRequiredActionForFile;
//# sourceMappingURL=getRequiredActionForFile.js.map
;