From 55bfdc8d9a046f8a6963f55cf390a0fdb5214e8a Mon Sep 17 00:00:00 2001 From: Martin Bohal Date: Fri, 13 Nov 2026 09:35:03 +0100 Subject: [PATCH] Rename npm scripts to `lint:*` and `test:*` * Linters run as `lint:eslint`, `lint:stylelint`, `lint:markdownlint` and `lint:types`. * Playwright runs as `test:playwright` * `test` is removed --- .claude/agents/code-reviewer.md | 11 ++++--- .claude/rules/docs.md | 2 +- .claude/rules/frontend.md | 4 +-- .claude/rules/styling.md | 2 +- .claude/rules/testing.md | 9 +++--- .claude/settings.json | 15 +++------ .claude/skills/commit/SKILL.md | 2 +- .github/workflows/playwright.yml | 2 +- .github/workflows/release-management.yml | 2 +- .github/workflows/test.yml | 2 +- CLAUDE.md | 38 ++++++++++++++--------- eslint.config.mjs | 2 ++ package.json | 16 +++++----- src/docs/contribute/testing-guidelines.md | 29 ++++++++++------- 14 files changed, 75 insertions(+), 61 deletions(-) diff --git a/.claude/agents/code-reviewer.md b/.claude/agents/code-reviewer.md index 45c274749..5ab526596 100644 --- a/.claude/agents/code-reviewer.md +++ b/.claude/agents/code-reviewer.md @@ -86,9 +86,12 @@ rules in section 6 are the easiest to miss — do not skip them. Easy-to-miss invariants beyond the generic checks above: -* **Lint gate** ([CLAUDE.md](../../CLAUDE.md#commands)): `npm run lint` = - eslint + markdownlint + stylelint. It is not auto-run — remind the author to - run `npm run lint`, `npm run test:jest`, and `npm run test:playwright-ct:all`. +* **CI gate** ([CLAUDE.md](../../CLAUDE.md#commands)): CI runs `lint`, + `test:jest` and `test:playwright` + ([.github/workflows/](../../.github/workflows/)). `npm run lint` covers + `lint:eslint`, `lint:stylelint`, `lint:markdownlint` and `lint:types`; the + tests run separately. `npm run lint:eslint` covers `src` and `tests`. + Remind the author to run them. * **Component layout** ([frontend.md](../rules/frontend.md)): every component folder has the `.tsx` + `.types.ts` + `index.ts` barrel + `*.module.scss` + `_settings`/ `_theme`/`_tools` SCSS partials + `README.md` + `__tests__/`. Props are @@ -117,7 +120,7 @@ Group findings by severity. For each: - [design] src/components/Foo/Foo.tsx:7 (frontend.md) — ref not forwarded to root element. ## Reminders -- Run `npm run lint`, `npm run test:jest`, and `npm run test:playwright-ct:all` before committing. +- Run `npm run lint`, `npm run test:jest` and `npm run test:playwright`. ``` End with a one-line verdict: APPROVE / APPROVE WITH NITS / REQUEST CHANGES. diff --git a/.claude/rules/docs.md b/.claude/rules/docs.md index 33cf24f02..82cf757f9 100644 --- a/.claude/rules/docs.md +++ b/.claude/rules/docs.md @@ -10,7 +10,7 @@ paths: ## Commands -* Run `npm run markdownlint` after changes (add `-- --fix` to autofix). +* Run `npm run lint:markdownlint` after changes (add `-- --fix` to autofix). * Run `mkdocs build` and `mkdocs serve` to build and serve the documentation * To verify a rendered component or the docs previews in a real browser (navigate, click, screenshot, inspect the running docs site), drive host diff --git a/.claude/rules/frontend.md b/.claude/rules/frontend.md index 5921a1ba5..7c1ff0788 100644 --- a/.claude/rules/frontend.md +++ b/.claude/rules/frontend.md @@ -9,8 +9,8 @@ paths: ## Commands * If dependencies change, run `npm ci`. -* Run `npm run eslint` after changes (add `-- --fix` to autofix) and - `npm run typecheck` (`tsc --noEmit`). +* Run `npm run lint:eslint` after changes (add `-- --fix` to autofix) and + `npm run lint:types` (`tsc --noEmit`). * To verify a rendered component or the docs previews in a real browser (navigate, click, screenshot, inspect the running docs site), drive host Chrome through the `chrome-host` MCP. See diff --git a/.claude/rules/styling.md b/.claude/rules/styling.md index 70e7ef312..85af665f0 100644 --- a/.claude/rules/styling.md +++ b/.claude/rules/styling.md @@ -8,7 +8,7 @@ paths: ## Commands -Run `npm run stylelint` after changes (add `-- --fix` to autofix). +Run `npm run lint:stylelint` after changes (add `-- --fix` to autofix). ## Styling diff --git a/.claude/rules/testing.md b/.claude/rules/testing.md index 67bf14f5a..b91b4c266 100644 --- a/.claude/rules/testing.md +++ b/.claude/rules/testing.md @@ -12,10 +12,11 @@ paths: * Run all Jest unit tests with `npm run test:jest`. For a single file: `npm run test:jest -- `. -* Run all Playwright component tests with `npm run test:playwright-ct:all`; for - one component, `npm run test:playwright-ct:all -- -- src/components/Button`. -* Update Playwright snapshots with `npm run test:playwright-ct:all-with-update`. -* Serve the report with `npm run test:playwright-ct:show-report`. +* Run all Playwright component tests with `npm run test:playwright`; for one + component, `npm run test:playwright -- src/components/Button`. +* Update Playwright snapshots with + `npm run test:playwright -- [] --update-snapshots`. +* Serve the report with `npm run test:playwright:report`. ## Testing diff --git a/.claude/settings.json b/.claude/settings.json index 2c777935f..f8c83f7dd 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -10,16 +10,11 @@ "Bash(npm audit)", "Bash(npm audit signatures)", "Bash(npm ci)", - "Bash(npm run build:*)", - "Bash(npm run lint)", - "Bash(npm run eslint:*)", - "Bash(npm run stylelint:*)", - "Bash(npm run markdownlint:*)", - "Bash(npm start)", - "Bash(npm run start:*)", - "Bash(npm test)", - "Bash(npm run test:jest:*)", - "Bash(npm run test:playwright-ct:*)" + "Bash(npm run build*)", + "Bash(npm run lint*)", + "Bash(npm run start*)", + "Bash(npm run test*)", + "Bash(npm start*)" ] }, "attribution": { diff --git a/.claude/skills/commit/SKILL.md b/.claude/skills/commit/SKILL.md index a2d48953a..0fcb79921 100644 --- a/.claude/skills/commit/SKILL.md +++ b/.claude/skills/commit/SKILL.md @@ -42,7 +42,7 @@ Before committing, check the following (see [Commands](../../../CLAUDE.md#comman * `mkdocs build` passes * `npm run lint` passes * `npm run test:jest` passes -* `npm run test:playwright-ct:all` passes +* `npm run test:playwright` passes Write a commit message for the staged changes following the project's git conventions ([General Guidelines › Git Workflow](../../../src/docs/contribute/general-guidelines.md#git-workflow)): diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 444056203..87e6fb3b4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -32,7 +32,7 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests and generate test report - run: npm run test:playwright-ct:all + run: npm run test:playwright - name: Install Playwright Browsers run: npx playwright install --with-deps diff --git a/.github/workflows/release-management.yml b/.github/workflows/release-management.yml index 30579a95b..8756e626a 100644 --- a/.github/workflows/release-management.yml +++ b/.github/workflows/release-management.yml @@ -32,7 +32,7 @@ jobs: run: npm run lint - name: Test - run: npm test + run: npm run test:jest - name: Build run: npm run build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11c8f3b9c..4639c9797 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: run: npm ci - name: Test and generate code coverage info - run: npm test + run: npm run test:jest - name: Upload code coverage info to Coveralls uses: coverallsapp/github-action@v2 diff --git a/CLAUDE.md b/CLAUDE.md index 8cd759178..948ac5f16 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,24 +23,32 @@ Run these inside the `devcontainer` (from the host, prefix with `docker compose exec -T devcontainer`). For details, see the [Contributing Guide](src/docs/contribute/general-guidelines.md). -| Task | Command | -|-----------------------------------|---------------------------------------------------------------------| -| Install JS | `npm ci` | -| Build library | `npm run build` | -| Build type declarations only | `npm run build:types` | -| Run static checks | `npm run lint` | -| Run type check | `npm run typecheck` | -| Run unit tests | `npm run test:jest` | -| Run a single unit test file | `npm run test:jest -- ` | -| Run component tests | `npm run test:playwright-ct:all` | -| Component tests for one component | `npm run test:playwright-ct:all -- -- src/components/Button` | -| Update component snapshots | `npm run test:playwright-ct:all-with-update` | -| Start build watcher | `npm start` | -| Build documentation | `mkdocs build` | -| Serve documentation | `mkdocs serve` | +| Task | Command | +|-----------------------------------|----------------------------------------------------------| +| Install JS | `npm ci` | +| Build library | `npm run build` | +| Build type declarations only | `npm run build:types` | +| Run static checks (incl. types) | `npm run lint` | +| Run ESLint | `npm run lint:eslint` | +| Run Stylelint | `npm run lint:stylelint` | +| Run Markdownlint | `npm run lint:markdownlint` | +| Run type check | `npm run lint:types` | +| Run unit tests | `npm run test:jest` | +| Run a single unit test file | `npm run test:jest -- ` | +| Run component tests | `npm run test:playwright` | +| Component tests for one component | `npm run test:playwright -- src/components/Button` | +| Update component snapshots | `npm run test:playwright -- [] --update-snapshots` | +| Start build watcher | `npm start` | +| Build documentation | `mkdocs build` | +| Serve documentation | `mkdocs serve` | Notes: +* `npm run lint` runs all linters (ESLint, Stylelint, Markdownlint, type check). + There is no `npm test` script. +* `npm run lint:eslint` lints `src` and `tests`. +* The lint / Jest / Playwright commands are the same gates CI runs + ([.github/workflows/](.github/workflows/)). * Commands like `npm`, `playwright` run in specific Docker containers. Normally, when you run those commands, they are executed within dedicated containers. If you need to communicate directly with specific Docker container, diff --git a/eslint.config.mjs b/eslint.config.mjs index 85930b3c5..768c94df8 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,6 +6,8 @@ import { export default defineConfig([ globalIgnores(['**/*.js']), + // Only these directories are linted, so `eslint` can be run without a path + globalIgnores(['*', '!src/', '!tests/'], 'app/lint-scope'), ...configs.base.recommended, ...configs.react.recommended, ...configs.base.typescript, diff --git a/package.json b/package.json index 47d45c913..bd03e887c 100644 --- a/package.json +++ b/package.json @@ -64,22 +64,20 @@ "copy": "npm run copy:css && npm run copy:js", "copy:css": "cp src/docs/_assets/generated/react-ui.css dist && cp src/docs/_assets/generated/react-ui.development.css dist", "copy:js": "cp src/docs/_assets/generated/react-ui.js dist && cp src/docs/_assets/generated/react-ui.development.js dist", - "eslint": "eslint src tests", - "lint": "npm run eslint && npm run markdownlint && npm run stylelint && npm run typecheck", - "markdownlint": "markdownlint-cli2 \"README.md\" \"src/**/*.md\"", + "lint": "npm run lint:stylelint && npm run lint:eslint && npm run lint:types && npm run lint:markdownlint", + "lint:eslint": "eslint", + "lint:markdownlint": "markdownlint-cli2 \"README.md\" \"src/**/*.md\"", + "lint:stylelint": "stylelint \"src/**/*.{css,scss}\" \"!src/docs/_assets/generated/**\" --config stylelint.config.mjs", + "lint:types": "node node_modules/@typescript/native/bin/tsc --noEmit", "postbuild": "npm run copy && npm run build:types", "postinstall": "sh scripts/write-lockfile-hash.sh", "precopy": "rm -rf dist && mkdir dist", "prepublishOnly": "npm run build", "start": "webpack --watch --mode=development", "start:chrome": "sh scripts/mcps/chrome-host/start-host-chrome.sh", - "stylelint": "stylelint \"src/**/*.{css,scss}\" \"!src/docs/_assets/generated/**\" --config stylelint.config.mjs", - "test": "npm run test:jest", "test:jest": "jest --coverage", - "test:playwright-ct:all": "playwright test -c playwright-ct.config.ts", - "test:playwright-ct:all-with-update": "playwright test -c playwright-ct.config.ts --update-snapshots", - "test:playwright-ct:show-report": "playwright show-report --host=0.0.0.0 --port=9323", - "typecheck": "node node_modules/@typescript/native/bin/tsc --noEmit" + "test:playwright": "playwright test -c playwright-ct.config.ts", + "test:playwright:report": "playwright show-report --host=0.0.0.0" }, "dependencies": { "normalize.css": "^8.0.1" diff --git a/src/docs/contribute/testing-guidelines.md b/src/docs/contribute/testing-guidelines.md index 88c1b3010..61888897a 100644 --- a/src/docs/contribute/testing-guidelines.md +++ b/src/docs/contribute/testing-guidelines.md @@ -8,7 +8,7 @@ Tools used to test the application: * **Jest** (unit tests) * **Playwright** (visual and functional component testing) -Generally, `npm test` and `npm run test:playwright-ct:all` should be run within +Generally, `npm run test:jest` and `npm run test:playwright` should be run within their designated Docker containers before pushing changes to the repository. ## Tools @@ -16,10 +16,10 @@ their designated Docker containers before pushing changes to the repository. You can run all tests with a single command: ```bash -npm run lint && npm test && npm run test:playwright-ct:all +npm run lint && npm run test:jest && npm run test:playwright ``` -### Linters (ESLint, Markdownlint, Stylelint) +### Linters (ESLint, Markdownlint, Stylelint, TypeScript) Run linters either all together: @@ -30,7 +30,7 @@ npm run lint or run linters individually: ```bash -npm run +npm run lint: ``` ### Jest @@ -39,6 +39,12 @@ npm run npm run test:jest ``` +Run a single test file: + +```bash +npm run test:jest -- +``` + ### Playwright #### Configuration @@ -47,22 +53,23 @@ Test parameters can be tweaked by creating and tweaking `.env` file. #### Running Tests -Run tests: +Run all component tests: ```bash -npm run test:playwright-ct: +npm run test:playwright ``` -You can also run specific tests by passing a path to the test files: +You can also run specific tests by passing a path, or pass any +[Playwright CLI argument][playwright-cli] to the test runner: ```bash -npm run test:playwright-ct: -- -- +npm run test:playwright -- ``` -You can also pass any [CLI command][playwright-cli] to the test runner: +Update snapshots by adding `--update-snapshots`, optionally limited to a path: ```bash -npm run test:playwright-ct: -- -- +npm run test:playwright -- [] --update-snapshots ``` #### Writing Tests @@ -212,7 +219,7 @@ After running Playwright tests, test report can be served by using the following command: ```bash -npm run test:playwright-ct:show-report +npm run test:playwright:report ``` Then open the displayed URL (typically `http://localhost:9323`)