Skip to content

Commit

Permalink
no-consecutive-blank-lines: fix for mdx jsx
Browse files Browse the repository at this point in the history
Closes GH-257.
  • Loading branch information
wooorm committed Sep 23, 2021
1 parent da865d0 commit 0b78a7e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/remark-lint-no-consecutive-blank-lines/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import {visit} from 'unist-util-visit'
import {pointStart, pointEnd} from 'unist-util-position'
import {generated} from 'unist-util-generated'

const unknownContainerSize = new Set(['mdxJsxFlowElement', 'mdxJsxTextElement'])

const remarkLintNoConsecutiveBlankLines = lintRule(
{
origin: 'remark-lint:no-consecutive-blank-lines',
Expand All @@ -67,8 +69,10 @@ const remarkLintNoConsecutiveBlankLines = lintRule(
const head = node.children[0]

if (head && !generated(head)) {
// Compare parent and first child.
compare(pointStart(node), pointStart(head), 0)
if (!unknownContainerSize.has(node.type)) {
// Compare parent and first child.
compare(pointStart(node), pointStart(head), 0)
}

// Compare between each child.
let index = -1
Expand All @@ -85,7 +89,11 @@ const remarkLintNoConsecutiveBlankLines = lintRule(
const tail = node.children[node.children.length - 1]

// Compare parent and last child.
if (tail !== head && !generated(tail)) {
if (
tail !== head &&
!generated(tail) &&
!unknownContainerSize.has(node.type)
) {
compare(pointEnd(node), pointEnd(tail), 1)
}
}
Expand Down

0 comments on commit 0b78a7e

Please sign in to comment.