mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
Wires JavaScript linting into the project for the first time, scoped to the Playwright specs and persona helpers under `roles/**/files/**/*.js`. Setup ----- - `package.json` + `package-lock.json` pin eslint v9, eslint-plugin- playwright v2, @eslint/js, globals. - `eslint.config.js` (flat config) loads `eslint:recommended` and `playwright/flat/recommended`. Browser globals are injected so `page.evaluate(() => window.foo)` callbacks lint cleanly. Project- idiomatic patterns are explicitly turned off with rationale: the service-gating contract (req 006/019) uses test.skip on disabled services; persona helpers branch on isVisible/isServiceEnabled before expect; some specs deliberately use waitForTimeout / networkidle for OIDC settle. `no-empty` allows the empty-catch idiom; the autofixer for `prefer-web-first-assertions` and `no-wait-for-navigation` is unsafe in this codebase (broken diff in dashboard.js), so both are off pending a hand-migration pass. - `scripts/lint/javascript.sh` mirrors the markdown.sh shape (skip on missing, exit 127 with "make install-lint" hint). - `scripts/lint/autoformat.sh` gets a `run_eslint` worker (treats rc≤1 as OK, like markdownlint). - `scripts/install/lint.sh` gets `ensure_eslint` (npm-local install in the repo root, matching the markdownlint pattern), a `javascript` group, and `install_javascript_tools` is wired into the `all` group. - `Makefile` exposes `lint-javascript` and folds it into the aggregate `lint` target. - `.github/workflows/lint-javascript.yml` follows the lint-makefile.yml shape (Node 20, npm cache, `npm ci`, `make lint-javascript`); the ci-orchestrator wires it into the lint pipeline + lint-gate `needs:`. - `.gitignore` adds `node_modules/`. Real lint findings fixed in this commit --------------------------------------- - `roles/web-app-decidim/files/playwright.spec.js` was using `runBiberFlow` / `runAdminFlow` without ever requiring `./personas` (would have failed at runtime). Adds the require. - Same file: two nutzlose `\\'csrf-token\\'` escapes in a double-quoted query selector — eslint flagged, fixed. - `roles/web-app-moodle/files/playwright.spec.js`: `expect(await locator.count()).toBe(0)` → `await expect(locator).toHaveCount(0)` (Playwright auto-retrying assertion; safe `prefer-to-have-count` autofix). Lint baseline: 0 errors, 285 warnings (mostly `no-unused-vars` and `playwright/expect-expect` — addressable as follow-up cleanup, not blocking). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
506 B
Bash
Executable File
20 lines
506 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
#
|
|
# Run ESLint against the project's JavaScript files (Playwright specs +
|
|
# persona helpers). Config: eslint.config.js at the repo root.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
if [[ ! -d "node_modules/eslint" ]]; then
|
|
echo "ESLint not installed. Run 'make install-lint' first." >&2
|
|
exit 127
|
|
fi
|
|
|
|
npx --no-install eslint 'roles/**/files/**/*.js'
|