Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): use special errorCode for missing rules/config #4142 #4143

Merged
merged 6 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions @commitlint/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ async function main(args: MainArgs): Promise<void> {
messages.map((message) => lint(message, loaded.rules, opts))
);

let isRulesEmpty = false;
if (Object.keys(loaded.rules).length === 0) {
let input = '';

Expand All @@ -340,6 +341,8 @@ async function main(args: MainArgs): Promise<void> {
warnings: [],
input,
});

isRulesEmpty = true;
}

const report = results.reduce<{
Expand Down Expand Up @@ -387,6 +390,9 @@ async function main(args: MainArgs): Promise<void> {
if (!report.valid) {
throw new CliError(output, pkg.name);
}
if (!report.valid && isRulesEmpty) {
throw new CliError(output, pkg.name, 6);
escapedcat marked this conversation as resolved.
Show resolved Hide resolved
}
}

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