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 |
example.mdNo problems
| Name | Port |
| ---- | ---- |
| api  | 3000 |
| web  |

Options#

OptionDefaultWhat it does
checkMissingCellsfalseAlso report a row with fewer cells than the header row.
example.mdwith { "checkMissingCells": true }1 problem
| Name | Port |
| ---- | ---- |
| web  |