|
| 1 | +# ember/template-attribute-indentation |
| 2 | + |
| 3 | +<!-- end auto-generated rule header --> |
| 4 | + |
| 5 | +Migrated from [ember-template-lint/attribute-indentation](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/attribute-indentation.md). |
| 6 | + |
| 7 | +## Rule Details |
| 8 | + |
| 9 | +This rule requires the positional params, attributes, and block params of helpers/components to be indented by moving them to multiple lines when the open invocation has more than 80 characters (configurable). |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +<!-- begin auto-generated rule options list --> |
| 14 | + |
| 15 | +| Name | Type | Choices | |
| 16 | +| :------------------------ | :------ | :--------------------------- | |
| 17 | +| `as-indentation` | | `attribute`, `closing-brace` | |
| 18 | +| `element-open-end` | | `new-line`, `last-attribute` | |
| 19 | +| `indentation` | Integer | | |
| 20 | +| `mustache-open-end` | | `new-line`, `last-attribute` | |
| 21 | +| `open-invocation-max-len` | Integer | | |
| 22 | +| `process-elements` | Boolean | | |
| 23 | + |
| 24 | +<!-- end auto-generated rule options list --> |
| 25 | + |
| 26 | +## Examples |
| 27 | + |
| 28 | +Examples of **incorrect** code for this rule: |
| 29 | + |
| 30 | +Non-block form (> 80 characters): |
| 31 | + |
| 32 | +```hbs |
| 33 | +{{employee-details firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl}} |
| 34 | +``` |
| 35 | + |
| 36 | +Block form (> 80 characters): |
| 37 | + |
| 38 | +```hbs |
| 39 | +{{#employee-details |
| 40 | + firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl |
| 41 | + as |employee| |
| 42 | +}} |
| 43 | + {{employee.fullName}} |
| 44 | +{{/employee-details}} |
| 45 | +``` |
| 46 | + |
| 47 | +HTML element (> 80 characters): |
| 48 | + |
| 49 | +```hbs |
| 50 | +<input disabled id='firstName' value={{firstName}} class='input-field first-name' type='text' /> |
| 51 | +``` |
| 52 | + |
| 53 | +Examples of **correct** code for this rule: |
| 54 | + |
| 55 | +Non-block form (attributes on separate lines): |
| 56 | + |
| 57 | +```hbs |
| 58 | +{{employee-details firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl}} |
| 59 | +``` |
| 60 | + |
| 61 | +Block form (attributes on separate lines): |
| 62 | + |
| 63 | +```hbs |
| 64 | +{{#employee-details |
| 65 | + firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl |
| 66 | + as |employee| |
| 67 | +}} |
| 68 | + {{employee.fullName}} |
| 69 | +{{/employee-details}} |
| 70 | +``` |
| 71 | + |
| 72 | +HTML element (attributes on separate lines): |
| 73 | + |
| 74 | +```hbs |
| 75 | +<input disabled id='firstName' value={{firstName}} class='input-field first-name' type='text' /> |
| 76 | +``` |
| 77 | + |
| 78 | +Short invocations (< 80 characters) are allowed on a single line: |
| 79 | + |
| 80 | +```hbs |
| 81 | +{{employee-details firstName=firstName lastName=lastName}} |
| 82 | +``` |
| 83 | + |
| 84 | +## Options |
| 85 | + |
| 86 | +- `open-invocation-max-len` (integer, default `80`): Maximum length of the opening invocation before attributes must be on separate lines. |
| 87 | +- `indentation` (integer, default `2`): Number of spaces for attribute indentation. |
| 88 | +- `process-elements` (boolean, default `true`): Also validate indentation of HTML/SVG element attributes. |
| 89 | +- `element-open-end` (`"new-line"` | `"last-attribute"`, default `"new-line"`): Position of the closing `>` bracket. |
| 90 | +- `mustache-open-end` (`"new-line"` | `"last-attribute"`, default `"new-line"`): Position of the closing `}}` braces. |
| 91 | +- `as-indentation` (`"attribute"` | `"closing-brace"`, default `"closing-brace"`): Position of `as |param|` block params relative to attributes or closing brace. |
0 commit comments