UNPKG

eslint-plugin-mdx

Version:
45 lines • 1.7 kB
import { ENABLED_OPTION_SCHEMA, getRuleConfig } from './helpers.js'; export const noHeadingContentIndent = { meta: { type: 'layout', docs: { description: 'Enforce one space between heading markers and content', }, fixable: 'code', schema: [ENABLED_OPTION_SCHEMA], }, create(context) { const config = getRuleConfig(context, 'no-heading-content-indent'); if (!config) { return {}; } return { MDHeading(node) { const spaceMatch = /^(#+)([ \t]+)/u.exec(node.raw); if (!spaceMatch) { return; } const size = spaceMatch[2].length; if (size <= 1) { return; } const start = node.range[0] + spaceMatch[1].length; context.report({ loc: { start: { line: node.loc.start.line, column: node.loc.start.column + start - node.range[0], }, end: { line: node.loc.start.line, column: node.loc.start.column + start - node.range[0] + size, }, }, message: `Unexpected \`${size}\` spaces between hashes and content, expected \`1\` space, remove \`${size - 1}\` spaces`, fix: fixer => fixer.replaceTextRange([start, start + size], ' '), }); }, }; }, }; //# sourceMappingURL=no-heading-content-indent.js.map