Skip to content

web: enforce lint, prettier, complexity and import rules in CI and pre-commit - #186

Closed
oly-agents[bot] wants to merge 1 commit into
mainfrom
web/ci-guardrails
Closed

oly-agents[bot] wants to merge 1 commit into
mainfrom
web/ci-guardrails

Conversation

@oly-agents

@oly-agents oly-agents Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This change adds CI guardrails to the Next.js UI in web/. It closes gauge-repo audit items 10, 11, 13, 21, 22 and 33.

Changes and audit items

Audit item Change Files
10, 11: lint and format in CI build.sh --test runs pnpm lint --max-warnings=0 and pnpm prettier-check before pnpm test. If one of them fails, the build stops with exit code 1. build.sh
13: pre-commit hook husky and lint-staged. The prepare script (cd .. && husky web/.husky) sets core.hooksPath=web/.husky/_ when you run pnpm install. The hook runs eslint --fix --max-warnings=0 and prettier --write on staged web/ files, then adds the fixes to the commit. If there is no .git (the Docker build), husky prints .git can't be found and the install continues. web/package.json, web/.husky/pre-commit, web/pnpm-lock.yaml
21: complexity ceiling ESLint complexity is set to error at 41. web/eslint.config.mjs
22: import boundaries no-restricted-imports for src/components/** and src/common/**. It blocks @/modules, @/modules/* and relative ../modules paths. web/eslint.config.mjs
33: structured test output Vitest reporters: default, junit (writes web/test-results/junit.xml), and github-actions when GITHUB_ACTIONS=true. web/vitest.config.mts, web/.gitignore, .dockerignore
Docs The README and AGENTS.md tell how the hook is turned on, how to skip it, and what the new lint rules do. web/README.md, web/AGENTS.md

Commitlint and PR-title checks are not in this PR. They moved to a backend task.

Measured complexity value

I ran ESLint with complexity: ['warn', 1] on all of web/ and sorted the results. The highest values today are:

Complexity Function
41 src/modules/Jobs/JobDetails/JobInformationPane.tsx:27
27 src/modules/Commands/CommandDetails/CommandInformationPane.tsx:21
25 src/modules/Clusters/ClustersDetails/ClusterInformationPane.tsx:18
25 src/modules/Jobs/Jobs.tsx:37

The limit is 41. I tested it: a function with complexity 42 fails lint, and a function with complexity 41 passes.

Import boundary violations

There was one violation: src/components/ListPage/ListPage.test.tsx imported CLUSTER_COLUMNS and toClusterRows from @/modules/Clusters/Helper. I fixed it. The test now makes the same 7 columns and rows itself, from the shared clusters fixture and RowActionButton. The snapshot file did not change. Production code had no violations.

Lockfile note

@patterninc/pattern-ui uses the specifier latest. A normal pnpm add moves it to a newer build. That changes rendered UI, so it is out of scope. I kept the locked version (0.0.0-main.202610271737.65d5c2ce3a27). The lockfile only adds husky, lint-staged and their dependencies (string-argv, tinyexec, yaml). pnpm install --frozen-lockfile passes.

Verification

All commands ran on this branch, with Node 26.13.1, pnpm 12.15.0 and Go 1.27.3.

Check Result
pnpm lint --max-warnings=0 Pass, 0 problems
pnpm prettier-check and pnpm format Pass
pnpm type-check Pass
pnpm test (with coverage) Pass: 21 files, 108 tests. Coverage: statements 89.02%, branches 86.75%, functions 88.75%, lines 90.51%
GITHUB_ACTIONS=true pnpm vitest run with a failing test Writes a ::error file=... annotation. Without GITHUB_ACTIONS, it writes no annotation.
test-results/junit.xml Written: tests="108" failures="0"
./build.sh --go --ui --test Pass, exit code 0 (Go tests, lint, prettier, web tests, Go build and next build)
./build.sh --test with a file that has a Prettier problem Fail, exit code 1, at prettier-check. The tests did not run.
./build.sh --test with a file that has a lint warning Fail, exit code 1, at lint. The tests did not run.
Pre-commit hook, badly formatted file The commit passed, and the file in the commit was formatted
Pre-commit hook, a components/ file that imports @/modules/... The commit stopped with the no-restricted-imports error
pnpm install --frozen-lockfile with no .git (as in the Docker build) Pass. Husky prints .git can't be found.

The first local run of ./build.sh --go --ui --test failed at the end of next build with SecurityFatalError: Your version of Next.js is affected by a known security vulnerability. Next.js 16.4.3 shows this message one time when it finds an AI agent in the environment (CLAUDECODE or AI_AGENT). A second run within 5 minutes passes (node_modules/next/dist/lib/upgrade/nudge.js, allowNudgeRetry). CI does not set these variables, so this PR does not change CI. The message recommends an upgrade of Next.js. That is out of scope for this PR, so it is a follow-up.

Checklist

  • patterninc/heimdall: changes in web/ and build.sh. Done.
  • Chromatic link: not needed. This repo has no Pattern UI package (lib/pattern-ui), and this PR does not change rendered UI. pnpm --filter pattern-ui chromatic gives No projects matched the filters in "/workspace/repos/heimdall/web".

Chromatic link

Not needed (see the checklist).

Screenshots

No screenshots attached. This PR does not change rendered UI.

Follow-ups

  • Upgrade Next.js 16.4.3. next build reports a known security vulnerability (see Verification).
  • Decrease complexity when someone splits JobInformationPane (41). The next highest value is 27.
  • If CI must show the JUnit results, add an upload step to .github/workflows/build.yml. This PR does not change workflow files.

🤖 Generated with Claude Code

…e-commit

- build.sh --test runs pnpm lint --max-warnings=0 and pnpm prettier-check
  before the web tests; either failure fails the build.
- husky + lint-staged pre-commit hook for staged web/ files, installed by
  pnpm install through the prepare script.
- ESLint complexity rule at 41 (today's maximum, JobInformationPane).
- no-restricted-imports stops src/components and src/common from importing
  src/modules; the ListPage snapshot test now builds its own table data.
- Vitest reporters: default, junit (test-results/junit.xml) and
  github-actions when GITHUB_ACTIONS=true.

ClickUp: https://app.clickup.com/t/1dfq9k64t00

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Gaurav Warale <gaurav.warale@pattern.com>
@argus-pattern

argus-pattern Bot commented Nov 30, 2026

Copy link
Copy Markdown

👀 Reviewing 2d6537c.

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Argus reviewed head 2d6537c against the ClickUp task and the implementation prompt (audit items 10, 11, 13, 21, 22 and 33). I found no problems.

What I checked:

  • build.sh --test: set -ex stops the build when pnpm lint --max-warnings=0 or pnpm prettier-check fails. Both run after install_web_deps and before pnpm test. CI runs build.sh on the runner, so GITHUB_ACTIONS=true reaches Vitest.
  • Pre-commit hook: pnpm install set core.hooksPath=web/.husky/_. In a scratch commit, the hook formatted a staged web/src file, and it left a staged root README.md alone (lint-staged found no matching files). In the Docker build, prepare finds no .git, prints a message and exits 0.
  • Complexity: eslint --rule "complexity: [error, 40]" fails only on JobInformationPane.tsx:27 (41), so the measured value of 41 is correct.
  • Import boundary: in a probe file under src/common/, the rule caught @/modules/..., @/modules (also as import type) and ../../modules/.... No file in src/components or src/common breaks the rule now. The rewritten ListPage test leaves the snapshot unchanged.
  • Vitest reporters: pnpm test passes (21 files, 108 tests, coverage above the thresholds) and writes test-results/junit.xml. Git and Docker ignore that folder.
  • pnpm lint --max-warnings=0 and pnpm prettier-check pass on Node 26.13.1 and pnpm 12.15.0. Nothing is out of scope, and commitlint is left out as the task says.

@argus-pattern

argus-pattern Bot commented Dec 1, 2026

Copy link
Copy Markdown

👀 Reviewing 2d6537c.

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Argus follow-up for head 2d6537c. The head is the same commit as in my last review (2d6537c), so there are no new commits to review.

Earlier Argus comments: none. My last review had no findings, so there are no earlier comments to check.

What changed since the last review: main got #192 (Next.js 16.4.3 → 16.4.6), which changes web/package.json, web/pnpm-lock.yaml and web/next.config.ts. This PR also changes the first two files. I merged origin/main into this head locally. Git merged it with no conflicts. On the merged tree (Node 26.13.1, pnpm 12.15.0), these all pass:

  • pnpm install --frozen-lockfile
  • pnpm lint --max-warnings=0
  • pnpm prettier-check
  • pnpm test (21 files, 108 tests)

#192 also covers the PR's "Upgrade Next.js" follow-up. When you update the branch, you can remove that item from the PR body.

CI on this head: build and all Wiz scanners pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant