Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 03cce8a

Browse files
committed
Updated CHANGELOG and precommit script
1 parent 67fdb2d commit 03cce8a

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"quotes": ["error", "double"],
2525
"semi": ["error", "always"],
2626
"react/prop-types": "off",
27+
"no-constant-condition": ["error", { "checkLoops": false }],
2728
"@typescript-eslint/no-explicit-any": "off"
2829
}
2930
}

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
88

99
- [[Unreleased]](#unreleased)
1010
- [[v1.3.2] - (2020-12-02)](#v132---2020-12-02)
11-
- [[v1.3.1] - (2020-11-30)](#v131---2020-11-30)
1211
- [Added](#added)
13-
- [[v1.3.0] - (2020-11-27)](#v130---2020-11-27)
12+
- [[v1.3.1] - (2020-11-30)](#v131---2020-11-30)
1413
- [Added](#added-1)
14+
- [[v1.3.0] - (2020-11-27)](#v130---2020-11-27)
15+
- [Added](#added-2)
1516
- [Dependencies](#dependencies)
1617
- [[v1.2.3] - (2020-11-26)](#v123---2020-11-26)
1718
- [Removed](#removed)
@@ -20,15 +21,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
2021
- [[v1.2.1] - (2020-11-26)](#v121---2020-11-26)
2122
- [Fixed](#fixed-1)
2223
- [[v1.2.0] - (2020-11-26)](#v120---2020-11-26)
23-
- [Added](#added-2)
24+
- [Added](#added-3)
2425
- [Changed](#changed)
2526
- [[v1.1.0] - (2020-11-24)](#v110---2020-11-24)
26-
- [Added](#added-3)
27+
- [Added](#added-4)
2728
- [Changed](#changed-1)
2829
- [[v1.0.2] - (2020-11-23)](#v102---2020-11-23)
2930
- [Changed](#changed-2)
3031
- [[1.0.1] - (2020-11-23)](#101---2020-11-23)
31-
- [Added](#added-4)
32+
- [Added](#added-5)
3233
- [Fixed](#fixed-2)
3334
- [[1.0.0] - (2020-11-23)](#100---2020-11-23)
3435

@@ -38,6 +39,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
3839

3940
## [v1.3.2] - (2020-12-02)
4041

42+
### Added
43+
44+
- Demos & Demos Documentation
45+
4146
---
4247

4348
## [v1.3.1] - (2020-11-30)

scripts/precommit.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,68 @@ const checkChangelog = async () => {
7979

8080
const { document } = createDom(changelog);
8181

82-
const mostRecent = document.getElementsByTagName("h2").item(1)?.innerHTML;
82+
const mostRecentHeading = document.getElementsByTagName("h2").item(1);
8383

84-
if (versions.find((v) => mostRecent?.includes(v)) === undefined)
84+
const mostRecentSubheadings: string[] = [];
85+
86+
let nextSibling: Element | null | undefined = mostRecentHeading;
87+
88+
while (true) {
89+
nextSibling = nextSibling?.nextElementSibling;
90+
const tag = nextSibling?.tagName;
91+
if (tag === "H2") break;
92+
if (tag !== "H3") continue;
93+
94+
mostRecentSubheadings.push(nextSibling?.innerHTML ?? "");
95+
}
96+
97+
const mostRecentTOC = document.getElementsByTagName("li").item(1);
98+
99+
const mostRecentTOCLink = mostRecentTOC
100+
?.getElementsByTagName?.("a")
101+
?.item?.(0);
102+
103+
const mostRecentTOCChildren = Array.from(
104+
mostRecentTOC?.getElementsByTagName("ul")?.item(0)?.children ?? []
105+
);
106+
107+
const mostRecentHeadingTitle = mostRecentHeading?.innerHTML;
108+
109+
if (versions.find((v) => mostRecentHeadingTitle?.includes(v)) === undefined)
85110
errors.push("Please update the CHANGELOG with the next planned release");
86111

87-
const date = mostRecent?.match(/\((.*)\)/)?.[1];
112+
const date = mostRecentHeadingTitle?.match(/\((.*)\)/)?.[1];
88113

89114
if (date !== today)
90115
errors.push(
91116
"Please update the upcoming release in the CHANGELOG with today's date"
92117
);
93118

94-
const mostRecentTOC = document.getElementsByTagName("a").item(3)?.innerHTML;
119+
const mostRecentTOCTitle = mostRecentTOCLink?.innerHTML;
95120

96-
if (versions.find((v) => mostRecentTOC?.includes(v)) === undefined)
121+
if (versions.find((v) => mostRecentTOCTitle?.includes(v)) === undefined)
97122
errors.push(
98123
"Please update the CHANGELOG Table of Contents with the next planned release"
99124
);
100125

101-
const dateTOC = mostRecentTOC?.match(/\((.*)\)/)?.[1];
126+
const dateTOC = mostRecentTOCTitle?.match(/\((.*)\)/)?.[1];
102127

103128
if (dateTOC !== today)
104129
errors.push(
105130
"Please update the upcoming release in the CHANGELOG Table of Contents with today's date"
106131
);
107132

133+
mostRecentSubheadings.forEach((heading, i) => {
134+
const child = mostRecentTOCChildren[i];
135+
const name = child?.getElementsByTagName("a")?.item(0)?.innerHTML;
136+
137+
if (name !== heading) {
138+
errors.push(
139+
`Please update the Changelog Table of Contents with subsection "${heading}" of the next planned release`
140+
);
141+
}
142+
});
143+
108144
if (errors.length) throw errors;
109145
} catch (e) {
110146
console.log(e);

0 commit comments

Comments
 (0)