Repository navigation
web: enforce lint, prettier, complexity and import rules in CI and pre-commit - #186
oly-agents[bot] wants to merge 1 commit into
Conversation
…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>
|
👀 Reviewing |
There was a problem hiding this comment.
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 -exstops the build whenpnpm lint --max-warnings=0orpnpm prettier-checkfails. Both run afterinstall_web_depsand beforepnpm test. CI runsbuild.shon the runner, soGITHUB_ACTIONS=truereaches Vitest.- Pre-commit hook:
pnpm installsetcore.hooksPath=web/.husky/_. In a scratch commit, the hook formatted a stagedweb/srcfile, and it left a staged rootREADME.mdalone (lint-staged found no matching files). In the Docker build,preparefinds no.git, prints a message and exits 0. - Complexity:
eslint --rule "complexity: [error, 40]"fails only onJobInformationPane.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 asimport type) and../../modules/.... No file insrc/componentsorsrc/commonbreaks the rule now. The rewrittenListPagetest leaves the snapshot unchanged. - Vitest reporters:
pnpm testpasses (21 files, 108 tests, coverage above the thresholds) and writestest-results/junit.xml. Git and Docker ignore that folder. pnpm lint --max-warnings=0andpnpm prettier-checkpass on Node 26.13.1 and pnpm 12.15.0. Nothing is out of scope, and commitlint is left out as the task says.
|
👀 Reviewing |
There was a problem hiding this comment.
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-lockfilepnpm lint --max-warnings=0pnpm prettier-checkpnpm 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.
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
build.sh --testrunspnpm lint --max-warnings=0andpnpm prettier-checkbeforepnpm test. If one of them fails, the build stops with exit code 1.build.shpreparescript (cd .. && husky web/.husky) setscore.hooksPath=web/.husky/_when you runpnpm install. The hook runseslint --fix --max-warnings=0andprettier --writeon stagedweb/files, then adds the fixes to the commit. If there is no.git(the Docker build), husky prints.git can't be foundand the install continues.web/package.json,web/.husky/pre-commit,web/pnpm-lock.yamlcomplexityis set toerrorat 41.web/eslint.config.mjsno-restricted-importsforsrc/components/**andsrc/common/**. It blocks@/modules,@/modules/*and relative../modulespaths.web/eslint.config.mjsdefault,junit(writesweb/test-results/junit.xml), andgithub-actionswhenGITHUB_ACTIONS=true.web/vitest.config.mts,web/.gitignore,.dockerignoreweb/README.md,web/AGENTS.mdCommitlint 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 ofweb/and sorted the results. The highest values today are:src/modules/Jobs/JobDetails/JobInformationPane.tsx:27src/modules/Commands/CommandDetails/CommandInformationPane.tsx:21src/modules/Clusters/ClustersDetails/ClusterInformationPane.tsx:18src/modules/Jobs/Jobs.tsx:37The 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.tsximportedCLUSTER_COLUMNSandtoClusterRowsfrom@/modules/Clusters/Helper. I fixed it. The test now makes the same 7 columns and rows itself, from the sharedclustersfixture andRowActionButton. The snapshot file did not change. Production code had no violations.Lockfile note
@patterninc/pattern-uiuses the specifierlatest. A normalpnpm addmoves 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 addshusky,lint-stagedand their dependencies (string-argv,tinyexec,yaml).pnpm install --frozen-lockfilepasses.Verification
All commands ran on this branch, with Node 26.13.1, pnpm 12.15.0 and Go 1.27.3.
pnpm lint --max-warnings=0pnpm prettier-checkandpnpm formatpnpm type-checkpnpm test(with coverage)GITHUB_ACTIONS=true pnpm vitest runwith a failing test::error file=...annotation. WithoutGITHUB_ACTIONS, it writes no annotation.test-results/junit.xmltests="108" failures="0"./build.sh --go --ui --testnext build)./build.sh --testwith a file that has a Prettier problemprettier-check. The tests did not run../build.sh --testwith a file that has a lint warninglint. The tests did not run.components/file that imports@/modules/...no-restricted-importserrorpnpm install --frozen-lockfilewith no.git(as in the Docker build).git can't be found.The first local run of
./build.sh --go --ui --testfailed at the end ofnext buildwithSecurityFatalError: 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 (CLAUDECODEorAI_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
web/andbuild.sh. Done.lib/pattern-ui), and this PR does not change rendered UI.pnpm --filter pattern-ui chromaticgivesNo 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
next buildreports a known security vulnerability (see Verification).complexitywhen someone splitsJobInformationPane(41). The next highest value is 27..github/workflows/build.yml. This PR does not change workflow files.🤖 Generated with Claude Code