Skip to content

Commit d2a7a86

Browse files
committed
docs: improve organization, formatting, and consistency for rule docs.
1 parent 80095e9 commit d2a7a86

40 files changed

+140
-109
lines changed

docs/rule/attribute-indentation.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This rule requires the positional params, attributes and block params of the helper/component to be indented by moving them to multiple lines when the open invocation has more than 80 characters (configurable).
44

5-
#### Forbidden:
5+
### Forbidden
66

77
Non-Block form
88
``` hbs
@@ -30,7 +30,7 @@ Block form (HTML)
3030
<a href="https://www.emberjs.com" class="emberjs-home link" rel="noopener" target="_blank">Ember JS</a>
3131
```
3232

33-
#### Allowed:
33+
### Allowed
3434

3535
Non-Block form
3636
``` hbs
@@ -117,10 +117,14 @@ Block form (HTML)
117117
</a>
118118
```
119119

120-
#### Configuration:
120+
### Configuration
121121
* boolean - `true` - Enables the rule to be enforced when the opening invocation has more than 80 characters or when it spans multiple lines.
122122
* object - { 'indentation': n spaces } - Indentation length for attributes (defaults to `2`).
123123
* object - { 'open-invocation-max-len': n characters } - Maximum length of the opening invocation.
124124
* object - { 'process-elements': `true` } - Also validate the indentation of HTML/SVG elements.
125125
* object - { 'element-open-end': `new-line`|`last-attribute` } - Enforce the position of the closing brace `>` to be on a new line or next to the last attribute (defaults to `new-line`).
126126
* object - { 'mustache-open-end': `new-line`|`last-attribute` } - Enforce the position of the closing braces `}}` to be on a new line or next to the last attribute (defaults to `new-line`).
127+
128+
### Related Rules
129+
130+
* [attribute-indentation](attribute-indentation.md)

docs/rule/block-indentation.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Good indentation is crucial for long term maintenance of templates. For example, having blocks misaligned is a common cause of logic errors...
44

5-
This rule forbids the following examples:
5+
This rule **forbids** the following:
66

77
``` hbs
88
{{#each foo as |bar}}
@@ -19,8 +19,14 @@ This rule forbids the following examples:
1919
<p>{{t 'Stuff here!'}}</p></div>
2020
```
2121

22+
### Configuration
23+
2224
The following values are valid configuration:
2325

2426
* boolean -- `true` indicates a 2 space indent, `false` indicates that the rule is disabled.
2527
* numeric -- the number of spaces to require for indentation
2628
* "tab" -- To indicate tab style indentation (1 char)
29+
30+
### Related Rules
31+
32+
* [block-indentation](block-indentation.md)

docs/rule/deprecations/deprecated-each-syntax.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
In Ember 2.0, support for using the `in` form of the `{{#each}}` helper
44
has been removed.
55

6-
For example, this rule forbids the following:
6+
This rule **forbids** the following:
77

88
```hbs
99
{{#each post in posts}}
1010
<li>{{post.name}}</li>
1111
{{/each}}
1212
```
1313

14-
Instead, you should write the template as:
14+
This rule **allows** the following:
1515

1616
```hbs
1717
{{#each posts as |post|}}
1818
<li>{{post.name}}</li>
1919
{{/each}}
2020
```
2121

