Skip to content

Commit

Permalink
commitlint.config: remove workaround for body
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tehraninasab committed Feb 13, 2023
1 parent 60929f3 commit 0fc2f0c
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 239 deletions.
17 changes: 10 additions & 7 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
{
rules: {
"body-prose": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.bodyProse(rawStr);
},

Expand Down Expand Up @@ -92,12 +92,12 @@ module.exports = {
},

"footer-notes-misplacement": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.footerNotesMisplacement(rawStr);
},

"footer-references-existence": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.footerReferencesExistence(rawStr);
},

Expand All @@ -114,7 +114,7 @@ module.exports = {
},

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

Expand Down Expand Up @@ -165,12 +165,15 @@ module.exports = {
},

"body-soft-max-line-length": (
{ raw }: { raw: any },
{ body }: { body: any },
_: any,
maxLineLength: number
) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.bodySoftMaxLineLength(rawStr, maxLineLength);
let bodyStr = Helpers.convertAnyToString(body, "body");
return Plugins.bodySoftMaxLineLength(
bodyStr,
maxLineLength
);
},

"trailing-whitespace": ({ raw }: { raw: any }) => {
Expand Down
10 changes: 2 additions & 8 deletions commitlint/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ export abstract class Helpers {
public static convertAnyToString(
potentialString: any,
paramName: string
): string {
): string | null {
if (potentialString === null || potentialString === undefined) {
// otherwise, String(null) might give us the stupid string "null"
throw new Error(
"Unexpected " +
paramName +
"===null or " +
paramName +
"===undefined happened"
);
return null;
}
return String(potentialString);
}
Expand Down
Loading

0 comments on commit 0fc2f0c

Please sign in to comment.