-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-docs-index.ts
49 lines (43 loc) · 1.39 KB
/
update-docs-index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @fileoverview Update docs index script
* @author kazuya kawaguchi (a.k.a. kazupon)
* Forked by https://github.com/mysticatea/eslint-plugin-eslint-comments/tree/master/scripts/update-docs-index.js
*/
import { writeFileSync } from 'fs'
import { resolve } from 'path'
import type { RuleInfo } from './lib/rules.js'
import { withCategories } from './lib/rules.js'
function toTableRow(rule: RuleInfo) {
const mark = `${rule.recommended ? ':star:' : ''}${
rule.fixable ? ':black_nib:' : ''
}`
const link = `[@intlify/svelte/<wbr>${rule.name}](./${rule.name}.md)`
const description = rule.description || '(no description)'
return `| ${link} | ${description} | ${mark} |`
}
function toCategorySection({
category,
rules
}: {
category: string
rules: RuleInfo[]
}) {
return `## ${category}
<!--prettier-ignore-->
| Rule ID | Description | |
|:--------|:------------|:---|
${rules.map(toTableRow).join('\n')}
`
}
writeFileSync(
resolve(import.meta.dirname, '../docs/rules/README.md'),
`# Available Rules
- :star: mark: the rule which is enabled by the \`*.configs.["flat/recommended"]\` preset.
- :black_nib: mark: the rule which is fixable by \`eslint --fix\` command.
${withCategories
.filter(({ rules }) => rules.length)
.map(toCategorySection)
.join('\n')}
**If you have any ideas for new rules, please open an [issue](https://github.com/intlify/eslint-plugin-svelte/issues).**
`
)