eslint-plugin-mdx
Version:
ESLint Plugin for MDX
35 lines • 1.12 kB
JavaScript
import { getRuleConfig } from './helpers.js';
export const ruleStyle = {
meta: {
type: 'layout',
docs: {
description: 'Enforce a consistent thematic rule style',
},
fixable: 'code',
schema: [{ type: 'string' }],
},
create(context) {
const config = getRuleConfig(context, 'rule-style');
if (!config) {
return {};
}
let expected = typeof config.options === 'string' && config.options !== 'consistent'
? config.options
: undefined;
return {
MDThematicBreak(node) {
const actual = node.raw;
expected ??= actual;
if (actual === expected) {
return;
}
context.report({
loc: node.loc,
message: `Unexpected thematic rule \`${actual}\`, expected \`${expected}\``,
fix: fixer => fixer.replaceTextRange(node.range, expected),
});
},
};
},
};
//# sourceMappingURL=rule-style.js.map