22-
More information is available at the [Deprecation Guide](http://emberjs.com/deprecations/v1.x/#toc_code-in-code-syntax-for-code-each-code).
22+
### References
23+
24+
* More information is available at the [Deprecation Guide](http://emberjs.com/deprecations/v1.x/#toc_code-in-code-syntax-for-code-each-code).

docs/rule/deprecations/deprecated-inline-view-helper.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In Ember 1.12, support for invoking the inline View helper was deprecated.
44

5-
For example, this rule forbids the following:
5+
This rule **forbids** the following:
66

77
```hbs
88
{{view 'this-is-bad'}}
@@ -16,7 +16,7 @@ For example, this rule forbids the following:
1616
<div foo={{view.bar}}></div>
1717
```
1818

19-
Instead, you should use:
19+
This rule **allows** the following:
2020

2121
```hbs
2222
{{this-is-better}}
@@ -28,4 +28,6 @@ Instead, you should use:
2828
<div foo={{bar}}></div>
2929
```
3030

31-
More information is available at the [Deprecation Guide](http://emberjs.com/deprecations/v1.x/#toc_ember-view).
31+
### References
32+
33+
* More information is available at the [Deprecation Guide](http://emberjs.com/deprecations/v1.x/#toc_ember-view).

docs/rule/deprecations/deprecated-render-helper.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
In Ember 2.6 and newer, support for using the `{{render}}` helper has been deprecated.
44

5-
For example, this rule forbids the following:
5+
This rule **forbids** the following:
66

77
```hbs
88
{{render 'this-is-bad'}}
99
1010
{{render 'also-bad' model}}
1111
```
1212

13-
Instead, you should use:
13+
This rule **allows** the following:
1414

1515
```hbs
1616
{{this-is-better}}
1717
1818
{{saul-goodman model=model}}
1919
```
2020

21-
More information is available at the [Deprecation Guide](https://emberjs.com/deprecations/v2.x/#toc_code-render-code-helper).
21+
### References
22+
23+
* More information is available at the [Deprecation Guide](https://emberjs.com/deprecations/v2.x/#toc_code-render-code-helper).

docs/rule/eol-last.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#### eol-last
1+
## eol-last
22

3-
Require or disallow newline at the end of files. Similar to https://eslint.org/docs/rules/eol-last.
3+
Require or disallow newline at the end of files.
44

55
Enforce either:
66

@@ -15,6 +15,12 @@ or:
1515
1616
```
1717

18+
### Configuration
19+
1820
The following values are valid configuration:
1921

2022
* string -- "always" enforces that files end with a newline, "never" enforces that files do not end with a newline
23+
24+
### Related Rules
25+
26+
* [eol-last](https://eslint.org/docs/rules/eol-last) from eslint

docs/rule/img-alt-attributes.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ An `<img>` without an `alt` attribute is essentially invisible to assistive tech
44
In order to ensure that screen readers can provide useful information, we need to ensure that all `<img>` elements
55
have an `alt` specified. See [WCAG Suggestion H37](https://www.w3.org/TR/WCAG20-TECHS/H37.html).
66

7-
The rule forbids the following:
7+
This rule **forbids** the following:
88

99
```hbs
1010
<img src="rwjblue.png">
1111
```
1212

13-
Instead, you should write the template as:
13+
This rule **allows** the following:
1414

1515
```hbs
1616
<img src="rwjblue.png" alt="picture of Robert Jackson">
1717
```
18-
19-
The following values are valid configuration:
20-
21-
* boolean -- `true` for enabled / `false` for disabled

docs/rule/inline-link-to.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Ember's `link-to` component has both an inline form and a block form. This rule forbids the inline form.
44

5-
Forbidden (inline form):
5+
This rule **forbids** the following (inline form):
66

77
```hbs
88
{{link-to 'Link text' 'routeName' prop1 prop2}}
99
```
1010

11-
Allowed (block form):
11+
This rule **allows** the following (block form):
1212

1313
```hbs
1414
{{#link-to 'routeName' prop1 prop2}}Link text{{/link-to}}
@@ -19,7 +19,3 @@ The block form is a little longer but has advantages over the inline form:
1919
* It maps closer to the use of HTML anchor tags which wrap their inner content.
2020
* It provides an obvious way for developers to put nested markup and components inside of their link.
2121
* The block form's argument order is more direct: "link to route". The inline form's argument order is somewhat ambiguous (link text then link target). This is opposite of the order in HTML (`href` then link text).
22-
23-
This rule is configured with one boolean value:
24-
25-
* boolean -- `true` for enabled / `false` for disabled

docs/rule/invocable-blacklist.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Disallow certain components or helpers from being used. Use case is you bring in some addon like ember-composable-helpers, but your team deems one or many of the helpers not suitable and wants to guard against their usage.
44

5-
Given a config of
5+
Given a config of:
66

77
```js
88
'invocable-blacklist': ['foo']
99
```
1010

11-
#### Forbidden:
11+
This rule **forbids** the following:
1212

1313
```hbs
1414
{{foo}}
@@ -18,5 +18,6 @@ Given a config of
1818
{{#foo}}{{/foo}}
1919
```
2020

21-
#### Configuration:
21+
### Configuration
22+
2223
* array of strings - helpers or components to blacklist

docs/rule/linebreak-style.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#### linebreak-style
1+
## linebreak-style
22

33
Having consistent linebreaks is important to make sure that the source code is rendered correctly in editors.
44

5+
### Configuration
6+
57
This rule is configured with a boolean, or a string value:
68

79
* boolean -- `true` for enforcing consistency (all `CRLF` or all `LF` not both in a single file)

docs/rule/link-href-attributes.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ It's common to treat anchor tags as a button: `<a {{action 'handleClick'}}>Submi
44

55
However, this is typically considered bad practice as an anchor tag without an `href` is unfocusable which break accessability.
66

7-
This rule forbids the following:
7+
This rule **forbids** the following:
88

99
```hbs
1010
<a>I'm a fake link</a>
1111
<a {{action 'handleClick'}}>I'm a fake link</a>
1212
```
1313

14-
Instead, you should write the template as:
14+
This rule **allows** the following:
1515

1616
```hbs
1717
<a href="https://alink.com">I'm a real link</a>
1818
```
19-
20-
The following values are valid configuration:
21-
22-
* boolean -- `true` for enabled / `false` for disabled

docs/rule/link-rel-noopener.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ to a malicious clone to perform phishing on your users.
88
Adding `rel="noopener noreferrer"` closes that door and avoids javascript in the opened tab to block the main
99
thread in the opener. Also note that Firefox versions prior 52 do not implement `noopener` and `rel="noreferrer"` should be used instead [ see Firefox issue ](https://bugzilla.mozilla.org/show_bug.cgi?id=1222516) and https://html.spec.whatwg.org/multipage/semantics.html#link-type-noreferrer.
1010

11-
This rule forbids the following:
11+
This rule **forbids** the following:
1212

1313
```hbs
1414
<a href="https://i.seem.secure.com" target="_blank">I'm a bait</a>
1515
```
1616

17-
Instead, you should write the template as:
17+
This rule **allows** the following:
1818

1919
```hbs
2020
<a href="https://i.seem.secure.com" target="_blank" rel="noopener noreferrer">I'm a bait</a>
2121
```
2222

23+
### Configuration
24+
2325
The following values are valid configuration:
2426

2527
* string -- `strict` for enabled and validating both noopener `and` noreferrer

docs/rule/no-action-modifiers.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
## no-action-modifiers
22

3-
This rule forbids the use of `{{action}}` modifiers on elements. The following
4-
code will throw an error:
3+
This rule forbids the use of `{{action}}` modifiers on elements.
4+
5+
This rule **forbids** the following:
56

67
```hbs
78
<button {{action 'handleClick'}}>
89
```
910

10-
The following code will be accepted:
11+
This rule **allows** the following:
1112

1213
```hbs
1314
<button onclick={{action 'handleClick'}}>
1415
```
1516

17+
### Configuration
18+
1619
The following values are valid configuration:
1720

1821
* boolean -- `true` for enabled / `false` for disabled

docs/rule/no-attrs-in-components.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22

33
This rule prevents the usage of `attrs` property to access values passed to the component since all the values can be accessed directly from the template.
44

5-
For example, doing
5+
This rule **forbids** the following:
66

77
```components/templates/layout.hbs
88
{{attr.foo}}
99
```
10-
is bad. The correct way would be to directly consume `foo` in the template like,
10+
This rule **allows** the following:
11+
12+
The correct way would be to directly consume `foo` in the template like:
1113

1214
```components/templates/layout.hbs
1315
{{foo}}
1416
```
1517

16-
or if you using Ember 3.1 and above,
18+
or if you using Ember 3.1 and above:
1719

1820
```components/templates/layout.hbs
1921
{{@foo}}
2022
```
21-
22-
23-
The following values are valid configuration:
24-
25-
* boolean -- `true` for enabled / `false` for disabled

docs/rule/no-bare-strings.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
In order to be able to internationalize your application, you will need to avoid using plain strings in your templates. Instead, you would need to use a template helper specializing in translation ([ember-intl](https://github.com/ember-intl/ember-intl) is the recommended project to use this for).
44

5-
This rule forbids the following:
5+
This rule **forbids** the following:
66

77
``` html
88
<h2>Some string here!</h2>
99
```
1010

11+
### Configuration
12+
1113
The following values are valid configuration:
1214

1315
* boolean -- `true` for enabled / `false` for disabled
@@ -21,5 +23,3 @@ When the config value of `true` is used the following configuration is used:
2123
* `whitelist` - `(),.&+-=*/#%!?:[]{}`
2224
* `globalAttributes` - `title`, `aria-label`, `aria-placeholder`, `aria-roledescription`, `aria-valuetext`
2325
* `elementAttributes` - `{ img: ['alt'], input: ['placeholder'] }`
24-
25-

docs/rule/no-debugger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`{{debugger}}` will inject `debugger` statement into compiled template code and will pause its rendering if developer tools are open. That is undesirable in a production environment.
44

5-
This rule forbids usage of the following:
5+
This rule **forbids** the following:
66

77
```hbs
88
{{debugger}}

docs/rule/no-duplicate-attributes.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
This rule forbids multiple attributes passed to a Component, Helper or an ElementNode with the same name.
44

5-
For Instance:
6-
7-
Forbidden (multiple attributes with the same name):
5+
This rule **forbids** the following (multiple attributes with the same name):
86

97
```hbs
108
{{employee-details name=name age=age name=name}}
119
```
1210

13-
Allowed:
11+
This rule **allows** the following:
1412

1513
```hbs
1614
{{employee-details name=name age=age}}
1715
```
18-
19-
This rule is configured with one boolean value:
20-
21-
* boolean -- `true` for enabled / `false` for disabled

0 commit comments

Comments
 (0)