Skip to content

Commit 5a4dc90

Browse files
authored
Increase width of rules table name column (#1204)
1 parent b1a5f53 commit 5a4dc90

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ Each rule has emojis denoting:
125125
<!-- Do not manually modify this table. Run: `npm run generate-rules-table` -->
126126
<!-- RULES_TABLE_START -->
127127

128-
| Name | Description || 🔧 |
129-
| :--- | :---------- | :------------------- | :--------------- |
128+
| Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Description || 🔧 |
129+
| :-- | :-- | :-- | :-- |
130130
| [better-regex](docs/rules/better-regex.md) | Improve regexes by making them shorter, consistent, and safer. || 🔧 |
131131
| [catch-error-name](docs/rules/catch-error-name.md) | Enforce a specific parameter name in catch clauses. || 🔧 |
132132
| [consistent-destructuring](docs/rules/consistent-destructuring.md) | Use destructured variables over properties. || 🔧 |

scripts/generate-rules-table.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const EMOJI_RECOMMENDED = '✅';
1919
const EMOJI_FIXABLE = '🔧';
2020

2121
// Generate rule table contents.
22-
const rulesTableContent = Object.keys(rules).filter(ruleName => !rules[ruleName].meta.deprecated)
23-
.sort()
22+
const ruleNames = Object.keys(rules).filter(ruleName => !rules[ruleName].meta.deprecated).sort();
23+
const rulesTableContent = ruleNames
2424
.map(ruleName => {
2525
// Check which emojis to show for this rule.
2626
const isRecommended = configs.recommended.rules[`unicorn/${ruleName}`] === 'error';
@@ -34,6 +34,7 @@ const rulesTableContent = Object.keys(rules).filter(ruleName => !rules[ruleName]
3434
return `| ${link} | ${description} | ${isRecommended ? EMOJI_RECOMMENDED : ''} | ${isFixable ? EMOJI_FIXABLE : ''} |`;
3535
})
3636
.join('\n');
37+
const spaces = '&nbsp;'.repeat(Math.max(...ruleNames.map(({length}) => length)) + 8);
3738

3839
writeFileSync(
3940
pathReadme,
@@ -42,8 +43,8 @@ writeFileSync(
4243
outdent`
4344
<!-- RULES_TABLE_START -->
4445
45-
| Name | Description | ${EMOJI_RECOMMENDED} | ${EMOJI_FIXABLE} |
46-
| :--- | :---------- | :------------------- | :--------------- |
46+
| Name${spaces} | Description | ${EMOJI_RECOMMENDED} | ${EMOJI_FIXABLE} |
47+
| :-- | :-- | :-- | :-- |
4748
${rulesTableContent}
4849
4950
<!-- RULES_TABLE_END -->

0 commit comments

Comments
 (0)