UNPKG

eslint-plugin-mdx

Version:
33 lines • 1.24 kB
import { getRuleConfig } from './helpers.js'; export const tableCellPadding = { meta: { type: 'layout', docs: { description: 'Enforce table cell padding' }, schema: [{ enum: ['compact', 'consistent', 'padded'], type: 'string' }], }, create(context) { const config = getRuleConfig(context, 'table-cell-padding'); if (!config) { return {}; } return { MDTable(node) { let expected = config.options === 'padded' || config.options === 'compact' ? config.options : undefined; for (const row of node.children) { const raw = row.raw; const padded = /^\|\s/u.test(raw) && /\s\|$/u.test(raw); expected ??= padded ? 'padded' : 'compact'; if ((expected === 'padded') !== padded) { context.report({ loc: row.loc, message: `Unexpected table cell padding, expected ${expected} cells`, }); } } }, }; }, }; //# sourceMappingURL=table-cell-padding.js.map