Skip to content

Commit

Permalink
Merge pull request #152 from bmish/table-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Oct 21, 2022
2 parents b3ea927 + 3e29965 commit ccce381
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
41 changes: 20 additions & 21 deletions lib/rule-list.ts
Expand Up @@ -12,6 +12,7 @@ import { getPluginRoot } from './package-json.js';
import { generateLegend } from './legend.js';
import { relative } from 'node:path';
import { COLUMN_TYPE } from './types.js';
import { markdownTable } from 'markdown-table';
import type {
Plugin,
RuleDetails,
Expand Down Expand Up @@ -109,27 +110,25 @@ function generateRulesListMarkdown(
: headerStrOrFn,
];
});
const listSpacerRow = Array.from({ length: listHeaderRow.length }).fill(
':--'
); // Left-align header with colon.
return [
listHeaderRow,
listSpacerRow,
...details
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
.map((rule: RuleDetails) =>
buildRuleRow(
columns,
rule,
configsToRules,
pluginPrefix,
configEmojis,
ignoreConfig
)
),
]
.map((column) => [...column, ' '].join('|'))
.join('\n');

return markdownTable(
[
listHeaderRow,
...details
.sort(({ name: a }, { name: b }) => a.localeCompare(b))
.map((rule: RuleDetails) =>
buildRuleRow(
columns,
rule,
configsToRules,
pluginPrefix,
configEmojis,
ignoreConfig
)
),
],
{ align: 'l' } // Left-align headers.
);
}

export async function updateRulesList(
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@typescript-eslint/utils": "^5.38.1",
"commander": "^9.4.0",
"markdown-table": "^3.0.2",
"type-fest": "^3.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit ccce381

Please sign in to comment.