Skip to content

Commit 032a3eb

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 032a3eb

File tree

3 files changed

+282
-258
lines changed

3 files changed

+282
-258
lines changed

commitlint.config.ts

Lines changed: 23 additions & 11 deletions
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,20 @@ 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(
96+
body,
97+
"body"
98+
)
99+
return Plugins.footerNotesMisplacement(bodyStr);
97100
},
98101

99-
"footer-references-existence": ({ raw }: { raw: any }) => {
100-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
101-
return Plugins.footerReferencesExistence(rawStr);
102+
"footer-references-existence": ({ body }: { body: any }) => {
103+
let bodyStr = Helpers.convertAnyToString(
104+
body,
105+
"body"
106+
)
107+
return Plugins.footerReferencesExistence(bodyStr);
102108
},
103109

104110
"prefer-slash-over-backslash": ({
@@ -114,7 +120,7 @@ module.exports = {
114120
},
115121

116122
"proper-issue-refs": ({ raw }: { raw: any }) => {
117-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
123+
let rawStr = Helpers.convertAnyToString(raw, "raw");
118124
return Plugins.properIssueRefs(rawStr);
119125
},
120126

@@ -165,12 +171,18 @@ module.exports = {
165171
},
166172

167173
"body-soft-max-line-length": (
168-
{ raw }: { raw: any },
174+
{ body }: { body: any },
169175
_: any,
170176
maxLineLength: number
171177
) => {
172-
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
173-
return Plugins.bodySoftMaxLineLength(rawStr, maxLineLength);
178+
let bodyStr = Helpers.convertAnyToString(
179+
body,
180+
"body"
181+
);
182+
return Plugins.bodySoftMaxLineLength(
183+
bodyStr,
184+
maxLineLength
185+
);
174186
},
175187

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

commitlint/helpers.ts

Lines changed: 2 additions & 8 deletions
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)