Skip to content

feat: add REPL text lint rule to catch semicolon omission in examples #2435

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

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ var endsWith = require( '@stdlib/string/ends-with' );
// MAIN //

/**
* Rule for enforcing that semicolons are omitted if output is not suppressed.
* Rule for enforcing that semicolons are omitted only if output is not suppressed.
*
* @param {Context} context - lint context
* @returns {Object} validators
*/
function main( context ) {
/**
* Checks examples section for whether semicolons are always omitted if output is not suppressed.
* Checks examples section for whether semicolons are omitted only if output is not suppressed.
*
* @private
* @param {Object} section - examples section
Expand All @@ -49,6 +49,9 @@ function main( context ) {
if ( endsWith( current.code, ';' ) && current.output ) {
context.report( 'Omit semicolons if output shall not be suppressed', section );
}
if ( !endsWith( current.code, ';' ) && !current.output ) {
context.report( 'Semicolons must not be omitted if output is suppressed', section );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/_tools/repl-txt/rules/code-semicolons",
"version": "0.0.0",
"description": "Lint rule to enforce that semicolons are omitted if output is not suppressed.",
"description": "Lint rule to enforce that semicolons are omitted only if output is not suppressed.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
Expand Down