Skip to content

Commit

Permalink
docs: add automatic rule option lists with eslint-doc-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Oct 31, 2023
1 parent 0bfa254 commit f83bd28
Show file tree
Hide file tree
Showing 39 changed files with 213 additions and 55 deletions.
9 changes: 4 additions & 5 deletions docs/rules/_TEMPLATE_.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ TODO: suggest any fast/automated techniques for fixing violations in a large cod

## Configuration

TODO: exclude this section if the rule has no extra configuration

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

## Related Rules

Expand Down
8 changes: 6 additions & 2 deletions docs/rules/named-functions-in-promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ test('it reloads user in promise handler', function (assert) {

## Configuration

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

- `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))`.
| Name | Description | Type | Default |
| :------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `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` |

<!-- end auto-generated rule options list -->
8 changes: 6 additions & 2 deletions docs/rules/no-arrow-function-computed-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ const Person = EmberObject.extend({

## Configuration

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

- `boolean` -- `onlyThisContexts` -- whether the rule should allow or disallow computed properties where the arrow function body does not contain a `this` reference (default: `false`)
| Name | Description | Type | Default |
| :----------------- | :------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `onlyThisContexts` | Whether the rule should allow or disallow computed properties where the arrow function body does not contain a `this` reference. | Boolean | `false` |

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

## References

Expand Down
8 changes: 6 additions & 2 deletions docs/rules/no-classic-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ export default class MyComponent extends Component.extend(Evented) {}

## Configuration

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

- `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`.
| Name | Description | Type |
| :----------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| `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[] |

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

## When Not To Use It

Expand Down
8 changes: 6 additions & 2 deletions docs/rules/no-computed-properties-in-native-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ export default class MyComponent extends Component {}

## Configuration

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

- `boolean` -- `ignoreClassic` -- whether the rule should ignore usage inside of native classes labeled with `@classic` (default `true`)
| Name | Description | Type | Default |
| :-------------- | :------------------------------------------------------------------------------------- | :------ | :------ |
| `ignoreClassic` | Whether the rule should ignore usage inside of native classes labeled with `@classic`. | Boolean | `true` |

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

## References

Expand Down
9 changes: 7 additions & 2 deletions docs/rules/no-controller-access-in-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@ export default class MyRoute extends Route {

## Configuration

- object -- containing the following properties:
- boolean -- `allowControllerFor` -- whether the rule should allow or disallow routes from accessing the controller outside of `setupController`/`resetController` via `controllerFor` (default: `false`)
<!-- begin auto-generated rule options list -->

| Name | Description | Type | Default |
| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `allowControllerFor` | Whether the rule should allow or disallow routes from accessing the controller outside of `setupController`/`resetController` via `controllerFor`. | Boolean | `false` |

<!-- end auto-generated rule options list -->
10 changes: 7 additions & 3 deletions docs/rules/no-get-with-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ const test = this.key || [];

## Configuration

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

- `boolean` -- `catchSafeObjects` -- whether the rule should catch non-`this` imported usages like `getWithDefault(person, 'name', '')` (default `true`)
- `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`)
| Name | Description | Type | Default |
| :------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `catchSafeObjects` | Whether the rule should catch non-`this` imported usages like `getWithDefault(person, 'name', '')`. | Boolean | `true` |
| `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` |

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

## References

Expand Down
20 changes: 12 additions & 8 deletions docs/rules/no-get.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ export default EmberObject.extend({
## Configuration
This rule takes an optional object containing:
- `boolean` -- `ignoreGetProperties` -- whether the rule should ignore `getProperties` (default `false`)
- `boolean` -- `ignoreNestedPaths` -- whether the rule should ignore `this.get('some.nested.property')` (can't be enabled at the same time as `useOptionalChaining`) (default `false`)
- `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`)
- `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`)
- `boolean` -- `catchSafeObjects` -- whether the rule should catch non-`this` imported usages like `get(foo, 'bar')` (default `true`)
- `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`)
<!-- begin auto-generated rule options list -->
| Name | Description | Type | Default |
| :-------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `catchSafeObjects` | Whether the rule should catch non-`this` imported usages like `get(foo, 'bar')`. | Boolean | `true` |
| `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` |
| `ignoreGetProperties` | Whether the rule should ignore `getProperties`. | Boolean | `false` |
| `ignoreNestedPaths` | Whether the rule should ignore `this.get('some.nested.property')` (can't be enabled at the same time as `useOptionalChaining`). | Boolean | `false` |
| `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` |
| `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` |
<!-- end auto-generated rule options list -->
## Related Rules
Expand Down
10 changes: 7 additions & 3 deletions docs/rules/no-private-routing-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ export default class MyComponent extends Component {

## Configuration

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

- `boolean` -- `catchRouterMicrolib` -- whether the rule should catch usages of the private property `_routerMicrolib` (default `true`)
- `boolean` -- `catchRouterMain` -- whether the rule should catch usages of the private property `router:main` (default `true`)
| Name | Description | Type | Default |
| :-------------------- | :------------------------------------------------------------------------------ | :------ | :------ |
| `catchRouterMain` | Whether the rule should catch usages of the private property `router:main`. | Boolean | `true` |
| `catchRouterMicrolib` | Whether the rule should catch usages of the private property `_routerMicrolib`. | Boolean | `true` |

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

## References

Expand Down
9 changes: 7 additions & 2 deletions docs/rules/no-restricted-property-modifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export default class MyComponent extends Component {

## Configuration

- object -- containing the following properties:
- `String[]` -- `properties` -- array of names of properties that should not be modified (modifying child/nested/sub-properties of these is also not allowed)
<!-- begin auto-generated rule options list -->

| Name | Description | Type | Required |
| :----------- | :----------------------------------------------------------------------------------------------------------------------------- | :------- | :------- |
| `properties` | Array of names of properties that should not be modified (modifying child/nested/sub-properties of these is also not allowed). | String[] | Yes |

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

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`.
15 changes: 11 additions & 4 deletions docs/rules/no-restricted-service-injections.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ class MyComponent extends Component {

## Configuration

- object[] -- containing the following properties:
- string[] -- `services` -- list of (kebab-case) service names that should be disallowed from being injected under the specified paths
- 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)
- string -- `message` -- optional custom error message to display for violations
Accepts an array of the objects with the following options:

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

| Name | Description | Type | Required |
| :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | :------- |
| `message` | Optional custom error message to display for violations. | 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). | String[] | |
| `services` | List of (kebab-case) service names that should be disallowed from being injected under the specified paths. | String[] | Yes |

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

## Related Rules

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/no-runloop.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export default class MyComponent extends Component {

## Configuration

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.
<!-- begin auto-generated rule options list -->

| Name | Description | Type |
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
| `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[] |

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

```js
module.exports = {
Expand Down
10 changes: 7 additions & 3 deletions docs/rules/no-side-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export default Component.extend({

## Configuration

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

- `boolean` -- `catchEvents` -- whether the rule should catch function calls that send actions or events (default `true`)
- `boolean` -- `checkPlainGetters` -- whether the rule should check plain (non-computed) getters in native classes for side effects (default `true`)
| Name | Description | Type | Default |
| :------------------ | :--------------------------------------------------------------------------------------------- | :------ | :------ |
| `catchEvents` | Whether the rule should catch function calls that send actions or events. | Boolean | `true` |
| `checkPlainGetters` | Whether the rule should check plain (non-computed) getters in native classes for side effects. | Boolean | `true` |

<!-- end auto-generated rule options list -->
8 changes: 8 additions & 0 deletions docs/rules/order-in-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it

## Configuration

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

| Name | Type |
| :------ | :---- |
| `order` | Array |

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

```js
const rules = {
'ember/order-in-components': [
Expand Down
8 changes: 8 additions & 0 deletions docs/rules/order-in-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it

## Configuration

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

| Name | Type |
| :------ | :---- |
| `order` | Array |

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

```js
const rules = {
'ember/order-in-controllers': [
Expand Down
8 changes: 8 additions & 0 deletions docs/rules/order-in-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Note: this rule will not be added to the `recommended` configuration because it

## Configuration

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

| Name | Type |
| :------ | :---- |
| `order` | Array |

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

```js
const rules = {
'ember/order-in-models': [
Expand Down
Loading

0 comments on commit f83bd28

Please sign in to comment.