Skip to content

Commit

Permalink
fix: position could be null actually (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Jan 14, 2024
1 parent 2da97b2 commit ee3b593
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-eagles-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-mdx": patch
---

fix: `position` could be `null` actually - related to #520
8 changes: 5 additions & 3 deletions packages/eslint-plugin-mdx/src/rules/remark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const remark: Rule.RuleModule = {
fatal,
line,
column,
position: { start, end },
position,
} of messages) {
// https://github.com/remarkjs/remark-lint/issues/65#issuecomment-220800231
/* istanbul ignore next */
Expand All @@ -83,6 +83,8 @@ export const remark: Rule.RuleModule = {
continue
}

const { start, end } = position || /* istanbul ignore next */ {}

const message: RemarkLintMessage = {
reason,
source,
Expand All @@ -96,11 +98,11 @@ export const remark: Rule.RuleModule = {
line,
// ! eslint ast column is 0-indexed, but unified is 1-indexed
column: column - 1,
start: {
start: start && {
...start,
column: start.column - 1,
},
end: {
end: end && {
...end,
column: end.column - 1,
},
Expand Down

0 comments on commit ee3b593

Please sign in to comment.