UNPKG

eslint-plugin-mdx

Version:
31 lines • 994 B
import { ENABLED_OPTION_SCHEMA, getRuleConfig } from './helpers.js'; export const headingIncrement = { meta: { type: 'problem', docs: { description: 'Warn when heading ranks increment by more than one', }, schema: [ENABLED_OPTION_SCHEMA], }, create(context) { const config = getRuleConfig(context, 'heading-increment'); if (!config) { return {}; } let previous = 0; return { MDHeading(node) { const depth = node.depth; const expected = previous + 1; if (previous > 0 && depth > expected) { context.report({ loc: node.loc, message: `Unexpected heading rank \`${depth}\`, exected rank \`${expected}\``, }); } previous = depth; }, }; }, }; //# sourceMappingURL=heading-increment.js.map