Skip to content

Commit b1eca80

Browse files
refactor: rework rule docs scripts (testing-library#694)
* refactor: rework rule docs scripts * test: remove unnecessary config test * style: avoid formatting after each gen command * Revert "style: avoid formatting after each gen command" This reverts commit c1bae58. * refactor: remove node prefix imports Co-authored-by: Michaël De Boey <[email protected]> Signed-off-by: Mario Beltrán <[email protected]> * test: remove old snapshot * refactor: avoid format after doc gen Signed-off-by: Mario Beltrán <[email protected]> Co-authored-by: Michaël De Boey <[email protected]>
1 parent c1be0cf commit b1eca80

File tree

5 files changed

+12
-164
lines changed

5 files changed

+12
-164
lines changed

.github/pull_request_template.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## Checks
22

33
- [ ] I have read the [contributing guidelines](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/CONTRIBUTING.md).
4-
- [ ] If some rule is added/updated/removed, I've regenerated the rules list (`npm run generate:rules-list`)
5-
- [ ] If some rule meta info is changed, I've regenerated the plugin shared configs (`npm run generate:configs`)
64

75
## Changes
86

.github/workflows/pipeline.yml

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
- name: Check format
4646
run: npm run format:check
4747

48+
- name: Check autogenerated docs
49+
run: npm run docs:gen && npm run format && git diff --exit-code
50+
4851
tests:
4952
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
5053
runs-on: ubuntu-latest

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
"scripts": {
2929
"build": "tsc",
3030
"postbuild": "cpy README.md ./dist && cpy package.json ./dist && cpy LICENSE ./dist",
31-
"format": "prettier --write .",
32-
"format:check": "prettier --check .",
33-
"generate": "npm-run-all \"generate:*\"",
34-
"generate:configs": "ts-node tools/generate-configs && npm run format",
35-
"generate:rules-list": "npm run build && eslint-doc-generator --path-rule-list \"../README.md\" --path-rule-doc \"../docs/rules/{name}.md\" --url-rule-doc \"docs/rules/{name}.md\" dist/ && npm run format",
36-
"lint": "npm-run-all \"lint:*\"",
37-
"lint:generate": "npm run generate && git diff --exit-code",
38-
"lint:js": "eslint . --max-warnings 0 --ext .js,.ts",
39-
"lint:js:fix": "npm run lint:js -- --fix",
31+
"docs:gen": "run-p \"docs:gen:*\"",
32+
"docs:gen:configs": "ts-node tools/generate-configs",
33+
"docs:gen:rules-list": "npm run build && npm run rule-doc-generator && npm run format",
34+
"format": "npm run prettier-base -- --write",
35+
"format:check": "npm run prettier-base -- --check",
36+
"lint": "eslint . --max-warnings 0 --ext .js,.ts",
37+
"lint:fix": "npm run lint -- --fix",
4038
"prepare": "is-ci || husky install",
39+
"prettier-base": "prettier . --ignore-unknown --cache --loglevel warn",
40+
"rule-doc-generator": "eslint-doc-generator --path-rule-list \"../README.md\" --path-rule-doc \"../docs/rules/{name}.md\" --url-rule-doc \"docs/rules/{name}.md\" dist/",
4141
"semantic-release": "semantic-release",
4242
"test": "jest",
4343
"test:ci": "jest --ci --coverage",

tests/__snapshots__/index.test.ts.snap

-141
This file was deleted.

tests/index.test.ts

-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { exec } from 'child_process';
21
import { existsSync } from 'fs';
32
import { resolve } from 'path';
4-
import util from 'util';
53

64
import plugin from '../lib';
75

8-
const execAsync = util.promisify(exec);
9-
const generateConfigs = () => execAsync(`npm run generate:configs`);
10-
116
const numberOfRules = 27;
127
const ruleNames = Object.keys(plugin.rules);
138

@@ -48,13 +43,6 @@ it('should have the correct amount of rules', () => {
4843
}
4944
});
5045

51-
it("should have run 'generate:configs' script when changing config rules", async () => {
52-
await generateConfigs();
53-
54-
const allConfigs = plugin.configs;
55-
expect(allConfigs).toMatchSnapshot();
56-
}, 20000);
57-
5846
it('should export configs that refer to actual rules', () => {
5947
const allConfigs = plugin.configs;
6048

0 commit comments

Comments
 (0)