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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 21 additions & 22 deletions
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

Lines changed: 0 additions & 55 deletions
This file was deleted.

docs/rules/prefer-checked.md

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

0 commit comments

Comments
 (0)