Skip to content

Commit 07cc915

Browse files
Remove unused function addNewLineBeforeRootKeywords from src/lib.ts
- Remove `addNewLineBeforeRootKeywords` from `src/lib.ts` as it is not used in production code. - Remove corresponding unit tests and import in `src/test/suite/lib.test.ts`. - This improves code health by reducing dead code and maintenance burden. Co-authored-by: pascalre <23454966+pascalre@users.noreply.github.com>
1 parent 26c9fe4 commit 07cc915

2 files changed

Lines changed: 0 additions & 23 deletions

File tree

src/lib.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,3 @@ export function removeLeadingLineBreakOfFirstElement(delimiters: RegExpMatchArra
2828
return delimiters
2929
}
3030

31-
/**
32-
* Add a new line before each occurence of a top level keyword after a new line
33-
* @param {string} text Text to be processed
34-
* @returns {string} processed text
35-
*/
36-
export function addNewLineBeforeRootKeywords(text: string): string {
37-
return text.replace(/\n[^\s]*:/g, "\n$&")
38-
}

src/test/suite/lib.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { equal, throws} from "assert"
22

33
import {
4-
addNewLineBeforeRootKeywords,
54
prependWhitespacesOnEachLine
65
} from "../../lib"
76
import { removeTrailingCharacters } from "../../util/yaml-util"
@@ -52,17 +51,3 @@ suite("Test prependWhitespacesOnEachLine", () => {
5251
})
5352
})
5453

55-
suite("Test addNewLineBeforeRootKeywords", () => {
56-
test("should add an empty line before each top level keyword, but only if they appear after a new line", () => {
57-
const actual = `data:
58-
key: value
59-
spec: value
60-
`
61-
const expected = `data:
62-
key: value
63-
64-
spec: value
65-
`
66-
equal(addNewLineBeforeRootKeywords(actual), expected)
67-
})
68-
})

0 commit comments

Comments
 (0)