From 1a81c44a2dc9f4eff94e79f72cf7b7a82ae23de5 Mon Sep 17 00:00:00 2001 From: Ethan Shumate <13422990+EthanShoeDev@users.noreply.github.com> Date: Sun, 14 Jan 2024 00:09:22 -0500 Subject: [PATCH] fix: undefined place in vFile message causes TypeError (#521) Many remark-lint errors do not set a place variable in the vFile message. This code should accept undefined for this field. fixes #520 Co-authored-by: JounQin --- .changeset/new-brooms-visit.md | 10 ++++++++++ packages/eslint-plugin-mdx/src/rules/remark.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/new-brooms-visit.md diff --git a/.changeset/new-brooms-visit.md b/.changeset/new-brooms-visit.md new file mode 100644 index 00000000..65d49eb1 --- /dev/null +++ b/.changeset/new-brooms-visit.md @@ -0,0 +1,10 @@ +--- +"eslint-plugin-mdx": patch +--- + +fix: `undefined` `place` in vFile message causes TypeError + +Many `remark-lint` errors do not set a place variable in the vFile +message. This code should accept `undefined` for this field. + +fixes #520 diff --git a/packages/eslint-plugin-mdx/src/rules/remark.ts b/packages/eslint-plugin-mdx/src/rules/remark.ts index edc7d104..f1c85ec9 100644 --- a/packages/eslint-plugin-mdx/src/rules/remark.ts +++ b/packages/eslint-plugin-mdx/src/rules/remark.ts @@ -100,7 +100,7 @@ export const remark: Rule.RuleModule = { // related to https://github.com/eslint/eslint/issues/14198 message: JSON.stringify(message), loc: - /* istanbul ignore next */ 'start' in place + /* istanbul ignore next */ place && 'start' in place ? { ...point, start: { ...place.start, column: place.start.column - 1 },