Skip to content

Commit 10674fe

Browse files
docs: auto-generate rule docs (#1)
- Added eslint-doc-generator - Added markdownlint - Re-created rule headers and README rules list
1 parent ce90476 commit 10674fe

File tree

7 files changed

+927
-23
lines changed

7 files changed

+927
-23
lines changed

.markdownlint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"line-length": false,
3+
"MD024": {
4+
"siblings_only": true
5+
}
6+
}

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ There is no recommended configuration for this package, as all of the rules are
1212
This project is a fork of [`eslint-plugin-rxjs-angular`](https://github.com/cartant/eslint-plugin-rxjs-angular)
1313
initially started to support the new ESLint flat config format.
1414

15+
- The old `.eslintrc` format is not supported.
16+
- If you need to continue using this old format, use the original `eslint-plugin-rxjs` or a different fork.
17+
1518
A complete description of all changes are documented in the [CHANGELOG](CHANGELOG.md) file.
1619

1720
## Install
@@ -51,8 +54,14 @@ See [Linting with Type Information](https://typescript-eslint.io/getting-started
5154

5255
The package includes the following rules:
5356

54-
| Rule | Description | Recommended |
55-
| --- | --- | --- |
56-
| [`prefer-async-pipe`](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-angular-x/blob/main/docs/rules/prefer-async-pipe.md) | Forbids the calling of `subscribe` within Angular components. | No |
57-
| [`prefer-composition`](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-angular-x/blob/main/docs/rules/prefer-composition.md) | Forbids `subscribe` calls that are not composed within Angular components (and, optionally, within services, directives, and pipes). | No |
58-
| [`prefer-takeuntil`](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-angular-x/blob/main/docs/rules/prefer-takeuntil.md) | Forbids Calling `subscribe` without an accompanying `takeUntil`. | No |
57+
<!-- begin auto-generated rules list -->
58+
59+
💭 Requires [type information](https://typescript-eslint.io/linting/typed-linting).
60+
61+
| Name               | Description | 💭 |
62+
| :----------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | :- |
63+
| [prefer-async-pipe](docs/rules/prefer-async-pipe.md) | Disallow the calling of `subscribe` within Angular components. | 💭 |
64+
| [prefer-composition](docs/rules/prefer-composition.md) | Disallow `subscribe` calls that are not composed within Angular components (and, optionally, within services, directives, and pipes). | 💭 |
65+
| [prefer-takeuntil](docs/rules/prefer-takeuntil.md) | Disallow `subscribe` calls without an accompanying `takeUntil` within Angular components (and, optionally, within services, directives, and pipes). | 💭 |
66+
67+
<!-- end auto-generated rules list -->

docs/rules/prefer-async-pipe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Use container components and async pipe (`prefer-async-pipe`)
1+
# Disallow the calling of `subscribe` within Angular components (`rxjs-angular-x/prefer-async-pipe`)
22

3-
This rule effects failures if explicit calls to `subscribe` are made within a component. Instead, use a child component to which a value is passed by using the async pipe in the parent component's template.
3+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
44

5-
## Options
5+
<!-- end auto-generated rule header -->
66

7-
This rule has no options.
7+
This rule effects failures if explicit calls to `subscribe` are made within a component. Instead, use a child component to which a value is passed by using the async pipe in the parent component's template.
88

99
## Further reading
1010

docs/rules/prefer-composition.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Use subscription composition (`prefer-composition`)
1+
# Disallow `subscribe` calls that are not composed within Angular components (and, optionally, within services, directives, and pipes) (`rxjs-angular-x/prefer-composition`)
2+
3+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
4+
5+
<!-- end auto-generated rule header -->
26

37
This rule effects failures if `subscribe` calls are made with a component and the returned subscription is not composed into a subscription that is unsubscribed when the component is destroyed.
48

@@ -48,6 +52,14 @@ export class SomeComponent implements OnInit, OnDestroy {
4852

4953
## Options
5054

55+
<!-- begin auto-generated rule options list -->
56+
57+
| Name | Description | Type |
58+
| :---------------- | :--------------------------------------------- | :------- |
59+
| `checkDecorators` | An optional array of decorator names to check. | String[] |
60+
61+
<!-- end auto-generated rule options list -->
62+
5163
This rule accepts a single option which is an object with a `checkDecorators` property which is an array containing the names of the decorators that determine whether or not a class is checked. By default, `checkDecorators` is `["Component"]`.
5264

5365
```json
@@ -61,4 +73,4 @@ This rule accepts a single option which is an object with a `checkDecorators` pr
6173

6274
## Further reading
6375

64-
- [Composing Subscriptions](https://ncjamieson.com/composing-subscriptions/)
76+
- [Composing Subscriptions](https://ncjamieson.com/composing-subscriptions/)

docs/rules/prefer-takeuntil.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Use `takeUntil` and `ngOnDestroy` (`prefer-takeuntil`)
1+
# Disallow `subscribe` calls without an accompanying `takeUntil` within Angular components (and, optionally, within services, directives, and pipes) (`rxjs-angular-x/prefer-takeuntil`)
2+
3+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
4+
5+
<!-- end auto-generated rule header -->
26

37
This rule effects failures if `subscribe` is called within a component and the `takeUntil`-destroyed pattern is not used.
48

@@ -50,6 +54,17 @@ class SomeComponent implements OnDestroy, OnInit {
5054

5155
## Options
5256

57+
<!-- begin auto-generated rule options list -->
58+
59+
| Name | Description | Type |
60+
| :---------------- | :-------------------------------------------------------------- | :------- |
61+
| `alias` | An optional array of operator names that alias for `takeUntil`. | String[] |
62+
| `checkComplete` | Check for `complete` calls. | Boolean |
63+
| `checkDecorators` | An optional array of decorator names to check. | String[] |
64+
| `checkDestroy` | Check for `Subject`-based `ngOnDestroy`. | Boolean |
65+
66+
<!-- end auto-generated rule options list -->
67+
5368
This rule accepts a single option which is an object with `checkComplete`, `checkDecorators`, `checkDestroy` and `alias` properties.
5469

5570
The `checkComplete` property is a boolean that determines whether or not `complete` must be called after `next` and the `checkDestroy` property is a boolean that determines whether or not a `Subject`-based `ngOnDestroy` must be implemented.
@@ -74,4 +89,4 @@ The `alias` property is an array of names of operators that should be treated si
7489

7590
## Further reading
7691

77-
- [Avoiding takeUntil leaks](https://ncjamieson.com/avoiding-takeuntil-leaks/)
92+
- [Avoiding takeUntil leaks](https://ncjamieson.com/avoiding-takeuntil-leaks/)

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
],
4444
"scripts": {
4545
"build": "tsup",
46-
"lint": "yarn lint-js",
46+
"lint": "yarn lint-js && yarn lint-docs && yarn lint-eslint-docs",
4747
"lint-js": "eslint",
48+
"lint-docs": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"",
49+
"lint-eslint-docs": "yarn build && eslint-doc-generator --check",
50+
"docs": "eslint-doc-generator",
4851
"release": "bumpp && echo \"Create a new release in GitHub to trigger the publish workflow.\"",
4952
"test": "vitest",
5053
"coverage": "vitest run --coverage",
@@ -53,6 +56,7 @@
5356
"dependencies": {
5457
"@typescript-eslint/utils": "^8.19.1",
5558
"common-tags": "^1.8.0",
59+
"markdownlint-cli2": "^0.17.2",
5660
"ts-api-utils": "^2.0.0",
5761
"tslib": "^2.1.0"
5862
},
@@ -77,6 +81,7 @@
7781
"bumpp": "^10.0.1",
7882
"eslint": "^9.19.0",
7983
"eslint-config-flat-gitignore": "^1.0.0",
84+
"eslint-doc-generator": "^2.0.2",
8085
"eslint-import-resolver-typescript": "^3.7.0",
8186
"eslint-plugin-eslint-plugin": "^6.4.0",
8287
"eslint-plugin-import-x": "^4.6.1",

0 commit comments

Comments
 (0)