Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ npm-debug.log

# eslint-remote-tester
eslint-remote-tester-results

# Lock file generated by npm install (project uses pnpm)
package-lock.json
.tmp/
2,314 changes: 1,385 additions & 929 deletions CHANGELOG.md

Large diffs are not rendered by default.

213 changes: 141 additions & 72 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rules/no-array-prototype-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ arr.uniq();

## Related Rules

- [no-array-prototype-extensions](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-array-prototype-extensions.md) from ember-template-lint
- [template-no-array-prototype-extensions](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-array-prototype-extensions.md) from eslint-plugin-ember
- [no-function-prototype-extensions](no-function-prototype-extensions.md)
- [no-string-prototype-extensions](no-string-prototype-extensions.md)
4 changes: 2 additions & 2 deletions docs/rules/no-at-ember-render-modifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ import didUpdate from '@ember/render-modifiers/modifiers/did-update';
import willDestroy from '@ember/render-modifiers/modifiers/will-destroy';
```

For more examples, see [the docs on ember-template-lint](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-at-ember-render-modifiers.md).
For more examples, see [the docs on eslint-plugin-ember](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-at-ember-render-modifiers.md).

## References

- [Editions](https://emberjs.com/editions/)
- [Octane Upgrade Guide](https://guides.emberjs.com/release/upgrading/current-edition/)
- [Component Documentation](https://guides.emberjs.com/release/components/)
- [Avoiding Lifecycle in Component](https://nullvoxpopuli.com/avoiding-lifecycle)
- [The `ember-template-lint` version of this rule](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-at-ember-render-modifiers.md)
- [The `eslint-plugin-ember` version of this rule](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-at-ember-render-modifiers.md)
- [`ember-modifier`](https://github.com/ember-modifier/ember-modifier)
- [`@ember/render-modifiers`](https://github.com/emberjs/ember-render-modifiers) (deprecated)
2 changes: 1 addition & 1 deletion docs/rules/no-html-safe.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default helper(substring);

## Related Rules

- ember-template-lint has a [no-triple-curlies](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-triple-curlies.md) rule for the template equivalent of this rule.
- eslint-plugin-ember has a [template-no-triple-curlies](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-triple-curlies.md) rule for the template equivalent of this rule.

## References

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-restricted-service-injections.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ Accepts an array of the objects with the following options:
## Related Rules

- The [no-restricted-imports](https://eslint.org/docs/rules/no-restricted-imports) or [import/no-restricted-paths](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md) rules are the JavaScript import statement equivalent of this rule.
- ember-template-lint has a [no-restricted-invocations](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-restricted-invocations.md) rule for disallowing component usages.
- eslint-plugin-ember has a [template-no-restricted-invocations](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-restricted-invocations.md) rule for disallowing component usages.
47 changes: 27 additions & 20 deletions docs/rules/template-attribute-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,67 @@ Enforces a consistent ordering of attributes in template elements. This helps im

## Rule Details

This rule enforces a consistent order for attributes on template elements. By default, it follows this order:

1. `class`
2. `id`
3. `role`
4. `aria-*` attributes
5. `data-test-*` attributes
6. `type`
7. `name`
8. `value`
9. `placeholder`
10. `disabled`
This rule enforces a consistent order for attributes on template elements. By default, attributes are ordered by type group:

1. **Arguments** — `@argName` (Glimmer component arguments)
2. **Attributes** — standard HTML attributes like `class`, `id`, `role`
3. **Modifiers** — `{{on "click" ...}}`, `{{did-insert ...}}`, etc.

Within each group, attributes are sorted alphabetically by default.

Additional groups (`splattributes` and `comments`) can be added to the ordering if needed.

Hash pairs in curly invocations (mustache/block statements) are also alphabetized when `alphabetize` is enabled.

## Examples

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

```gjs
<template>
<div id="main" class="container"></div>
<MyComponent class="btn" @onClick={{this.go}} @label="hi" />
</template>
```

In this example, `class` (an attribute) appears before `@onClick` and `@label` (arguments). Arguments should come first.

```gjs
<template>
<button aria-label="Submit" role="button">Send</button>
<MyComponent @label="hi" @action={{this.go}} />
</template>
```

Here, `@label` and `@action` are out of alphabetical order within the arguments group.

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

```gjs
<template>
<div class="container" id="main"></div>
<MyComponent @action={{this.go}} @label="hi" class="btn" />
</template>
```

```gjs
<template>
<button class="btn" role="button" aria-label="Submit">Send</button>
<div class="container" id="main" {{on "click" this.handleClick}}></div>
</template>
```

## Configuration
## Options

You can customize the order by providing an `order` array:
| Name | Type | Default | Description |
| ------------- | ---------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `order` | `string[]` | `["arguments", "attributes", "modifiers"]` | The order of token type groups. Valid values: `"arguments"`, `"attributes"`, `"modifiers"`, `"splattributes"`, `"comments"`. |
| `alphabetize` | `boolean` | `true` | Whether to alphabetize attributes within each group. |

```js
module.exports = {
rules: {
'ember/template-attribute-order': [
'error',
{
order: ['class', 'id', 'role', 'aria-', 'type'],
order: ['arguments', 'attributes', 'modifiers'],
alphabetize: true,
},
],
},
Expand All @@ -70,4 +77,4 @@ module.exports = {

## References

- [ember-template-lint attribute-order](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/attribute-order.md)
- [eslint-plugin-ember template-attribute-order](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-attribute-order.md)
2 changes: 0 additions & 2 deletions docs/rules/template-block-indentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ember/template-block-indentation

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

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

Migrated from [ember-template-lint/block-indentation](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/block-indentation.md).
Expand Down
30 changes: 14 additions & 16 deletions docs/rules/template-builtin-component-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

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

✅ The `extends: 'recommended'` property in a configuration file enables this rule.

The builtin `Input` component has several arguments that match attributes
of the lower-case `input` HTML element. These arguments should be set via e.g.
`@type`, instead of `type`, but it is easy to forget and can cause subtle
Expand Down Expand Up @@ -32,34 +30,34 @@ other attributes or builtin components.

This rule **forbids** the following:

```hbs
<Input type='text' size='10' />
```gjs
<template><Input type='text' size='10' /></template>
```

```hbs
<Input @type='checkbox' checked />
```gjs
<template><Input @type='checkbox' checked /></template>
```

```hbs
<Textarea value="Hello, Tom!" /></Textarea>
```gjs
<template><Textarea value="Hello, Tom!" /></Textarea></template>
```

This rule **allows** the following:

```hbs
<input type='text' size='10' />
```gjs
<template><input type='text' size='10' /></template>
```

```hbs
<Input @type='text' size='10' />
```gjs
<template><Input @type='text' size='10' /></template>
```

```hbs
<Input @type='checkbox' @checked={{true}} />
```gjs
<template><Input @type='checkbox' @checked={{true}} /></template>
```

```hbs
<Textarea @value="Hello, Tom!" /></Textarea>
```gjs
<template><Textarea @value="Hello, Tom!" /></Textarea></template>
```

## Migration
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/template-deprecated-inline-view-helper.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ember/template-deprecated-inline-view-helper

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

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

<!-- end auto-generated rule header -->
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/template-deprecated-render-helper.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ember/template-deprecated-render-helper

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

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

<!-- end auto-generated rule header -->
Expand Down
1 change: 0 additions & 1 deletion docs/rules/template-eol-last.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ This rule enforces at least one newline (or no newline) at the end of template f
This rule accepts a single string option:

- `"always"` (default) — enforces that template files end with a newline
- `"editorconfig"` — requires or disallows a final newline based on the project's `.editorconfig` settings (via `insert_final_newline`); throws if `insert_final_newline` is not set
- `"never"` — enforces that template files do not end with a newline

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/template-link-href-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ Examples of **correct** code for this rule:

- [MDN: The Anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
- [WebAIM: Links and Hypertext](https://webaim.org/techniques/hypertext/)
- [ember-template-lint link-href-attributes](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/link-href-attributes.md)
- [eslint-plugin-ember template-link-href-attributes](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-link-href-attributes.md)
8 changes: 4 additions & 4 deletions docs/rules/template-link-rel-noopener.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ thread in the opener. Also note that Firefox versions prior 52 do not implement

This rule **forbids** the following:

```hbs
<a href='https://i.seem.secure.com' target='_blank'>I'm a bait</a>
```gjs
<template><a href='https://i.seem.secure.com' target='_blank'>I'm a bait</a></template>
```

This rule **allows** the following:

```hbs
<a href='https://i.seem.secure.com' target='_blank' rel='noopener noreferrer'>I'm a bait</a>
```gjs
<template><a href='https://i.seem.secure.com' target='_blank' rel='noopener noreferrer'>I'm a bait</a></template>
```

## References
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/template-modifier-name-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

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

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

Requires dasherized names for modifiers.
Expand Down
8 changes: 4 additions & 4 deletions docs/rules/template-no-abstract-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ The HTML attribute `role` must never have the following values:

This rule **forbids** the following:

```hbs
<div role='window'> Hello, world! </div>
```gjs
<template><div role='window'> Hello, world! </div></template>
```

This rule **allows** the following:

```hbs
<div role='button'> Push it </div>
```gjs
<template><div role='button'> Push it </div></template>
```

## References
Expand Down
57 changes: 31 additions & 26 deletions docs/rules/template-no-action-modifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->
> **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.

💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
<!-- end auto-generated rule header -->

Disallow usage of `{{action}}` modifiers in templates.

Expand All @@ -18,42 +18,47 @@ This rule disallows using `{{action}}` as an element modifier.

### Incorrect ❌

```gjs
<template>
<button {{action "save"}}>Save</button>
</template>
```hbs
<button {{action 'save'}}>Save</button>
```

```gjs
<template>
<div {{action "onClick"}}>Click me</div>
</template>
```hbs
<div {{action 'onClick'}}>Click me</div>
```

```gjs
<template>
<form {{action "submit" on="submit"}}>Submit</form>
</template>
```hbs
<form {{action 'submit' on='submit'}}>Submit</form>
```

### Correct ✅

```gjs
<template>
<button {{on "click" this.handleClick}}>Save</button>
</template>
```hbs
<button {{on 'click' this.handleClick}}>Save</button>
```

```hbs
<div {{on 'click' this.onClick}}>Click me</div>
```

```gjs
<template>
<div {{on "click" this.onClick}}>Click me</div>
</template>
```hbs
<form {{on 'submit' this.handleSubmit}}>Submit</form>
```

```gjs
<template>
<form {{on "submit" this.handleSubmit}}>Submit</form>
</template>
## Configuration

The following values are valid configuration:

- boolean -- `true` for enabled / `false` for disabled
- array -- an allowlist of element tag names, which will accept action modifiers

For example, to allow action modifiers only on specific elements:

```js
module.exports = {
rules: {
'ember/template-no-action-modifiers': ['error', { allowlist: ['form'] }],
},
};
```

## Options
Expand Down
Loading
Loading