UNPKG

@alauda/doom

Version:

Doctor Doom making docs.

14 lines (13 loc) 565 B
import { lintRule } from 'unified-lint-rule'; import { visitParents } from 'unist-util-visit-parents'; const MAX_HEADING_DEPTH = 5; export const noDeepHeading = lintRule('doom-lint:no-deep-heading', (root, vfile) => { visitParents(root, 'heading', (heading, parents) => { if (heading.depth > MAX_HEADING_DEPTH) { vfile.message(`Unexpected deep heading level ${heading.depth}, maximum is ${MAX_HEADING_DEPTH}`, { ancestors: [...parents, heading], place: heading.position, }); } }); });