|
| 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