Skip to content

refactor: rework rule docs scripts #694

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

Merged
merged 7 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## Checks

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

## Changes

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Check format
run: npm run format:check

- name: Check autogenerated docs
run: npm run docs:gen && git diff --exit-code

tests:
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
runs-on: ubuntu-latest
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"scripts": {
"build": "tsc",
"postbuild": "cpy README.md ./dist && cpy package.json ./dist && cpy LICENSE ./dist",
"format": "prettier --write .",
"format:check": "prettier --check .",
"generate": "npm-run-all \"generate:*\"",
"generate:configs": "ts-node tools/generate-configs && npm run format",
"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",
"lint": "npm-run-all \"lint:*\"",
"lint:generate": "npm run generate && git diff --exit-code",
"lint:js": "eslint . --max-warnings 0 --ext .js,.ts",
"lint:js:fix": "npm run lint:js -- --fix",
"prettier-base": "prettier . --ignore-unknown --cache --loglevel warn",
"format": "npm run prettier-base -- --write",
"format:check": "npm run prettier-base -- --check",
"lint": "eslint . --max-warnings 0 --ext .js,.ts",
"lint:fix": "npm run lint -- --fix",
"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/",
"docs:gen": "npm-run-all \"docs:gen:*\"",
"docs:gen:configs": "ts-node tools/generate-configs && npm run format",
"docs:gen:rules-list": "npm run build && npm run rule-doc-generator && npm run format",
"prepare": "is-ci || husky install",
"semantic-release": "semantic-release",
"test": "jest",
Expand Down
16 changes: 2 additions & 14 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { exec } from 'child_process';
import { existsSync } from 'fs';
import { resolve } from 'path';
import util from 'util';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path';

import plugin from '../lib';

const execAsync = util.promisify(exec);
const generateConfigs = () => execAsync(`npm run generate:configs`);

const numberOfRules = 27;
const ruleNames = Object.keys(plugin.rules);

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

it("should have run 'generate:configs' script when changing config rules", async () => {
await generateConfigs();

const allConfigs = plugin.configs;
expect(allConfigs).toMatchSnapshot();
}, 20000);

it('should export configs that refer to actual rules', () => {
const allConfigs = plugin.configs;

Expand Down