-
Notifications
You must be signed in to change notification settings - Fork 84
fix: wrong location reporting in fenced-code-language
#518
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
mdjermanovic
merged 14 commits into
main
from
fix-wrong-location-reporting-in-fenced-code-language
Sep 9, 2025
Merged
fix: wrong location reporting in fenced-code-language
#518
mdjermanovic
merged 14 commits into
main
from
fix-wrong-location-reporting-in-fenced-code-language
Sep 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ong-location-reporting-in-fenced-code-language
lumirlumir
commented
Sep 8, 2025
| } | ||
|
|
||
| /** @type {number} */ | ||
| let openingCodeFenceEndOffset; |
Member
Author
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.
I got the variable name from the CommonMark specification.
https://spec.commonmark.org/0.31.2/#fenced-code-block
mdjermanovic
approved these changes
Sep 9, 2025
Member
mdjermanovic
left a 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.
LGTM, thanks!
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
Which language are you using?
CommonMark and GFM.
What did you do?
When using the
fenced-code-languagerule, theendColumnerror location is reported incorrectly in the 'What did you expect to happen' example below:What did you expect to happen?
First Problem
I expected the error location to end at the last backtick or tilde character, but it extends endlessly when there are spaces after the backtick or tilde.
<!-- eslint markdown/fenced-code-language: "error" -->Second Problem
I expected the
endColumnerror location to be17, but it reports20, which exceeds the actual line length.<!-- eslint markdown/fenced-code-language: ["error", { required: ["js"] }] -->Codenode: AST)The following error location would help identify the problem:
{ messageId: "disallowedLanguage", data: { lang: "javascript" }, line: 1, column: 4, endLine: 1, + endColumn: 17, - endColumn: 20, },Link to minimal reproducible Example
Adding the following test cases to the
invalidtests intests/rules/fenced-code-language.test.jscauses the tests to fail due to incorrect error reporting location.markdown/tests/rules/fenced-code-language.test.js
Line 96 in f6d6b76
First Problem
Second Problem
What changes did you make? (Give an overview)
I've updated the rule so it reports the error location correctly.
Also, I've added test cases.
Related Issues
N/A
Is there anything you'd like reviewers to focus on?
N/A