MCPcopy
hub / github.com/conventional-changelog/commitlint / subjectCase

Function subjectCase

@commitlint/rules/src/subject-case.ts:24–56  ·  view source on GitHub ↗
(
	parsed,
	when = "always",
	value = [],
)

Source from the content-addressed store, hash-verified

22const negated = (when?: string) => when === "never";
23
24export const subjectCase: SyncRule<TargetCaseType | TargetCaseType[]> = (
25 parsed,
26 when = "always",
27 value = [],
28) => {
29 const { subject } = parsed;
30
31 if (typeof subject !== "string" || !subject.match(startsWithLetterRegex)) {
32 return [true];
33 }
34
35 const checks = (Array.isArray(value) ? value : [value]).map((check) => {
36 if (typeof check === "string") {
37 return {
38 when: "always",
39 case: check,
40 };
41 }
42 return check;
43 });
44
45 const result = checks.some((check) => {
46 const r = ensureCase(subject, check.case);
47 return negated(check.when) ? !r : r;
48 });
49
50 const list = checks.map((c) => c.case).join(", ");
51
52 return [
53 negated(when) ? !result : result,
54 message([`subject must`, negated(when) ? `not` : null, `be ${list}`]),
55 ];
56};

Callers 1

Calls 3

ensureCaseFunction · 0.85
messageFunction · 0.85
negatedFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…