Skip to content

Commit 89144c6

Browse files
authored
Add automatic rule option lists with eslint-doc-generator (#1969)
1 parent 0bfa254 commit 89144c6

39 files changed

+213
-55
lines changed

docs/rules/_TEMPLATE_.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ TODO: suggest any fast/automated techniques for fixing violations in a large cod
4141

4242
## Configuration
4343

44-
TODO: exclude this section if the rule has no extra configuration
45-
46-
- object -- containing the following properties:
47-
- string -- `parameterName1` -- TODO: description of parameter including the possible values and default value
48-
- boolean -- `parameterName2` -- TODO: description of parameter including the possible values and default value
44+
<!-- begin auto-generated rule options list -->
45+
TODO: exclude this section if the rule has no extra configuration.
46+
TODO: ensure `meta.schema` contains descriptions, constraints, defaults, etc for all options.
47+
<!-- end auto-generated rule options list -->
4948

5049
## Related Rules
5150

docs/rules/named-functions-in-promises.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ test('it reloads user in promise handler', function (assert) {
6767

6868
## Configuration
6969

70-
This rule takes an optional object containing:
70+
<!-- begin auto-generated rule options list -->
7171

72-
- `boolean` -- `allowSimpleArrowFunction` -- (default false) setting to `true` allows arrow function expressions that do not have block bodies. These simple arrow functions must also only contain a single function call. For example: `.then(user => this._reloadUser(user))`.
72+
| Name | Description | Type | Default |
73+
| :------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
74+
| `allowSimpleArrowFunction` | Enabling allows arrow function expressions that do not have block bodies. These simple arrow functions must also only contain a single function call. For example: `.then(user => this._reloadUser(user))`. | Boolean | `false` |
75+
76+
<!-- end auto-generated rule options list -->

docs/rules/no-arrow-function-computed-properties.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ const Person = EmberObject.extend({
3838

3939
## Configuration
4040

41-
This rule takes an optional object containing:
41+
<!-- begin auto-generated rule options list -->
4242

43-
- `boolean` -- `onlyThisContexts` -- whether the rule should allow or disallow computed properties where the arrow function body does not contain a `this` reference (default: `false`)
43+
| Name | Description | Type | Default |
44+
| :----------------- | :------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
45+
| `onlyThisContexts` | Whether the rule should allow or disallow computed properties where the arrow function body does not contain a `this` reference. | Boolean | `false` |
46+
47+
<!-- end auto-generated rule options list -->
4448

4549
## References
4650

docs/rules/no-classic-classes.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ export default class MyComponent extends Component.extend(Evented) {}
4949

5050
## Configuration
5151

52-
This rule takes an optional object containing:
52+
<!-- begin auto-generated rule options list -->
5353

54-
- `string[]` -- `additionalClassImports` -- Allows you to specify additional imports that should be flagged to disallow calling `extend` on. This allows you to handle the case where your app or addon is importing from a module that performs the `extend`.
54+
| Name | Description | Type |
55+
| :----------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
56+
| `additionalClassImports` | Allows you to specify additional imports that should be flagged to disallow calling `extend` on. This allows you to handle the case where your app or addon is importing from a module that performs the `extend`. | String[] |
57+
58+
<!-- end auto-generated rule options list -->
5559

5660
## When Not To Use It
5761

docs/rules/no-computed-properties-in-native-classes.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ export default class MyComponent extends Component {}
6868

6969
## Configuration
7070

71-
This rule takes an optional object containing:
71+
<!-- begin auto-generated rule options list -->
7272

73-
- `boolean` -- `ignoreClassic` -- whether the rule should ignore usage inside of native classes labeled with `@classic` (default `true`)
73+
| Name | Description | Type | Default |
74+
| :-------------- | :------------------------------------------------------------------------------------- | :------ | :------ |
75+
| `ignoreClassic` | Whether the rule should ignore usage inside of native classes labeled with `@classic`. | Boolean | `true` |
76+
77+
<!-- end auto-generated rule options list -->
7478

7579
## References
7680

docs/rules/no-controller-access-in-routes.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,10 @@ export default class MyRoute extends Route {
6666

6767
## Configuration
6868

69-
- object -- containing the following properties:
70-
- boolean -- `allowControllerFor` -- whether the rule should allow or disallow routes from accessing the controller outside of `setupController`/`resetController` via `controllerFor` (default: `false`)
69+
<!-- begin auto-generated rule options list -->
70+
71+
| Name | Description | Type | Default |
72+
| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
73+
| `allowControllerFor` | Whether the rule should allow or disallow routes from accessing the controller outside of `setupController`/`resetController` via `controllerFor`. | Boolean | `false` |
74+
75+
<!-- end auto-generated rule options list -->

docs/rules/no-get-with-default.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ const test = this.key || [];
4444

4545
## Configuration
4646

47-
This rule takes an optional object containing:
47+
<!-- begin auto-generated rule options list -->
4848

49-
- `boolean` -- `catchSafeObjects` -- whether the rule should catch non-`this` imported usages like `getWithDefault(person, 'name', '')` (default `true`)
50-
- `boolean` -- `catchUnsafeObjects` -- whether the rule should catch non-`this` usages like `person.getWithDefault('name', '')` even though we don't know for sure if `person` is an Ember object (default `true`)
49+
| Name | Description | Type | Default |
50+
| :------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
51+
| `catchSafeObjects` | Whether the rule should catch non-`this` imported usages like `getWithDefault(person, 'name', '')`. | Boolean | `true` |
52+
| `catchUnsafeObjects` | Whether the rule should catch non-`this` usages like `person.getWithDefault('name', '')` even though we don't know for sure if `person` is an Ember object. | Boolean | `true` |
53+
54+
<!-- end auto-generated rule options list -->
5155

5256
## References
5357

docs/rules/no-get.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,18 @@ export default EmberObject.extend({
9191
9292
## Configuration
9393
94-
This rule takes an optional object containing:
95-
96-
- `boolean` -- `ignoreGetProperties` -- whether the rule should ignore `getProperties` (default `false`)
97-
- `boolean` -- `ignoreNestedPaths` -- whether the rule should ignore `this.get('some.nested.property')` (can't be enabled at the same time as `useOptionalChaining`) (default `false`)
98-
- `boolean` -- `useAt` -- whether the rule should use `at(-1)` [Array.prototype.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at) to replace `lastObject` (default `true`)
99-
- `boolean` -- `useOptionalChaining` -- whether the rule should use the [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) `?.` to autofix nested paths such as `this.get('some.nested.property')` to `this.some?.nested?.property` (when this option is off, these nested paths won't be autofixed at all) (default `true`)
100-
- `boolean` -- `catchSafeObjects` -- whether the rule should catch non-`this` imported usages like `get(foo, 'bar')` (default `true`)
101-
- `boolean` -- `catchUnsafeObjects` -- whether the rule should catch non-`this` usages like `foo.get('bar')` even though we don't know for sure if `foo` is an Ember object (default `false`)
94+
<!-- begin auto-generated rule options list -->
95+
96+
| Name | Description | Type | Default |
97+
| :-------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
98+
| `catchSafeObjects` | Whether the rule should catch non-`this` imported usages like `get(foo, 'bar')`. | Boolean | `true` |
99+
| `catchUnsafeObjects` | Whether the rule should catch non-`this` usages like `foo.get('bar')` even though we don't know for sure if `foo` is an Ember object. | Boolean | `false` |
100+
| `ignoreGetProperties` | Whether the rule should ignore `getProperties`. | Boolean | `false` |
101+
| `ignoreNestedPaths` | Whether the rule should ignore `this.get('some.nested.property')` (can't be enabled at the same time as `useOptionalChaining`). | Boolean | `false` |
102+
| `useAt` | Whether the rule should use `at(-1)` [Array.prototype.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at) to replace `lastObject`. | Boolean | `true` |
103+
| `useOptionalChaining` | Whether the rule should use the [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) `?.` to autofix nested paths such as `this.get('some.nested.property')` to `this.some?.nested?.property` (when this option is off, these nested paths won't be autofixed at all). | Boolean | `true` |
104+
105+
<!-- end auto-generated rule options list -->
102106
103107
## Related Rules
104108

docs/rules/no-private-routing-service.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ export default class MyComponent extends Component {
8383

8484
## Configuration
8585

86-
This rule takes an optional object containing:
86+
<!-- begin auto-generated rule options list -->
8787

88-
- `boolean` -- `catchRouterMicrolib` -- whether the rule should catch usages of the private property `_routerMicrolib` (default `true`)
89-
- `boolean` -- `catchRouterMain` -- whether the rule should catch usages of the private property `router:main` (default `true`)
88+
| Name | Description | Type | Default |
89+
| :-------------------- | :------------------------------------------------------------------------------ | :------ | :------ |
90+
| `catchRouterMain` | Whether the rule should catch usages of the private property `router:main`. | Boolean | `true` |
91+
| `catchRouterMicrolib` | Whether the rule should catch usages of the private property `_routerMicrolib`. | Boolean | `true` |
92+
93+
<!-- end auto-generated rule options list -->
9094

9195
## References
9296

docs/rules/no-restricted-property-modifications.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ export default class MyComponent extends Component {
5656

5757
## Configuration
5858

59-
- object -- containing the following properties:
60-
- `String[]` -- `properties` -- array of names of properties that should not be modified (modifying child/nested/sub-properties of these is also not allowed)
59+
<!-- begin auto-generated rule options list -->
60+
61+
| Name | Description | Type | Required |
62+
| :----------- | :----------------------------------------------------------------------------------------------------------------------------- | :------- | :------- |
63+
| `properties` | Array of names of properties that should not be modified (modifying child/nested/sub-properties of these is also not allowed). | String[] | Yes |
64+
65+
<!-- end auto-generated rule options list -->
6166

6267
Not yet implemented: There is currently no way to configure whether sub-properties are restricted from modification. To make this configurable, the `properties` array option could be updated to also accept objects of the form `{ name: 'myPropertyName', includeSubProperties: false }` where `includeSubProperties` defaults to `true`.

docs/rules/no-restricted-service-injections.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ class MyComponent extends Component {
4545

4646
## Configuration
4747

48-
- object[] -- containing the following properties:
49-
- string[] -- `services` -- list of (kebab-case) service names that should be disallowed from being injected under the specified paths
50-
- string[] -- `paths` -- optional list of regexp file paths that injecting the specified services should be disallowed under (omit this field to match any path) (for glob patterns, use [ESLint `overrides`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns) instead)
51-
- string -- `message` -- optional custom error message to display for violations
48+
Accepts an array of the objects with the following options:
49+
50+
<!-- begin auto-generated rule options list -->
51+
52+
| Name | Description | Type | Required |
53+
| :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | :------- |
54+
| `message` | Optional custom error message to display for violations. | String | |
55+
| `paths` | Optional list of regexp file paths that injecting the specified services should be disallowed under (omit this field to match any path) (for glob patterns, use [ESLint `overrides`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns) instead). | String[] | |
56+
| `services` | List of (kebab-case) service names that should be disallowed from being injected under the specified paths. | String[] | Yes |
57+
58+
<!-- end auto-generated rule options list -->
5259

5360
## Related Rules
5461

docs/rules/no-runloop.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ export default class MyComponent extends Component {
5858

5959
## Configuration
6060

61-
If you have `@ember/runloop` functions that you wish to allow, you can configure this rule to allow specific methods. The configuration takes an object with the `allowList` property, which is an array of strings where the strings must be names of runloop functions.
61+
<!-- begin auto-generated rule options list -->
62+
63+
| Name | Description | Type |
64+
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
65+
| `allowList` | If you have `@ember/runloop` functions that you wish to allow, you can configure this rule to allow specific methods. The configuration takes an object with the `allowList` property, which is an array of strings where the strings must be names of runloop functions. | String[] |
66+
67+
<!-- end auto-generated rule options list -->
6268

6369
```js
6470
module.exports = {

docs/rules/no-side-effects.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ export default Component.extend({
4646

4747
## Configuration
4848

49-
This rule takes an optional object containing:
49+
<!-- begin auto-generated rule options list -->
5050

51-
- `boolean` -- `catchEvents` -- whether the rule should catch function calls that send actions or events (default `true`)
52-
- `boolean` -- `checkPlainGetters` -- whether the rule should check plain (non-computed) getters in native classes for side effects (default `true`)
51+
| Name | Description | Type | Default |
52+
| :------------------ | :--------------------------------------------------------------------------------------------- | :------ | :------ |
53+
| `catchEvents` | Whether the rule should catch function calls that send actions or events. | Boolean | `true` |
54+
| `checkPlainGetters` | Whether the rule should check plain (non-computed) getters in native classes for side effects. | Boolean | `true` |
55+
56+
<!-- end auto-generated rule options list -->

docs/rules/order-in-components.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it
88

99
## Configuration
1010

11+
<!-- begin auto-generated rule options list -->
12+
13+
| Name | Type |
14+
| :------ | :---- |
15+
| `order` | Array |
16+
17+
<!-- end auto-generated rule options list -->
18+
1119
```js
1220
const rules = {
1321
'ember/order-in-components': [

docs/rules/order-in-controllers.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it
88

99
## Configuration
1010

11+
<!-- begin auto-generated rule options list -->
12+
13+
| Name | Type |
14+
| :------ | :---- |
15+
| `order` | Array |
16+
17+
<!-- end auto-generated rule options list -->
18+
1119
```js
1220
const rules = {
1321
'ember/order-in-controllers': [

docs/rules/order-in-models.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it
88

99
## Configuration
1010

11+
<!-- begin auto-generated rule options list -->
12+
13+
| Name | Type |
14+
| :------ | :---- |
15+
| `order` | Array |
16+
17+
<!-- end auto-generated rule options list -->
18+
1119
```js
1220
const rules = {
1321
'ember/order-in-models': [

0 commit comments

Comments
 (0)