Skip to content

Commit 12e5511

Browse files
committed
chore: rename variables and define empty line regexp
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 62f6e82 commit 12e5511

File tree

1 file changed

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

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ var trim = require( '@stdlib/string/trim' );
3030
// VARIABLES //
3131

3232
var debug = logger( 'remark-lint-html-section-structure' );
33-
var SECTION_START = /<section(?:\s+class="([^"]*)")?>/;
34-
var SECTION_END = /<\/section>$/;
35-
var SECTION_END_WITH_COMMENT = /<\/section>\s*<!--\s*\/\.([^*]*)\s*-->/;
36-
var END_COMMENT_SIMPLE = /<!--\s*\/\.([^>]+)-->/;
37-
var END_COMMENT = /^\s*<!--\s*\/\.([^\s]*)\s*-->/;
33+
var RE_SECTION_START = /<section(?:\s+class="([^"]*)")?>/;
34+
var RE_SECTION_END = /<\/section>$/;
35+
var RE_SECTION_END_WITH_COMMENT = /<\/section>\s*<!--\s*\/\.([^*]*)\s*-->/;
36+
var RE_END_COMMENT_SIMPLE = /<!--\s*\/\.([^>]+)-->/;
37+
var RE_END_COMMENT = /^\s*<!--\s*\/\.([^\s]*)\s*-->/;
38+
var RE_EMPTY_LINES = /(\r?\n)\s*(\r?\n)/;
3839
var htmlSectionStructureRule;
3940

4041

@@ -148,7 +149,7 @@ function hasEmptyLine( node ) {
148149
value = node.value;
149150

150151
// Look for at least two consecutive newlines (representing an empty line):
151-
return (/(\r?\n)\s*(\r?\n)/).test( value );
152+
return RE_EMPTY_LINES.test( value );
152153
}
153154

154155

@@ -224,7 +225,7 @@ function linter( tree, file, options, clbk ) {
224225
}
225226

226227
// Check if this is a combined section end with comment on the same line (which is an error):
227-
combinedMatch = SECTION_END_WITH_COMMENT.exec( node.value );
228+
combinedMatch = RE_SECTION_END_WITH_COMMENT.exec( node.value );
228229
if ( combinedMatch ) {
229230
debug( 'Found combined section end with comment: %s', node.value );
230231
msg = 'Missing empty line between closing section tag and comment. There should be an empty line between </section> and <!-- /.' + combinedMatch[1] + ' -->';
@@ -240,7 +241,7 @@ function linter( tree, file, options, clbk ) {
240241
}
241242

242243
// Check if this is a section start tag:
243-
sectionMatch = SECTION_START.exec( node.value );
244+
sectionMatch = RE_SECTION_START.exec( node.value );
244245
if ( sectionMatch ) {
245246
debug( 'Found a section start tag with class: %s', sectionMatch[1] || '[none]' );
246247

@@ -267,7 +268,7 @@ function linter( tree, file, options, clbk ) {
267268
}
268269

269270
// Check if this is a section end tag:
270-
endMatch = SECTION_END.exec( node.value );
271+
endMatch = RE_SECTION_END.exec( node.value );
271272
if ( endMatch ) {
272273
debug( 'Found a section end tag' );
273274

@@ -286,7 +287,7 @@ function linter( tree, file, options, clbk ) {
286287
// Look at the next node to check if it's a comment:
287288
if ( nextNode.type === 'html' ) {
288289
// Check if the next node is a comment but NOT on the same line
289-
commentClass = extractCommentClass( nextNode, END_COMMENT, END_COMMENT_SIMPLE );
290+
commentClass = extractCommentClass( nextNode, RE_END_COMMENT, RE_END_COMMENT_SIMPLE );
290291

291292
if ( commentClass ) {
292293
// Check if there are at least 2 line breaks between them:
@@ -324,7 +325,7 @@ function linter( tree, file, options, clbk ) {
324325

325326
// Check if the following node is the expected comment:
326327
if ( commentNode.type === 'html' ) {
327-
match = END_COMMENT.exec( commentNode.value );
328+
match = RE_END_COMMENT.exec( commentNode.value );
328329
if ( match ) {
329330
current = sectionStack[ sectionStack.length - 1 ];
330331
msg = 'Mismatched section class in closing comment. Opening tag has class="%s1" but closing comment is <!-- /.%s2 -->. They should match.';

0 commit comments

Comments
 (0)