-
-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy path.eslint-doc-generatorrc.js
More file actions
44 lines (36 loc) · 1.45 KB
/
.eslint-doc-generatorrc.js
File metadata and controls
44 lines (36 loc) · 1.45 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
const path = require('path');
const HBS_ONLY_NOTE =
'> **HBS Only**: This rule applies to classic `.hbs` template files only (loose mode). It is not relevant for `gjs`/`gts` files (strict mode), where these patterns cannot occur.';
const END_HEADER_MARKER = '<!-- end auto-generated rule header -->';
/** @type {import('eslint-doc-generator').GenerateOptions} */
module.exports = {
configEmoji: [
['recommended-gjs', ''],
['recommended-gts', ''],
['template-lint-migration', '📋'],
],
ruleDocSectionInclude: ['Examples'],
ruleDocTitleFormat: 'prefix-name',
ruleListSplit: 'meta.docs.category',
urlConfigs: 'https://github.com/ember-cli/eslint-plugin-ember#-configurations',
postprocess(content, filePath) {
// Only process rule doc files
if (!filePath.includes(path.join('docs', 'rules'))) {
return content;
}
const ruleName = path.basename(filePath, '.md');
let rule;
try {
rule = require(path.join(__dirname, 'lib', 'rules', ruleName));
} catch {
return content;
}
// Strip any existing HBS Only note (with surrounding blank lines)
let result = content.replace(/\n> \*\*HBS Only\*\*:[^\n]+\n/, '\n');
// Add HBS Only note for loose-mode rules
if (rule.meta?.docs?.templateMode === 'loose') {
result = result.replace(END_HEADER_MARKER, `${HBS_ONLY_NOTE}\n\n${END_HEADER_MARKER}`);
}
return result;
},
};