UNPKG

eslint-plugin-mdx

Version:
48 lines • 1.59 kB
import { ENABLED_OPTION_SCHEMA, getRuleConfig } from './helpers.js'; export const noConsecutiveBlankLines = { meta: { type: 'layout', docs: { description: 'Disallow consecutive blank lines', }, schema: [ENABLED_OPTION_SCHEMA], }, create(context) { const config = getRuleConfig(context, 'no-consecutive-blank-lines'); if (!config) { return {}; } const check = (children) => { let previousLoc; for (const current of children) { const currentLoc = current.loc; const difference = previousLoc ? currentLoc.start.line - previousLoc.end.line - 2 : 0; if (difference > 0) { const actual = difference + 1; context.report({ loc: currentLoc, message: `Unexpected \`${actual}\` blank lines before node, expected up to \`1\` blank line, remove \`${difference}\` blank line`, }); } previousLoc = currentLoc; } }; return { Program(node) { check(node.body); }, MDBlockquote(node) { check(node.children); }, MDList(node) { check(node.children); }, MDListItem(node) { check(node.children); }, }; }, }; //# sourceMappingURL=no-consecutive-blank-lines.js.map