markdown/table-column-count
Disallow data rows in a table from having more cells than the header row
The header row decides how many columns a table has. Extra cells are dropped when the table is rendered, so their content is silently lost.
Tables are part of GitHub Flavored Markdown, so the rule reports nothing in markdown/commonmark.
Configure#
Off by default. It needs an ESLint config that says which files are in the language:
eslint.config.js
import markdown from "@eslint/markdown";
export default [
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/gfm",
rules: { "markdown/table-column-count": "error" },
},
];It also works with markdown/commonmark.
Examples#
example.md1 problem
| Name | Port |
| ---- | ---- |
| api | 3000 | internal |Table column count mismatch (Expected: 2, Actual: 3), extra data starting here will be ignored.example.mdNo problems
| Name | Port |
| ---- | ---- |
| api | 3000 |
| web |Options#
| Option | Default | What it does |
|---|---|---|
checkMissingCells | false | Also report a row with fewer cells than the header row. |
example.mdwith
{ "checkMissingCells": true }1 problem| Name | Port |
| ---- | ---- |
| web |Table column count mismatch (Expected: 2, Actual: 1), row might be missing data.