markdown.config.js
1.38 KB
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
50
51
52
53
54
55
56
57
58
59
'use strict';
require('@babel/register');
const {
configs: {
recommended: { rules: recommended },
strict: { rules: strict },
},
rules,
} = require('./src');
const ruleTableRows = Object.keys(rules)
.sort()
.map((id) => {
const { meta } = rules[id];
const { url, errorOptions } = meta.docs;
const recSev = [].concat(recommended[`jsx-a11y/${id}`] || 'off')[0];
const strictSev = [].concat(strict[`jsx-a11y/${id}`] || 'off')[0];
return [
`[${id}](${url})`,
recSev === 'error' ? (errorOptions ? 'error, with options' : 'error') : recSev, // eslint-disable-line no-nested-ternary
strictSev,
].join(' | ');
});
const buildRulesTable = (rows) => {
const header = 'Rule | Recommended | Strict';
const separator = ':--- | :--- | :---';
return [header, separator].concat(rows)
.map((row) => `| ${row} |`)
.join('\n');
};
const ruleList = Object.keys(rules)
.sort()
.map((id) => {
const { meta } = rules[id];
const { description, url } = meta.docs;
return description ? [`- [${id}](${url}): ${description}`] : null;
});
const buildRuleList = (listItems) => listItems.join('\n');
const LIST = () => buildRuleList(ruleList);
const TABLE = () => buildRulesTable(ruleTableRows);
module.exports = {
transforms: {
TABLE,
LIST,
},
callback: () => {
console.log('The auto-generating of rules finished!');
},
};