Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const baseConfig = lintOpts.clintConfig || defaultClintConfig;
baseConfig.extends = baseConfig.extends || [];
let mergedConfig;
if (czConfigContent) {
// Hack because of some weird expectation inside of commitlint-config-cz/lib/config').get;
if (!baseConfig.rules['scope-enum']) baseConfig.rules['scope-enum'] = [0, 'never', 'bullshit'];
if (!baseConfig.rules['type-enum']) baseConfig.rules['type-enum'] = [0, 'never', 'bullshit'];
mergedConfig = mergeCZWithBaseConfig(czConfigContent, baseConfig);
} else {
mergedConfig = baseConfig;
}
const opts = await commitlint.load(mergedConfig);
const reportObj = await commitlint.lint(prTitle, opts.rules);
const report = await commitlint.format(reportObj, {color: false});
return {reportObj, report};
}
return paginate(pullRequests.getCommits(pull), async ({ data }) => {
// empty summary
const report = { valid: true, commits: [] };
const { rules } = await load(config);
// Keep counters
let errorsCount = 0;
let warnsCount = 0;
// Iterates over all commits
for (const d of data) {
const { valid, errors, warnings } = await lint(
d.commit.message,
rules
);
if (!valid) {
report.valid = false;
}
if (errors.length > 0 || warnings.length > 0) {
// Update counts
errorsCount += errors.length;
warnsCount += warnings.length;
report.commits.push({ sha: d.sha, errors, warnings });
}
}
commits.map(({ commit }) => lint(commit.message, rules))
)