Skip to content

Commit 4299024

Browse files
authored
docs: automate docs with eslint-doc-generator (#275)
1 parent e1d8511 commit 4299024

15 files changed

+106
-90
lines changed

.github/workflows/validate.yml

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
if: ${{ matrix.eslint == 8 }}
4848
run: npm run validate
4949

50+
- name: ▶️ Ensure docs are up-to-date
51+
if: ${{ matrix.eslint == 8 && matrix.node == 16 }}
52+
run: npm run lint:generate-readme-table
53+
5054
- name: ⬆️ Upload coverage report
5155
uses: codecov/codecov-action@v3
5256

README.md

+21-22
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,27 @@ module.exports = {
9292

9393
## Supported Rules
9494

95-
👍 indicates that a rule is recommended for all users.
96-
97-
🔧 indicates that a rule is fixable.
98-
99-
<!-- __BEGIN AUTOGENERATED TABLE__ -->
100-
101-
| Name | 👍 | 🔧 | Description |
102-
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | --------------------------------------------------------------------- |
103-
| [prefer-checked](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-checked.md) | 👍 | 🔧 | prefer toBeChecked over checking attributes |
104-
| [prefer-empty](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-empty.md) | 👍 | 🔧 | Prefer toBeEmpty over checking innerHTML |
105-
| [prefer-enabled-disabled](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-enabled-disabled.md) | 👍 | 🔧 | prefer toBeDisabled or toBeEnabled over checking attributes |
106-
| [prefer-focus](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-focus.md) | 👍 | 🔧 | prefer toHaveFocus over checking document.activeElement |
107-
| [prefer-in-document](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-in-document.md) | 👍 | 🔧 | Prefer .toBeInTheDocument() for asserting the existence of a DOM node |
108-
| [prefer-required](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-required.md) | 👍 | 🔧 | prefer toBeRequired over checking properties |
109-
| [prefer-to-have-attribute](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-attribute.md) | 👍 | 🔧 | prefer toHaveAttribute over checking getAttribute/hasAttribute |
110-
| [prefer-to-have-class](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-class.md) | 👍 | 🔧 | prefer toHaveClass over checking element className |
111-
| [prefer-to-have-style](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-style.md) | 👍 | 🔧 | prefer toHaveStyle over checking element style |
112-
| [prefer-to-have-text-content](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-text-content.md) | 👍 | 🔧 | Prefer toHaveTextContent over checking element.textContent |
113-
| [prefer-to-have-value](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-value.md) | 👍 | 🔧 | prefer toHaveValue over checking element.value |
114-
115-
<!-- __END AUTOGENERATED TABLE__ -->
95+
<!-- begin auto-generated rules list -->
96+
97+
💼 Configurations enabled in.\
98+
✅ Set in the `recommended` configuration.\
99+
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
100+
101+
| Name                        | Description | 💼 | 🔧 |
102+
| :----------------------------------------------------------------------- | :-------------------------------------------------------------------- | :- | :- |
103+
| [prefer-checked](docs/rules/prefer-checked.md) | prefer toBeChecked over checking attributes || 🔧 |
104+
| [prefer-empty](docs/rules/prefer-empty.md) | Prefer toBeEmpty over checking innerHTML || 🔧 |
105+
| [prefer-enabled-disabled](docs/rules/prefer-enabled-disabled.md) | prefer toBeDisabled or toBeEnabled over checking attributes || 🔧 |
106+
| [prefer-focus](docs/rules/prefer-focus.md) | prefer toHaveFocus over checking document.activeElement || 🔧 |
107+
| [prefer-in-document](docs/rules/prefer-in-document.md) | Prefer .toBeInTheDocument() for asserting the existence of a DOM node || 🔧 |
108+
| [prefer-required](docs/rules/prefer-required.md) | prefer toBeRequired over checking properties || 🔧 |
109+
| [prefer-to-have-attribute](docs/rules/prefer-to-have-attribute.md) | prefer toHaveAttribute over checking getAttribute/hasAttribute || 🔧 |
110+
| [prefer-to-have-class](docs/rules/prefer-to-have-class.md) | prefer toHaveClass over checking element className || 🔧 |
111+
| [prefer-to-have-style](docs/rules/prefer-to-have-style.md) | prefer toHaveStyle over checking element style || 🔧 |
112+
| [prefer-to-have-text-content](docs/rules/prefer-to-have-text-content.md) | Prefer toHaveTextContent over checking element.textContent || 🔧 |
113+
| [prefer-to-have-value](docs/rules/prefer-to-have-value.md) | prefer toHaveValue over checking element.value || 🔧 |
114+
115+
<!-- end auto-generated rules list -->
116116

117117
## Issues
118118

@@ -196,7 +196,6 @@ MIT
196196
[coc]: https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/other/CODE_OF_CONDUCT.md
197197
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
198198
[all-contributors]: https://github.com/all-contributors/all-contributors
199-
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/eslint-plugin-jest-dom?color=orange&style=flat-square
200199
[bugs]: https://github.com/testing-library/eslint-plugin-jest-dom/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug
201200
[requests]: https://github.com/testing-library/eslint-plugin-jest-dom/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement
202201
[good-first-issue]: https://github.com/testing-library/eslint-plugin-jest-dom/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22

build/generate-readme-table.js

-55
This file was deleted.

docs/rules/prefer-checked.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toBeChecked() or not.toBeChecked() over toHaveProperty('checked', true|false) (prefer-enabled-checked)
1+
# Prefer toBeChecked over checking attributes (`jest-dom/prefer-checked`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
## Rule Details
410

docs/rules/prefer-empty.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Prefer toBeEmptyDOMElement over checking innerHTML / firstChild (prefer-empty)
1+
# Prefer toBeEmpty over checking innerHTML (`jest-dom/prefer-empty`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
This rule ensures people will use toBeEmptyDOMElement() rather than checking dom
410
nodes/properties. It is primarily aimed at consistently using jest-dom for

docs/rules/prefer-enabled-disabled.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toBeDisabled() or toBeEnabled() over toHaveProperty('disabled', true|false) (prefer-enabled-disabled)
1+
# Prefer toBeDisabled or toBeEnabled over checking attributes (`jest-dom/prefer-enabled-disabled`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
## Rule Details
410

docs/rules/prefer-focus.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer-focus
1+
# Prefer toHaveFocus over checking document.activeElement (`jest-dom/prefer-focus`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
prefer toHaveFocus over checking document.activeElement (prefer-focus)
410

docs/rules/prefer-in-document.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Prefer .toBeInTheDocument in favor of .toHaveLength(1) (prefer-in-document)
1+
# Prefer .toBeInTheDocument() for asserting the existence of a DOM node (`jest-dom/prefer-in-document`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
## Rule Details
410

docs/rules/prefer-required.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toBeRequired() or not.toBeRequired() over toHaveProperty('required', true|false) (prefer-required)
1+
# Prefer toBeRequired over checking properties (`jest-dom/prefer-required`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
## Rule Details
410

docs/rules/prefer-to-have-attribute.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toHaveAttribute over checking getAttribute/hasAttribute (prefer-to-have-attribute)
1+
# Prefer toHaveAttribute over checking getAttribute/hasAttribute (`jest-dom/prefer-to-have-attribute`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
This rule is an autofixable rule that reports usages of `getAttribute` or
410
`hasAttribute` in expect statements in preference of using the jest-dom

docs/rules/prefer-to-have-class.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toHaveClass over checking element.class (prefer-to-have-class)
1+
# Prefer toHaveClass over checking element className (`jest-dom/prefer-to-have-class`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
This rule is an autofixable rule that reports usages of checking element className or classList in expect statements in preference of using the jest-dom
410
`toHaveClass` matcher.

docs/rules/prefer-to-have-style.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toHaveStyle over checking element.style (prefer-to-have-style)
1+
# Prefer toHaveStyle over checking element style (`jest-dom/prefer-to-have-style`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
This rule is an autofixable rule that reports usages of checking element.style in expect statements in preference of using the jest-dom
410
`toHaveStyle` matcher.

docs/rules/prefer-to-have-text-content.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Prefer toHaveTextContent over checking element.textContent (prefer-to-have-text-content)
1+
# Prefer toHaveTextContent over checking element.textContent (`jest-dom/prefer-to-have-text-content`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
Please describe the origin of the rule here.
410

docs/rules/prefer-to-have-value.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# prefer toHaveAttribute over checking getAttribute/hasAttribute (prefer-to-have-attribute)
1+
# Prefer toHaveValue over checking element.value (`jest-dom/prefer-to-have-value`)
2+
3+
💼 This rule is enabled in the ✅ `recommended` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
28

39
This rule is an autofixable rule that encourages the use of toHaveValue over checking the value attribute.
410

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
],
3131
"scripts": {
3232
"build": "kcd-scripts build",
33-
"pregenerate-readme-table": "yarn build",
34-
"generate-readme-table": "node build/generate-readme-table.js",
33+
"pregenerate-readme-table": "npm run build",
34+
"generate-readme-table": "eslint-doc-generator --ignore-config all",
3535
"lint": "kcd-scripts lint",
36+
"lint:generate-readme-table": "npm run generate-readme-table -- --check",
3637
"setup": "npm install && npm run validate -s",
3738
"test": "kcd-scripts test",
3839
"test:coverage": "npm test -- --coverage",
@@ -47,6 +48,7 @@
4748
"devDependencies": {
4849
"@typescript-eslint/parser": "^5.9.1",
4950
"eslint": "^8.7.0",
51+
"eslint-doc-generator": "^0.19.0",
5052
"eslint-remote-tester": "^3.0.0",
5153
"eslint-remote-tester-repositories": "^0.0.7",
5254
"kcd-scripts": "^12.0.0",

0 commit comments

Comments
 (0)