Skip to content

Commit 5f12534

Browse files
committed
feat(cli): use special errorCode for missing rules/config #4142
1 parent e12ef33 commit 5f12534

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

@commitlint/cli/src/cli.ts

+6
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ async function main(args: MainArgs): Promise<void> {
316316
messages.map((message) => lint(message, loaded.rules, opts))
317317
);
318318

319+
let isRulesEmpty = false;
319320
if (Object.keys(loaded.rules).length === 0) {
320321
let input = '';
321322

@@ -340,6 +341,8 @@ async function main(args: MainArgs): Promise<void> {
340341
warnings: [],
341342
input,
342343
});
344+
345+
isRulesEmpty = true;
343346
}
344347

345348
const report = results.reduce<{
@@ -387,6 +390,9 @@ async function main(args: MainArgs): Promise<void> {
387390
if (!report.valid) {
388391
throw new CliError(output, pkg.name);
389392
}
393+
if (!report.valid && isRulesEmpty) {
394+
throw new CliError(output, pkg.name, 6);
395+
}
390396
}
391397

392398
function checkFromStdin(input: (string | number)[], flags: CliFlags): boolean {

0 commit comments

Comments
 (0)