-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy path.eslint-doc-generatorrc.js
More file actions
84 lines (79 loc) · 2.69 KB
/
Copy path.eslint-doc-generatorrc.js
File metadata and controls
84 lines (79 loc) · 2.69 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import prettier from 'prettier';
import { rules as requireRules } from './lib/rules/require-properties.mjs';
import { rules as validRules } from './lib/rules/valid-properties.mjs';
const requireRuleNames = Object.keys(requireRules);
const validRuleNames = Object.keys(validRules);
/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
configEmoji: [
['recommended', '✅'],
['recommended-publishable', '📦'],
['stylistic', '🎨'],
],
framework: 'starlight',
pathRuleDoc(name) {
// Group the simple require-* and valid-* rules into their own sections.
if (requireRuleNames.includes(name)) {
return `site/src/content/docs/rules/require-properties/${name}.mdx`;
}
if (validRuleNames.includes(name)) {
return `site/src/content/docs/rules/valid-properties/${name}.mdx`;
}
return `site/src/content/docs/rules/${name}.mdx`;
},
pathRuleList: ['README.md', 'site/src/content/docs/rule-list.md'],
postprocess: async (content, path) => {
const parser = path.endsWith('.mdx') ? 'mdx' : 'markdown';
return prettier.format(content, {
...(await prettier.resolveConfig(path)),
parser,
});
},
ruleDocNotices: [
'configs',
'deprecated',
'fixableAndHasSuggestions',
'requiresTypeChecking',
],
ruleDocTitleFormat: 'name',
ruleListSplit(rules) {
return [
{
// No header for this list.
rules: rules.filter(
([name]) =>
!requireRuleNames.includes(name) && !validRuleNames.includes(name),
),
},
{
title: 'Require Properties',
rules: rules.filter(([name]) => requireRuleNames.includes(name)),
description:
'This group of rules allows you to require that the associated top-level property must be present in the `package.json`.',
},
{
title: 'Valid Properties',
rules: rules.filter(([name]) => validRuleNames.includes(name)),
description:
'This group of rules allows you to enforce that the value of the associated top-level property is valid. All of these rules are include in the `recommended` config.',
},
];
},
urlRuleDoc(name, page) {
// Group the simple require-* and valid-* rules into their own sections.
let rulePath = `rules/${name}`;
if (requireRuleNames.includes(name)) {
rulePath = `rules/require-properties/${name}`;
}
if (validRuleNames.includes(name)) {
rulePath = `rules/valid-properties/${name}`;
}
if (page === 'README.md') {
// Use URLs only in the readme.
return `https://eslint-plugin-package-json.dev/${rulePath}`;
} else {
return `/${rulePath}`;
}
},
};
export default config;