Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,18 @@ rules in templates can be disabled with eslint directives with mustache or html

### Stylistic Issues

| Name                          | Description | 💼 | 🔧 | 💡 |
| :--------------------------------------------------------------------------- | :--------------------------------------------------------------------- | :- | :- | :- |
| [order-in-components](docs/rules/order-in-components.md) | enforce proper order of properties in components | | 🔧 | |
| [order-in-controllers](docs/rules/order-in-controllers.md) | enforce proper order of properties in controllers | | 🔧 | |
| [order-in-models](docs/rules/order-in-models.md) | enforce proper order of properties in models | | 🔧 | |
| [order-in-routes](docs/rules/order-in-routes.md) | enforce proper order of properties in routes | | 🔧 | |
| [template-attribute-order](docs/rules/template-attribute-order.md) | enforce consistent ordering of attributes in template elements | | | |
| [template-block-indentation](docs/rules/template-block-indentation.md) | enforce consistent indentation for block statements and their children | | | |
| [template-eol-last](docs/rules/template-eol-last.md) | require or disallow newline at the end of template files | | 🔧 | |
| [template-linebreak-style](docs/rules/template-linebreak-style.md) | enforce consistent linebreaks in templates | | 🔧 | |
| [template-no-only-default-slot](docs/rules/template-no-only-default-slot.md) | disallow using only the default slot | | 🔧 | |
| Name                           | Description | 💼 | 🔧 | 💡 |
| :----------------------------------------------------------------------------- | :----------------------------------------------------------------------------- | :- | :- | :- |
| [order-in-components](docs/rules/order-in-components.md) | enforce proper order of properties in components | | 🔧 | |
| [order-in-controllers](docs/rules/order-in-controllers.md) | enforce proper order of properties in controllers | | 🔧 | |
| [order-in-models](docs/rules/order-in-models.md) | enforce proper order of properties in models | | 🔧 | |
| [order-in-routes](docs/rules/order-in-routes.md) | enforce proper order of properties in routes | | 🔧 | |
| [template-attribute-indentation](docs/rules/template-attribute-indentation.md) | enforce proper indentation of attributes and arguments in multi-line templates | | | |
| [template-attribute-order](docs/rules/template-attribute-order.md) | enforce consistent ordering of attributes in template elements | | | |
| [template-block-indentation](docs/rules/template-block-indentation.md) | enforce consistent indentation for block statements and their children | | | |
| [template-eol-last](docs/rules/template-eol-last.md) | require or disallow newline at the end of template files | | 🔧 | |
| [template-linebreak-style](docs/rules/template-linebreak-style.md) | enforce consistent linebreaks in templates | | 🔧 | |
| [template-no-only-default-slot](docs/rules/template-no-only-default-slot.md) | disallow using only the default slot | | 🔧 | |

### Testing

Expand Down
91 changes: 91 additions & 0 deletions docs/rules/template-attribute-indentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ember/template-attribute-indentation

<!-- end auto-generated rule header -->

Migrated from [ember-template-lint/attribute-indentation](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/attribute-indentation.md).

## Rule Details

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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hbs only since this is the kind of stylistic thing that should be prettier for template tags?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be a stylisstic rule, yes (never in the recommended config), but not everyone uses prettier, so I imagine once all of #2371 is merged, we make sure this rule works with gjs


## Configuration

<!-- begin auto-generated rule options list -->

| Name | Type | Choices |
| :------------------------ | :------ | :--------------------------- |
| `as-indentation` | | `attribute`, `closing-brace` |
| `element-open-end` | | `new-line`, `last-attribute` |
| `indentation` | Integer | |
| `mustache-open-end` | | `new-line`, `last-attribute` |
| `open-invocation-max-len` | Integer | |
| `process-elements` | Boolean | |

<!-- end auto-generated rule options list -->

## Examples

Examples of **incorrect** code for this rule:

Non-block form (> 80 characters):

```hbs
{{employee-details firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be updated to angle bracket invocation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a different PR perhaps -- these are copying from ember-template-lint.

I'd rather get everything ported over from #2371, and then do full modernization passes, rather than doing the same small loop on repeat

```

Block form (> 80 characters):

```hbs
{{#employee-details
firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl
as |employee|
}}
{{employee.fullName}}
{{/employee-details}}
```

HTML element (> 80 characters):

```hbs
<input disabled id='firstName' value={{firstName}} class='input-field first-name' type='text' />
```

Examples of **correct** code for this rule:

Non-block form (attributes on separate lines):

```hbs
{{employee-details firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl}}
```

Block form (attributes on separate lines):

```hbs
{{#employee-details
firstName=firstName lastName=lastName age=age avatarUrl=avatarUrl
as |employee|
}}
{{employee.fullName}}
{{/employee-details}}
```

HTML element (attributes on separate lines):

```hbs
<input disabled id='firstName' value={{firstName}} class='input-field first-name' type='text' />
```

Short invocations (< 80 characters) are allowed on a single line:

```hbs
{{employee-details firstName=firstName lastName=lastName}}
```

## Options

- `open-invocation-max-len` (integer, default `80`): Maximum length of the opening invocation before attributes must be on separate lines.
- `indentation` (integer, default `2`): Number of spaces for attribute indentation.
- `process-elements` (boolean, default `true`): Also validate indentation of HTML/SVG element attributes.
- `element-open-end` (`"new-line"` | `"last-attribute"`, default `"new-line"`): Position of the closing `>` bracket.
- `mustache-open-end` (`"new-line"` | `"last-attribute"`, default `"new-line"`): Position of the closing `}}` braces.
- `as-indentation` (`"attribute"` | `"closing-brace"`, default `"closing-brace"`): Position of `as |param|` block params relative to attributes or closing brace.
Loading
Loading