Skip to content

Commit

Permalink
docs: automate docs with eslint-doc-generator (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish authored Nov 8, 2022
1 parent e1d8511 commit 4299024
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 90 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ jobs:
if: ${{ matrix.eslint == 8 }}
run: npm run validate

- name: ▶️ Ensure docs are up-to-date
if: ${{ matrix.eslint == 8 && matrix.node == 16 }}
run: npm run lint:generate-readme-table

- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v3

Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,27 @@ module.exports = {

## Supported Rules

👍 indicates that a rule is recommended for all users.

🔧 indicates that a rule is fixable.

<!-- __BEGIN AUTOGENERATED TABLE__ -->

| Name | 👍 | 🔧 | Description |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | --------------------------------------------------------------------- |
| [prefer-checked](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-checked.md) | 👍 | 🔧 | prefer toBeChecked over checking attributes |
| [prefer-empty](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-empty.md) | 👍 | 🔧 | Prefer toBeEmpty over checking innerHTML |
| [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 |
| [prefer-focus](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-focus.md) | 👍 | 🔧 | prefer toHaveFocus over checking document.activeElement |
| [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 |
| [prefer-required](https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-required.md) | 👍 | 🔧 | prefer toBeRequired over checking properties |
| [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 |
| [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 |
| [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 |
| [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 |
| [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 |

<!-- __END AUTOGENERATED TABLE__ -->
<!-- begin auto-generated rules list -->

💼 Configurations enabled in.\
✅ Set in the `recommended` configuration.\
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).

| Name                        | Description | 💼 | 🔧 |
| :----------------------------------------------------------------------- | :-------------------------------------------------------------------- | :- | :- |
| [prefer-checked](docs/rules/prefer-checked.md) | prefer toBeChecked over checking attributes || 🔧 |
| [prefer-empty](docs/rules/prefer-empty.md) | Prefer toBeEmpty over checking innerHTML || 🔧 |
| [prefer-enabled-disabled](docs/rules/prefer-enabled-disabled.md) | prefer toBeDisabled or toBeEnabled over checking attributes || 🔧 |
| [prefer-focus](docs/rules/prefer-focus.md) | prefer toHaveFocus over checking document.activeElement || 🔧 |
| [prefer-in-document](docs/rules/prefer-in-document.md) | Prefer .toBeInTheDocument() for asserting the existence of a DOM node || 🔧 |
| [prefer-required](docs/rules/prefer-required.md) | prefer toBeRequired over checking properties || 🔧 |
| [prefer-to-have-attribute](docs/rules/prefer-to-have-attribute.md) | prefer toHaveAttribute over checking getAttribute/hasAttribute || 🔧 |
| [prefer-to-have-class](docs/rules/prefer-to-have-class.md) | prefer toHaveClass over checking element className || 🔧 |
| [prefer-to-have-style](docs/rules/prefer-to-have-style.md) | prefer toHaveStyle over checking element style || 🔧 |
| [prefer-to-have-text-content](docs/rules/prefer-to-have-text-content.md) | Prefer toHaveTextContent over checking element.textContent || 🔧 |
| [prefer-to-have-value](docs/rules/prefer-to-have-value.md) | prefer toHaveValue over checking element.value || 🔧 |

<!-- end auto-generated rules list -->

## Issues

Expand Down Expand Up @@ -196,7 +196,6 @@ MIT
[coc]: https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/other/CODE_OF_CONDUCT.md
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
[all-contributors]: https://github.com/all-contributors/all-contributors
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/eslint-plugin-jest-dom?color=orange&style=flat-square
[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
[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
[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
Expand Down
55 changes: 0 additions & 55 deletions build/generate-readme-table.js

This file was deleted.

8 changes: 7 additions & 1 deletion docs/rules/prefer-checked.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toBeChecked() or not.toBeChecked() over toHaveProperty('checked', true|false) (prefer-enabled-checked)
# Prefer toBeChecked over checking attributes (`jest-dom/prefer-checked`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-empty.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Prefer toBeEmptyDOMElement over checking innerHTML / firstChild (prefer-empty)
# Prefer toBeEmpty over checking innerHTML (`jest-dom/prefer-empty`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

This rule ensures people will use toBeEmptyDOMElement() rather than checking dom
nodes/properties. It is primarily aimed at consistently using jest-dom for
Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-enabled-disabled.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toBeDisabled() or toBeEnabled() over toHaveProperty('disabled', true|false) (prefer-enabled-disabled)
# Prefer toBeDisabled or toBeEnabled over checking attributes (`jest-dom/prefer-enabled-disabled`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-focus.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer-focus
# Prefer toHaveFocus over checking document.activeElement (`jest-dom/prefer-focus`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

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

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-in-document.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Prefer .toBeInTheDocument in favor of .toHaveLength(1) (prefer-in-document)
# Prefer .toBeInTheDocument() for asserting the existence of a DOM node (`jest-dom/prefer-in-document`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-required.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toBeRequired() or not.toBeRequired() over toHaveProperty('required', true|false) (prefer-required)
# Prefer toBeRequired over checking properties (`jest-dom/prefer-required`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-to-have-attribute.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toHaveAttribute over checking getAttribute/hasAttribute (prefer-to-have-attribute)
# Prefer toHaveAttribute over checking getAttribute/hasAttribute (`jest-dom/prefer-to-have-attribute`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

This rule is an autofixable rule that reports usages of `getAttribute` or
`hasAttribute` in expect statements in preference of using the jest-dom
Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-to-have-class.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toHaveClass over checking element.class (prefer-to-have-class)
# Prefer toHaveClass over checking element className (`jest-dom/prefer-to-have-class`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

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
`toHaveClass` matcher.
Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-to-have-style.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toHaveStyle over checking element.style (prefer-to-have-style)
# Prefer toHaveStyle over checking element style (`jest-dom/prefer-to-have-style`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

This rule is an autofixable rule that reports usages of checking element.style in expect statements in preference of using the jest-dom
`toHaveStyle` matcher.
Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-to-have-text-content.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Prefer toHaveTextContent over checking element.textContent (prefer-to-have-text-content)
# Prefer toHaveTextContent over checking element.textContent (`jest-dom/prefer-to-have-text-content`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

Please describe the origin of the rule here.

Expand Down
8 changes: 7 additions & 1 deletion docs/rules/prefer-to-have-value.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# prefer toHaveAttribute over checking getAttribute/hasAttribute (prefer-to-have-attribute)
# Prefer toHaveValue over checking element.value (`jest-dom/prefer-to-have-value`)

💼 This rule is enabled in the ✅ `recommended` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

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

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
],
"scripts": {
"build": "kcd-scripts build",
"pregenerate-readme-table": "yarn build",
"generate-readme-table": "node build/generate-readme-table.js",
"pregenerate-readme-table": "npm run build",
"generate-readme-table": "eslint-doc-generator --ignore-config all",
"lint": "kcd-scripts lint",
"lint:generate-readme-table": "npm run generate-readme-table -- --check",
"setup": "npm install && npm run validate -s",
"test": "kcd-scripts test",
"test:coverage": "npm test -- --coverage",
Expand All @@ -47,6 +48,7 @@
"devDependencies": {
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.7.0",
"eslint-doc-generator": "^0.19.0",
"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "^0.0.7",
"kcd-scripts": "^12.0.0",
Expand Down

0 comments on commit 4299024

Please sign in to comment.