Skip to content

Commit 901865f

Browse files
Merge pull request #2463 from ember-cli/nvp/update-docs-generator-to-handle-hbs-only-warnings
Update the docs-generator to handle the 'templateMode: loose' in rules from nvp/port-ember-template-lint-for-gjs-gts
2 parents a15aa2a + e9b3bf6 commit 901865f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.eslint-doc-generatorrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
const path = require('path');
2+
3+
const HBS_ONLY_NOTE =
4+
'> **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.';
5+
6+
const END_HEADER_MARKER = '<!-- end auto-generated rule header -->';
7+
18
/** @type {import('eslint-doc-generator').GenerateOptions} */
29
module.exports = {
310
configEmoji: [
@@ -8,4 +15,29 @@ module.exports = {
815
ruleDocTitleFormat: 'prefix-name',
916
ruleListSplit: 'meta.docs.category',
1017
urlConfigs: 'https://github.com/ember-cli/eslint-plugin-ember#-configurations',
18+
postprocess(content, filePath) {
19+
// Only process rule doc files
20+
if (!filePath.includes(path.join('docs', 'rules'))) {
21+
return content;
22+
}
23+
24+
const ruleName = path.basename(filePath, '.md');
25+
26+
let rule;
27+
try {
28+
rule = require(path.join(__dirname, 'lib', 'rules', ruleName));
29+
} catch {
30+
return content;
31+
}
32+
33+
// Strip any existing HBS Only note (with surrounding blank lines)
34+
let result = content.replace(/\n> \*\*HBS Only\*\*:[^\n]+\n/, '\n');
35+
36+
// Add HBS Only note for loose-mode rules
37+
if (rule.meta?.docs?.templateMode === 'loose') {
38+
result = result.replace(END_HEADER_MARKER, `${HBS_ONLY_NOTE}\n\n${END_HEADER_MARKER}`);
39+
}
40+
41+
return result;
42+
},
1143
};

0 commit comments

Comments
 (0)