Skip to content

Conversation

@lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented Aug 4, 2025

Prerequisites checklist

What is the purpose of this pull request?

Which language are you using?

CommonMark and GFM.

What did you do?

@eslint/markdown is unable to detect CR line endings in certain rules.

What did you expect to happen?

I expect CR line endings to be recognized as valid line endings throughout the Markdown rules.

According to the Markdown(CommonMark) specification, LF, CR, and CRLF can all be used for line endings.

https://spec.commonmark.org/0.31.2/#line-ending

Image

What changes did you make? (Give an overview)

This PR is follow-up to #554 and #555.

In this PR, I've updated the no-reversed-media-syntax rule to recognize CR line endings as a valid line break pattern.

I've also refactored the no-html and no-reference-like-urls rules, and added some additional comments to each file.

Related Issues

Refs: #554, #555, #491 (comment)

Is there anything you'd like reviewers to focus on?

N/A

@eslint-github-bot eslint-github-bot bot added the bug label Aug 4, 2025
@lumirlumir lumirlumir changed the title fix: add CR to the line ending pattern fix: add CR to the line ending pattern to follow CommonMark spec Aug 4, 2025
@lumirlumir
Copy link
Member Author

For a complete fix, #376 is a prerequisite, as some internal rules are closely tied to self-implemented line break logic.

@lumirlumir lumirlumir changed the title fix: add CR to the line ending pattern to follow CommonMark spec fix: handle CR in rules to follow CommonMark spec Oct 11, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

This rule already supports CR line endings, so I only refactored the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Motivated by #525, I've simplified the regex a bit.

Since imageBang and title can be retrieved directly from the node's information, I've updated the code to access them directly from the nodes.

(This rule already supports CR line endings, so I only refactored the code.)

@lumirlumir lumirlumir marked this pull request as ready for review October 11, 2025 11:24
@lumirlumir lumirlumir requested a review from nzakas October 11, 2025 11:25
…d-cr-to-line-ending-to-follow-spec-strictly
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@nzakas nzakas merged commit 20e88fe into main Oct 20, 2025
24 checks passed
@nzakas nzakas deleted the fix-add-cr-to-line-ending-to-follow-spec-strictly branch October 20, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants