Skip to content

Conversation

brettz9
Copy link
Collaborator

@brettz9 brettz9 commented Aug 16, 2025

feat(require-hyphen-before-param-description): when always is set, disallow hyphen at end of line; fixes #1435

@brettz9 brettz9 requested a review from Copilot August 16, 2025 09:57
@brettz9 brettz9 added the bug label Aug 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the require-hyphen-before-param-description rule to handle a specific edge case where hyphens at the end of lines (before descriptions that start on the next line) cause display issues in Visual Studio Code. When the rule is configured to "always" require hyphens, it now disallows hyphens that appear at the end of a line without any description text following on the same line.

Key changes:

  • Added logic to detect hyphens followed immediately by newlines and treat them as invalid even when "always" mode is enabled
  • Updated the fixer to properly handle the removal of trailing hyphens
  • Added comprehensive test cases covering the new behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/rules/requireHyphenBeforeParamDescription.js Core rule implementation with new logic to detect and handle trailing hyphens
test/rules/assertions/requireHyphenBeforeParamDescription.js Test cases for the new trailing hyphen detection behavior
docs/rules/require-hyphen-before-param-description.md Documentation updates explaining the new behavior and fixer functionality
.README/rules/require-hyphen-before-param-description.md README template updates matching the documentation changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@otomad
Copy link

otomad commented Aug 30, 2025

I suggest to revise the error message. The current error message directly uses the error message when setting to never, which may confuse users who set it to always. So I suggest to add a new message which mentions hyphen before EOL.

@brettz9
Copy link
Collaborator Author

brettz9 commented Sep 2, 2025

Good catch. I've updated the PR if you care to check.

It should now say "There must be no hyphen followed by newline in a @param description." whether "always" or "never" is set.

(Btw, am in China now where outside Internet is spotty these days, so that may explain my taking longer to get back to you.)

@otomad
Copy link

otomad commented Sep 2, 2025

It doesn’t matter, I’m in China too.

@otomad
Copy link

otomad commented Sep 2, 2025

There must be no hyphen followed by newline in a @param description.

The new message seems to imply that end of line with a hyphen in the description is invalid. For example:

/**
 * @param foo
 * The quick brown fox jumps -
 * over a lazy dog.          ^
 */

but in fact this is not the case.

@brettz9
Copy link
Collaborator Author

brettz9 commented Sep 2, 2025

Good point. I've amended to "There must be no hyphen followed by newline in the first line of a @param description." Does that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[require-hyphen-before-param-description]: Except when line break
2 participants