eslint-plugin-mdx
Version:
ESLint Plugin for MDX
33 lines • 1.02 kB
JavaScript
import { getRuleConfig } from './helpers.js';
export const noMultipleToplevelHeadings = {
meta: {
type: 'problem',
docs: {
description: 'Disallow multiple top-level headings',
},
schema: [{ type: 'number' }],
},
create(context) {
const config = getRuleConfig(context, 'no-multiple-toplevel-headings');
if (!config) {
return {};
}
const rank = config.options || 1;
let seen = false;
return {
MDHeading(node) {
if (node.depth !== rank) {
return;
}
if (seen) {
context.report({
loc: node.loc,
message: `Unexpected duplicate toplevel heading, exected a single heading with rank \`${rank}\``,
});
}
seen = true;
},
};
},
};
//# sourceMappingURL=no-multiple-toplevel-headings.js.map