Skip to content

Commit a4afa6b

Browse files
committed
Declare when rules are HBS only
1 parent 2cc0e36 commit a4afa6b

23 files changed

Lines changed: 76 additions & 44 deletions

.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
};

docs/rules/template-deprecated-inline-view-helper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-deprecated-inline-view-helper
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
In Ember 1.12, support for invoking the inline View helper was deprecated.
88

99
## Rule Details

docs/rules/template-deprecated-render-helper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-deprecated-render-helper
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallows the {{render}} helper which is deprecated.
88

99
## Examples

docs/rules/template-no-action-modifiers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-action-modifiers
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallow usage of `{{action}}` modifiers in templates.
88

99
The `{{action}}` modifier has been deprecated in favor of the `{{on}}` modifier. The `{{on}}` modifier provides a more explicit and flexible way to handle events.

docs/rules/template-no-action.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-action
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallows the use of `{{action}}` helper.
88

99
"Action" is an overloaded term in Ember. Actions are methods on the `actions` hash, element modifiers that set up event handlers, partial-applied functions, and something we both pass downward and send back up. They have served many different purposes over the years, which makes them difficult to learn, teach, and repurpose.

docs/rules/template-no-ambiguous-glimmer-paths.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-ambiguous-glimmer-paths
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallow ambiguous path in templates
88

99
## Rule Details

docs/rules/template-no-attrs-in-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-attrs-in-components
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
This rule prevents the usage of `this.attrs` property to access values passed to the component. Use `@arg` syntax instead.
88

99
## Examples

docs/rules/template-no-class-bindings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-class-bindings
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallow passing `classBinding` or `classNameBindings` as arguments within templates. These are legacy Ember Classic patterns that should be replaced with modern approaches.
88

99
## Examples

docs/rules/template-no-curly-component-invocation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-curly-component-invocation
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallows curly component invocation syntax. Use angle bracket syntax instead.
88

99
There are two ways to invoke a component in a template: curly component syntax

docs/rules/template-no-extra-mut-helper-argument.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ember/template-no-extra-mut-helper-argument
22

3-
<!-- end auto-generated rule header -->
4-
53
> **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.
64
5+
<!-- end auto-generated rule header -->
6+
77
Disallows passing more than one argument to the `mut` helper.
88

99
A common mistake when using the Ember handlebars template `mut(attr)` helper is to pass an extra `value` parameter to it when only `attr` should be passed. Instead, the `value` should be passed outside of `mut`.

0 commit comments

Comments
 (0)