-
-
Notifications
You must be signed in to change notification settings - Fork 804
build: add remark plugin to validate expected HTML sections #6156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
build: add remark plugin to validate expected HTML sections #6156
Conversation
--- 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: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - 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 ---
--- 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: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - 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 ---
--- 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: passed - 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 ---
/stdlib update-copyright-years |
lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/linter.js
Outdated
Show resolved
Hide resolved
--- 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 ---
lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/linter.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/linter.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/linter.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
var className; | ||
|
||
// Check if this is a section start tag: | ||
sectionMatch = RE_SECTION_START.exec( node.value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question regarding the use of exec
.
else if ( RE_SECTION_END.test( node.value ) ) { | ||
if ( sectionStack.length > 0 ) { | ||
sectionStack.pop(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if ( RE_SECTION_END.test( node.value ) ) { | |
if ( sectionStack.length > 0 ) { | |
sectionStack.pop(); | |
} | |
} | |
else if ( RE_SECTION_END.test( node.value ) && sectionStack.length > 0 ) { | |
sectionStack.pop(); | |
} |
You can refactor to avoid an extra level of nesting.
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); | ||
} | ||
if ( hasOwnProp( options, 'schema' ) ) { | ||
if ( !isObject( options.schema ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fairly weak check, as I could pass in options.schema = { 'foo': 'bar', 'required': null }
and this validation test would pass.
t.fail( err.message ); | ||
} | ||
t.strictEqual( file.messages.length, 1, 'has one error for invalid asin fixture' ); | ||
t.strictEqual( file.messages[0].reason.includes('Missing required sections in "c" section: `usage`'), true, 'error identifies the missing C usage section' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to avoid use of includes
here and below. Also, spacing.
t.fail( err.message ); | ||
} | ||
t.strictEqual( file.messages.length, 1, 'has one error for fixture missing a required root section' ); | ||
t.strictEqual( file.messages[0].reason.includes('Missing required root-level sections: `usage`'), true, 'error identifies the missing section' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
t.fail( err.message ); | ||
} | ||
t.strictEqual( file.messages.length, 1, 'has one error for fixture with an incomplete C section' ); | ||
t.strictEqual( file.messages[0].reason.includes('Missing required sections in "c" section: `usage`, `examples`'), true, 'error identifies the missing C sections' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
t.fail( err.message ); | ||
} | ||
t.strictEqual( file.messages.length, 1, 'has correct number of errors with custom schema' ); | ||
t.strictEqual( file.messages[0].reason.includes('usage') && file.messages[0].reason.includes('related'), true, 'error identifies both missing sections' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left an initial round of comments.
Description
This pull request:
README.md
files have the expected HTML<section>
tag structure as mandated by stdlib conventions.Related Issues
This pull request:
<section>
tag has a matching closing tag metr-issue-tracker#49 by resolving 3).Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers