Skip to content

Commit

Permalink
commitlint,FileConventions: make tests pass
Browse files Browse the repository at this point in the history
Partial fix for:
#120

Co-authored-by: webwarrior <[email protected]>
  • Loading branch information
knocte and webwarrior-ws committed Jul 19, 2023
1 parent 948e27e commit 6cb6d10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion commitlint/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,16 @@ export abstract class Plugins {
nextWordLength + line.length + 1 >
paragraphLineMaxLength;

if (!isUrl && !lineIsFooterNote && !isNextWordTooLong) {
let isLastCharAColonBreak =
line[line.length - 1] === ":" &&
nextLine[0].toUpperCase() == nextLine[0];

if (
!isUrl &&
!lineIsFooterNote &&
!isNextWordTooLong &&
!isLastCharAColonBreak
) {
offence = true;
break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ let private WrapParagraph (text: string) (maxCharsPerLine: int) : string =
(wrappedText: string)
(remainingWords: List<Text>)
: string =

let isColonBreak (currentLine: string) (textAfter: Text) =
currentLine.EndsWith ":" && Char.IsUpper textAfter.Text.[0]

match remainingWords with
| [] -> (wrappedText + currentLine).Trim()
| word :: rest ->
Expand All @@ -214,6 +218,7 @@ let private WrapParagraph (text: string) (maxCharsPerLine: int) : string =
} when
String.length currentLine + word.Text.Length + 1
<= maxCharsPerLine
&& not(isColonBreak currentLine word)
->
processWords (currentLine + " " + word.Text) wrappedText rest
| _,
Expand Down

0 comments on commit 6cb6d10

Please sign in to comment.