@@ -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