Skip to content

Commit 4524db2

Browse files
committed
commitlint.config: remove workaround for body
The workaround is not needed anymore because we're now using a recent-enough version of commitlint that includes the fix for the bug [1]. [1] conventional-changelog/commitlint#3428
1 parent 60929f3 commit 4524db2

File tree

3 files changed

+276
-245
lines changed

3 files changed

+276
-245
lines changed

commitlint.config.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
{
6060
rules: {
6161
"body-prose": ({ raw }: { raw: any }) => {
62-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
62+
let rawStr = Helpers.convertAnyToString(raw, "raw");
6363
return Plugins.bodyProse(rawStr);
6464
},
6565

@@ -91,14 +91,14 @@ module.exports = {
9191
);
9292
},
9393

94-
"footer-notes-misplacement": ({ raw }: { raw: any }) => {
95-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
96-
return Plugins.footerNotesMisplacement(rawStr);
94+
"footer-notes-misplacement": ({ body }: { body: any }) => {
95+
let bodyStr = Helpers.convertAnyToString(body, "body");
96+
return Plugins.footerNotesMisplacement(bodyStr);
9797
},
9898

99-
"footer-references-existence": ({ raw }: { raw: any }) => {
100-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
101-
return Plugins.footerReferencesExistence(rawStr);
99+
"footer-references-existence": ({ body }: { body: any }) => {
100+
let bodyStr = Helpers.convertAnyToString(body, "body");
101+
return Plugins.footerReferencesExistence(bodyStr);
102102
},
103103

104104
"prefer-slash-over-backslash": ({
@@ -114,7 +114,7 @@ module.exports = {
114114
},
115115

116116
"proper-issue-refs": ({ raw }: { raw: any }) => {
117-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
117+
let rawStr = Helpers.convertAnyToString(raw, "raw");
118118
return Plugins.properIssueRefs(rawStr);
119119
},
120120

@@ -165,12 +165,15 @@ module.exports = {
165165
},
166166

167167
"body-soft-max-line-length": (
168-
{ raw }: { raw: any },
168+
{ body }: { body: any },
169169
_: any,
170170
maxLineLength: number
171171
) => {
172-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
173-
return Plugins.bodySoftMaxLineLength(rawStr, maxLineLength);
172+
let bodyStr = Helpers.convertAnyToString(body, "body");
173+
return Plugins.bodySoftMaxLineLength(
174+
bodyStr,
175+
maxLineLength
176+
);
174177
},
175178

176179
"trailing-whitespace": ({ raw }: { raw: any }) => {

commitlint/helpers.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@ export abstract class Helpers {
1919
public static convertAnyToString(
2020
potentialString: any,
2121
paramName: string
22-
): string {
22+
): string | null {
2323
if (potentialString === null || potentialString === undefined) {
2424
// otherwise, String(null) might give us the stupid string "null"
25-
throw new Error(
26-
"Unexpected " +
27-
paramName +
28-
"===null or " +
29-
paramName +
30-
"===undefined happened"
31-
);
25+
return null;
3226
}
3327
return String(potentialString);
3428
}

0 commit comments

Comments
 (0)