You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

2 years ago
'use strict';
require('@babel/register');
const { rules } = require('./src');
const ruleTableRows = Object.keys(rules)
.sort()
.map((id) => {
const { meta } = rules[id];
const { url, errorOptions } = meta.docs;
return [
`[${id}](${url})`,
errorOptions ? 'error, with options' : 'error',
'error',
].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!');
},
};