diff --git a/commitlint/plugins.ts b/commitlint/plugins.ts index 03a472337..5bdd3b855 100644 --- a/commitlint/plugins.ts +++ b/commitlint/plugins.ts @@ -3,6 +3,34 @@ import { Helpers } from "./helpers"; export abstract class Plugins { public static bodyProse(rawStr: string) { + function paragraphHasValidEnding(paragraph: string): boolean { + let paragraphWords = paragraph.split(" "); + let lastWordInParagraph = paragraphWords[paragraphWords.length - 1]; + let isParagraphEndingWithUrl = + Helpers.isValidUrl(lastWordInParagraph); + if (isParagraphEndingWithUrl) { + return true; + } + + let endingChar = paragraph[paragraph.length - 1]; + if ( + endingChar === "." || + endingChar === ":" || + endingChar === "!" || + endingChar === "?" + ) { + return true; + } + if ( + endingChar === ")" && + paragraph.length > 1 && + paragraphHasValidEnding(paragraph[paragraph.length - 2]) + ) { + return true; + } + return false; + } + let offence = false; rawStr = rawStr.trim(); @@ -16,35 +44,6 @@ export abstract class Plugins { bodyStr = Helpers.removeAllCodeBlocks(bodyStr).trim(); if (bodyStr !== "") { - function paragraphHasValidEnding(paragraph: string): boolean { - let paragraphWords = paragraph.split(" "); - let lastWordInParagraph = - paragraphWords[paragraphWords.length - 1]; - let isParagraphEndingWithUrl = - Helpers.isValidUrl(lastWordInParagraph); - if (isParagraphEndingWithUrl) { - return true; - } - - let endingChar = paragraph[paragraph.length - 1]; - if ( - endingChar === "." || - endingChar === ":" || - endingChar === "!" || - endingChar === "?" - ) { - return true; - } - if ( - endingChar === ")" && - paragraph.length > 1 && - paragraphHasValidEnding(paragraph[paragraph.length - 2]) - ) { - return true; - } - return false; - } - for (let paragraph of Helpers.splitByEOLs(bodyStr, 2)) { paragraph = paragraph.trim(); diff --git a/tsconfig.json b/tsconfig.json index ddd301662..0b326deb2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { "strict": true, + "esModuleInterop": true, + "downlevelIteration": true, + "lib": ["ES2021"], }, }