Skip to content

Commit

Permalink
refactor(lint): rewrite missing rule error message
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Feb 25, 2024
1 parent f532fb2 commit 14d47e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion @commitlint/lint/src/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ test('throws for invalid rule names', async () => {
bar: [RuleConfigSeverity.Warning, 'never'],
});

await expect(error).rejects.toThrow(/^Found invalid rule names: foo, bar/);
await expect(error).rejects.toThrow(
/^Found rules without implementation: foo, bar/
);
});

test('throws for invalid rule config', async () => {
Expand Down
7 changes: 4 additions & 3 deletions @commitlint/lint/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ export default async function lint(
if (missing.length > 0) {
const names = [...allRules.keys()];
throw new RangeError(
`Found invalid rule names: ${missing.join(
', '
)}. Supported rule names are: ${names.join(', ')}`
[
`Found rules without implementation: ${missing.join(', ')}.`,
`Supported rules are: ${names.join(', ')}.`,
].join('\n')
);
}

Expand Down

0 comments on commit 14d47e5

Please sign in to comment.