Skip to content

Commit 2d4dc8f

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 9e3f361 commit 2d4dc8f

File tree

1 file changed

+45
-64
lines changed

1 file changed

+45
-64
lines changed

commitlint.config.ts

+45-64
Original file line numberDiff line numberDiff line change
@@ -337,33 +337,26 @@ module.exports = {
337337
];
338338
},
339339

340-
'footer-notes-misplacement': ({raw}: {raw:any}) => {
340+
'footer-notes-misplacement': ({body}: {body:any}) => {
341341
let offence = false;
342342

343-
let rawStr = convertAnyToString(raw, "raw").trim();
344-
let lineBreakIndex = rawStr.indexOf('\n');
345-
346-
if (lineBreakIndex >= 0){
347-
// Extracting bodyStr from rawStr rather than using body directly is a
348-
// workaround for https://github.com/conventional-changelog/commitlint/issues/3428
349-
let bodyStr = rawStr.substring(lineBreakIndex).trim();
343+
if (body !== null) {
344+
let bodyStr = convertAnyToString(body, "body");
350345

351-
if (bodyStr !== ''){
352-
let seenBody = false;
353-
let seenFooter = false;
354-
let lines = bodyStr.split(/\r?\n/);
355-
for (let line of lines) {
356-
if (line.length === 0){
357-
continue;
358-
}
359-
seenBody = seenBody || !isFooterNote(line);
360-
seenFooter = seenFooter || isFooterNote(line);
361-
if (seenFooter && !isFooterNote(line)) {
362-
offence = true;
363-
break;
364-
}
365-
346+
let seenBody = false;
347+
let seenFooter = false;
348+
let lines = bodyStr.split(/\r?\n/);
349+
for (let line of lines) {
350+
if (line.length === 0){
351+
continue;
352+
}
353+
seenBody = seenBody || !isFooterNote(line);
354+
seenFooter = seenFooter || isFooterNote(line);
355+
if (seenFooter && !isFooterNote(line)) {
356+
offence = true;
357+
break;
366358
}
359+
367360
}
368361
}
369362
return [
@@ -373,46 +366,39 @@ module.exports = {
373366
]
374367
},
375368

376-
'footer-references-existence': ({raw}: {raw:any}) => {
369+
'footer-references-existence': ({body}: {body:any}) => {
377370
let offence = false;
378371

379-
let rawStr = convertAnyToString(raw, "raw").trim();
380-
let lineBreakIndex = rawStr.indexOf('\n');
372+
if (body !== null) {
373+
let bodyStr = convertAnyToString(body, "body");
381374

382-
if (lineBreakIndex >= 0){
383-
// Extracting bodyStr from rawStr rather than using body directly is a
384-
// workaround for https://github.com/conventional-changelog/commitlint/issues/3428
385-
let bodyStr = rawStr.substring(lineBreakIndex).trim();
386-
387-
if (bodyStr !== ''){
388-
let lines = bodyStr.split(/\r?\n/);
389-
let bodyReferences = new Set();
390-
let references = new Set();
391-
for (let line of lines) {
392-
let matches = line.match(/(?<=\[)([0-9]+)(?=\])/g);
393-
if (matches === null) {
394-
continue;
375+
let lines = bodyStr.split(/\r?\n/);
376+
let bodyReferences = new Set();
377+
let references = new Set();
378+
for (let line of lines) {
379+
let matches = line.match(/(?<=\[)([0-9]+)(?=\])/g);
380+
if (matches === null) {
381+
continue;
382+
}
383+
for (let match of matches){
384+
if (isFooterReference(line)) {
385+
references.add(match);
395386
}
396-
for (let match of matches){
397-
if (isFooterReference(line)) {
398-
references.add(match);
399-
}
400-
else {
401-
bodyReferences.add(match);
402-
}
387+
else {
388+
bodyReferences.add(match);
403389
}
404390
}
405-
for (let ref of bodyReferences) {
406-
if (!references.has(ref)) {
407-
offence = true;
408-
break;
409-
}
391+
}
392+
for (let ref of bodyReferences) {
393+
if (!references.has(ref)) {
394+
offence = true;
395+
break;
410396
}
411-
for (let ref of references) {
412-
if (!bodyReferences.has(ref)) {
413-
offence = true;
414-
break;
415-
}
397+
}
398+
for (let ref of references) {
399+
if (!bodyReferences.has(ref)) {
400+
offence = true;
401+
break;
416402
}
417403
}
418404
}
@@ -565,16 +551,11 @@ module.exports = {
565551
];
566552
},
567553

568-
'body-soft-max-line-length': ({raw}: {raw:any}) => {
554+
'body-soft-max-line-length': ({body}: {body:any}) => {
569555
let offence = false;
570556

571-
let rawStr = convertAnyToString(raw, "raw").trim();
572-
let lineBreakIndex = rawStr.indexOf('\n');
573-
574-
if (lineBreakIndex >= 0){
575-
// Extracting bodyStr from rawStr rather than using body directly is a
576-
// workaround for https://github.com/conventional-changelog/commitlint/issues/3428
577-
let bodyStr = rawStr.substring(lineBreakIndex);
557+
if (body !== null) {
558+
let bodyStr = convertAnyToString(body, "body");
578559

579560
bodyStr = removeAllCodeBlocks(bodyStr).trim();
580561

0 commit comments

Comments
 (0)