Skip to content

Commit 62f6e82

Browse files
authored
Apply suggestions from code review
Signed-off-by: Athan <[email protected]>
1 parent 59665e5 commit 62f6e82

File tree

1 file changed

+9
-9
lines changed
  • lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-html-section-structure/lib

1 file changed

+9
-9
lines changed

lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-html-section-structure/lib/main.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function reportErr( file, node, message, errorCode ) {
7373
* @param {Object} node - AST node containing comment
7474
* @param {RegExp} matchRegex - regular expression for matching comment
7575
* @param {RegExp} simpleMatchRegex - alternative regular expression for matching comment
76-
* @returns {string|null} extracted class name or null if no match
76+
* @returns {(string|null)} extracted class name or null if no match
7777
*/
7878
function extractCommentClass( node, matchRegex, simpleMatchRegex ) {
7979
var simpleMatch;
@@ -239,7 +239,7 @@ function linter( tree, file, options, clbk ) {
239239
return;
240240
}
241241

242-
// Check if this is a section start tag
242+
// Check if this is a section start tag:
243243
sectionMatch = SECTION_START.exec( node.value );
244244
if ( sectionMatch ) {
245245
debug( 'Found a section start tag with class: %s', sectionMatch[1] || '[none]' );
@@ -281,15 +281,15 @@ function linter( tree, file, options, clbk ) {
281281

282282
// Special handling for direct closing tag followed by a comment (no text node between)...
283283
if ( index + 1 < parent.children.length ) {
284-
nextNode = parent.children[index + 1];
284+
nextNode = parent.children[ index + 1 ];
285285

286286
// Look at the next node to check if it's a comment:
287287
if ( nextNode.type === 'html' ) {
288288
// Check if the next node is a comment but NOT on the same line
289289
commentClass = extractCommentClass( nextNode, END_COMMENT, END_COMMENT_SIMPLE );
290290

291291
if ( commentClass ) {
292-
// Check if there are at least 2 line breaks between them
292+
// Check if there are at least 2 line breaks between them:
293293
if ( !hasValidWhitespace( node, nextNode ) ) {
294294
msg = 'Missing proper empty line after closing section tag. There should be an empty line between </section> and the closing comment.';
295295
errCode = 'missing-empty-line-after-section';
@@ -311,8 +311,8 @@ function linter( tree, file, options, clbk ) {
311311

312312
// Standard handling for other cases with whitespace between section end and comment...
313313
if ( index + 2 < parent.children.length ) {
314-
nextNode = parent.children[index + 1];
315-
commentNode = parent.children[index + 2];
314+
nextNode = parent.children[ index + 1 ];
315+
commentNode = parent.children[ index + 2 ];
316316

317317
// Check if the next node is a proper whitespace with empty line:
318318
if ( !hasEmptyLine( nextNode ) ) {
@@ -333,21 +333,21 @@ function linter( tree, file, options, clbk ) {
333333
} else {
334334
// The HTML node exists but it's not a proper closing comment...
335335
debug( 'Invalid closing comment format' );
336-
msg = 'Invalid section closing comment format. Expected <!-- /.' + sectionStack[sectionStack.length - 1].className + ' -->';
336+
msg = 'Invalid section closing comment format. Expected <!-- /.' + sectionStack[ sectionStack.length - 1 ].className + ' -->';
337337
errCode = 'invalid-closing-comment';
338338
reportErr( file, commentNode, msg, errCode );
339339
}
340340
} else {
341341
// The node after whitespace is not an HTML node (comment)...
342342
debug( 'Node after whitespace is not an HTML comment' );
343-
msg = 'Missing section closing comment. Section closing tag should be followed by <!-- /.' + sectionStack[sectionStack.length - 1].className + ' --> comment.';
343+
msg = 'Missing section closing comment. Section closing tag should be followed by <!-- /.' + sectionStack[ sectionStack.length - 1 ].className + ' --> comment.';
344344
errCode = 'missing-section-comment';
345345
reportErr( file, node, msg, errCode );
346346
}
347347
} else {
348348
// There's not enough nodes after the section closing tag...
349349
debug( 'Not enough nodes after section end' );
350-
msg = 'Missing section closing comment. Section closing tag should be followed by <!-- /.' + sectionStack[sectionStack.length - 1].className + ' --> comment on a separate line.';
350+
msg = 'Missing section closing comment. Section closing tag should be followed by <!-- /.' + sectionStack[ sectionStack.length - 1 ].className + ' --> comment on a separate line.';
351351
errCode = 'missing-section-comment';
352352
reportErr( file, node, msg, errCode );
353353
}

0 commit comments

Comments
 (0)