Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate docs with eslint-doc-generator #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 24 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ jobs:
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn
# TODO: Use --ignore-engines so we can install dev-dependencies which don't support Node 12. Remove this option after we drop Node 12 support.
- run: yarn install --frozen-lockfile --ignore-engines

- run:
name: Run tests
command: yarn test

- run: yarn lint

- save_cache:
paths:
- node_modules
Expand All @@ -37,6 +36,28 @@ jobs:
- persist_to_workspace:
root: ~/repo
paths: .

lint:
working_directory: ~/repo
docker:
## Linting should run on the latest Node.
- image: circleci/node:18
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

# TODO: Use --ignore-engines so we can install dev-dependencies which don't support Node 12. Remove this option after we drop Node 12 support.
- run: yarn install --frozen-lockfile --ignore-engines

- run:
name: Run lint
command: yarn lint

deploy:
<<: *defaults
steps:
Expand Down
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ This project aims to provide formatting rules (auto-fixable where possible) to e

Like this plugin? [Say thanks with a ⭐️](https://github.com/dangreenisrael/eslint-plugin-jest-formatting/stargazers)

**_Note: The master version may not be the version deployed to npm. Please treat https://www.npmjs.com/package/eslint-plugin-jest-formatting as the cannonical source for docs._**
**_Note: The master version may not be the version deployed to npm. Please treat <https://www.npmjs.com/package/eslint-plugin-jest-formatting> as the cannonical source for docs._**

## Installation

You'll first need to install [ESLint](http://eslint.org):

```
$ yarn add eslint --dev
```sh
yarn add eslint --dev
```

Next, install `eslint-plugin-jest-formatting`:

```
$ yarn add eslint-plugin-jest-formatting --dev
```sh
yarn add eslint-plugin-jest-formatting --dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-jest-formatting` globally.
Expand Down Expand Up @@ -68,19 +68,30 @@ We also support a "strict" settings which enabled all of the rules for you

## Rule Documentation

- [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md)
- [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md)
- [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md)
- [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md)
- [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md)
- [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md)
- [padding-around-test-blocks](docs/rules/padding-around-test-blocks.md)
- [padding-around-all](docs/rules/padding-around-all.md)
<!-- begin auto-generated rules list -->

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

| Name | 💼 | 🔧 |
| :----------------------------------------------------------------------------------- | :-- | :-- |
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | ✅ | 🔧 |
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | ✅ | 🔧 |
| [padding-around-all](docs/rules/padding-around-all.md) | 🔒 | 🔧 |
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | ✅ | 🔧 |
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | ✅ | 🔧 |
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | ✅ | 🔧 |
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | | 🔧 |
| [padding-around-test-blocks](docs/rules/padding-around-test-blocks.md) | ✅ | 🔧 |

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

## Related Projects

### eslint-plugin-jest

This provides an extensive set of jest eslint rules

https://github.com/jest-community/eslint-plugin-jest
<https://github.com/jest-community/eslint-plugin-jest>
6 changes: 6 additions & 0 deletions docs/rules/padding-around-after-all-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-after-all-blocks

💼 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

This rule enforces a line of padding before _and_ after 1 or more `afterAll` statements.
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-after-each-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-after-each-blocks

💼 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

This rule enforces a line of padding before _and_ after 1 or more `afterEach` statements.
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-all.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-all

💼 This rule is enabled in the 🔒 `strict` 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

This is a meta rule that simply enables all of the following rules:
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-before-all-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-before-all-blocks

💼 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

This rule enforces a line of padding before _and_ after `beforeAll` statements.
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-before-each-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-before-each-blocks

💼 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

This rule enforces a line of padding before _and_ after 1 or more `beforeEach` statements
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-describe-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-describe-blocks

💼 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

This rule enforces a line of padding before _and_ after 1 or more `describe` statements
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/padding-around-expect-groups.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# padding-around-expect-groups

🔧 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

This rule enforces a line of padding before _and_ after 1 or more `expect` statements
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/padding-around-test-blocks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# padding-around-test-blocks

💼 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

This rule enforces a line of padding before _and_ after 1 or more `test`/`it` statements
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"module": "src/index.ts",
"scripts": {
"pretty": "yarn prettier '**/*.*'",
"lint": "yarn build && yarn link-plugin && yarn pretty --check && yarn eslint --ext .ts,.js .",
"lint": "yarn build && yarn link-plugin && yarn pretty --check && yarn eslint --ext .ts,.js . && yarn lint:eslint-docs",
"lint:eslint-docs": "yarn update:eslint-docs && git diff --exit-code",
"format": "yarn build && yarn link-plugin && yarn pretty --write && yarn eslint --fix --ext .ts,.js .",
"build": "tsc",
"test": "yarn build && jest",
"link-plugin": "yarn link && yarn link eslint-plugin-jest-formatting"
"link-plugin": "yarn link && yarn link eslint-plugin-jest-formatting",
"update:eslint-docs": "yarn build && eslint-doc-generator --rule-doc-title-format name && yarn format"
},
"peerDependencies": {
"eslint": ">=0.8.0"
Expand All @@ -38,15 +40,16 @@
"eslint": "^8.2.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-doc-generator": "^1.4.3",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.2.4",
"eslint-plugin-jest-formatting": "file:.",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.3.1",
"prettier": "2.4.1",
"typescript": "^4.4.4",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an autoformattin and I'm ok with it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies were automatically sorted when I ran npm i --save-dev eslint-doc-generator.

"ts-jest": "^27.0.7"
"ts-jest": "^27.0.7",
"typescript": "^4.4.4"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
Expand Down