Skip to content

Commit a81d6f8

Browse files
Merge pull request #2462 from NullVoxPopuli/nvp/template-lint-extract-rule-template-block-indentation
Extract rule: template-block-indentation
2 parents 61f7b36 + 6db455b commit a81d6f8

4 files changed

Lines changed: 1174 additions & 10 deletions

File tree

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,17 @@ rules in templates can be disabled with eslint directives with mustache or html
381381

382382
### Stylistic Issues
383383

384-
| Name                          | Description | 💼 | 🔧 | 💡 |
385-
| :--------------------------------------------------------------------------- | :------------------------------------------------------------- | :- | :- | :- |
386-
| [order-in-components](docs/rules/order-in-components.md) | enforce proper order of properties in components | | 🔧 | |
387-
| [order-in-controllers](docs/rules/order-in-controllers.md) | enforce proper order of properties in controllers | | 🔧 | |
388-
| [order-in-models](docs/rules/order-in-models.md) | enforce proper order of properties in models | | 🔧 | |
389-
| [order-in-routes](docs/rules/order-in-routes.md) | enforce proper order of properties in routes | | 🔧 | |
390-
| [template-attribute-order](docs/rules/template-attribute-order.md) | enforce consistent ordering of attributes in template elements | | | |
391-
| [template-eol-last](docs/rules/template-eol-last.md) | require or disallow newline at the end of template files | | 🔧 | |
392-
| [template-linebreak-style](docs/rules/template-linebreak-style.md) | enforce consistent linebreaks in templates | | 🔧 | |
393-
| [template-no-only-default-slot](docs/rules/template-no-only-default-slot.md) | disallow using only the default slot | | 🔧 | |
384+
| Name                          | Description | 💼 | 🔧 | 💡 |
385+
| :--------------------------------------------------------------------------- | :--------------------------------------------------------------------- | :- | :- | :- |
386+
| [order-in-components](docs/rules/order-in-components.md) | enforce proper order of properties in components | | 🔧 | |
387+
| [order-in-controllers](docs/rules/order-in-controllers.md) | enforce proper order of properties in controllers | | 🔧 | |
388+
| [order-in-models](docs/rules/order-in-models.md) | enforce proper order of properties in models | | 🔧 | |
389+
| [order-in-routes](docs/rules/order-in-routes.md) | enforce proper order of properties in routes | | 🔧 | |
390+
| [template-attribute-order](docs/rules/template-attribute-order.md) | enforce consistent ordering of attributes in template elements | | | |
391+
| [template-block-indentation](docs/rules/template-block-indentation.md) | enforce consistent indentation for block statements and their children | | | |
392+
| [template-eol-last](docs/rules/template-eol-last.md) | require or disallow newline at the end of template files | | 🔧 | |
393+
| [template-linebreak-style](docs/rules/template-linebreak-style.md) | enforce consistent linebreaks in templates | | 🔧 | |
394+
| [template-no-only-default-slot](docs/rules/template-no-only-default-slot.md) | disallow using only the default slot | | 🔧 | |
394395

395396
### Testing
396397

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ember/template-block-indentation
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Migrated from [ember-template-lint/block-indentation](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/block-indentation.md).
6+
7+
## Rule Details
8+
9+
Forces valid indentation for blocks and their children.
10+
11+
1. Forces block begin and block end statements to be at the same indentation level, when not on one line.
12+
2. Forces children of all blocks to start at a single indentation level deeper.
13+
14+
## Configuration
15+
16+
<!-- begin auto-generated rule options list -->
17+
18+
| Name | Type |
19+
| :--------------- | :------ |
20+
| `ignoreComments` | Boolean |
21+
| `indentation` | Integer |
22+
23+
<!-- end auto-generated rule options list -->
24+
25+
## Examples
26+
27+
Examples of **incorrect** code for this rule:
28+
29+
```hbs
30+
{{#each foo as |bar|}}{{/each}}
31+
```
32+
33+
```hbs
34+
<div>
35+
<p>{{t 'greeting'}}</p>
36+
</div>
37+
```
38+
39+
```hbs
40+
<div>
41+
<p>{{t 'Stuff here!'}}</p></div>
42+
```
43+
44+
Examples of **correct** code for this rule:
45+
46+
```hbs
47+
{{#each foo as |bar|}}
48+
{{bar.name}}
49+
{{/each}}
50+
```
51+
52+
```hbs
53+
<div>
54+
<p>{{t 'greeting'}}</p>
55+
</div>
56+
```
57+
58+
## Options
59+
60+
- Integer (e.g., `2`, `4`): Number of spaces for indentation.
61+
- `"tab"`: Use tab-style indentation (1 character).
62+
- Object:
63+
- `indentation` (integer, default `2`): Number of spaces to indent.
64+
- `ignoreComments` (boolean, default `false`): Skip indentation checking for comments.
65+
66+
When no option is specified, the rule reads `indent_size` from .editorconfig (if present).
67+
If no .editorconfig is found, the default is `2` spaces.

0 commit comments

Comments
 (0)