Skip to content

Commit ccce381

Browse files
authored
Merge pull request #152 from bmish/table-formatting
2 parents b3ea927 + 3e29965 commit ccce381

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

lib/rule-list.ts

+20-21
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getPluginRoot } from './package-json.js';
1212
import { generateLegend } from './legend.js';
1313
import { relative } from 'node:path';
1414
import { COLUMN_TYPE } from './types.js';
15+
import { markdownTable } from 'markdown-table';
1516
import type {
1617
Plugin,
1718
RuleDetails,
@@ -109,27 +110,25 @@ function generateRulesListMarkdown(
109110
: headerStrOrFn,
110111
];
111112
});
112-
const listSpacerRow = Array.from({ length: listHeaderRow.length }).fill(
113-
':--'
114-
); // Left-align header with colon.
115-
return [
116-
listHeaderRow,
117-
listSpacerRow,
118-
...details
119-
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
120-
.map((rule: RuleDetails) =>
121-
buildRuleRow(
122-
columns,
123-
rule,
124-
configsToRules,
125-
pluginPrefix,
126-
configEmojis,
127-
ignoreConfig
128-
)
129-
),
130-
]
131-
.map((column) => [...column, ' '].join('|'))
132-
.join('\n');
113+
114+
return markdownTable(
115+
[
116+
listHeaderRow,
117+
...details
118+
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
119+
.map((rule: RuleDetails) =>
120+
buildRuleRow(
121+
columns,
122+
rule,
123+
configsToRules,
124+
pluginPrefix,
125+
configEmojis,
126+
ignoreConfig
127+
)
128+
),
129+
],
130+
{ align: 'l' } // Left-align headers.
131+
);
133132
}
134133

135134
export async function updateRulesList(

package-lock.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@typescript-eslint/utils": "^5.38.1",
4747
"commander": "^9.4.0",
48+
"markdown-table": "^3.0.2",
4849
"type-fest": "^3.0.0"
4950
},
5051
"devDependencies": {

0 commit comments

Comments
 (0)