Skip to content

Fix format and lint for root cluster/pulumi sources#5472

Open
samsondav wants to merge 2 commits into
canton-network:mainfrom
Avro-Digital:sam-avro/issue-3334-pulumi-lint
Open

Fix format and lint for root cluster/pulumi sources#5472
samsondav wants to merge 2 commits into
canton-network:mainfrom
Avro-Digital:sam-avro/issue-3334-pulumi-lint

Conversation

@samsondav
Copy link
Copy Markdown
Contributor

@samsondav samsondav commented May 8, 2026

Summary

Fixes #3334.

The root cluster/pulumi format:fix / lint:fix / check scripts only delegated to --workspaces, so scripts/fix-ts.py couldn't run on root .ts files: npm run format:fix -- <file> rejected the positional arg. To keep pre-commit working, .pre-commit-config.yaml excluded /pulumi/[^/]+.ts$, which left the root files uncovered.

This PR:

  • Runs prettier / eslint directly on cluster/pulumi/*.ts in the root scripts, then delegates to workspaces with --if-present.
  • Drops the /pulumi/[^/]+.ts$ exclude from the pre-commit hook.
  • Reformats and lints the existing root .ts files now in scope. Mostly import-block ordering; two as any casts replaced with typed local shapes; one .then(success, error) rewritten as async / try / catch to satisfy promise/prefer-await-to-then.

The root check script runs prettier and eslint on the root once, then delegates to each workspace's own check (which itself runs format / lint / type-check). The naive form format:check && lint:check && check --workspaces would have run workspace format/lint twice.

Test plan

  • python3 scripts/fix-ts.py cluster/pulumi/*.ts reformats nothing (all files already clean)
  • npm run check from cluster/pulumi passes (root + every workspace)
  • source .envrc.vars; source cluster/deployment/mock/.envrc.vars; make cluster/pulumi/test -j8

samsondav added 2 commits May 14, 2026 16:41
`scripts/fix-ts.py` failed on `.ts` files directly under `cluster/pulumi/`
because the root package's `format:fix` / `lint:fix` / `check` scripts
only delegated to `--workspaces`, refusing positional file arguments.
That forced the `typescriptfmt` pre-commit hook to exclude
`/pulumi/[^/]+.ts$` and left the root files uncovered.

Run prettier and eslint directly on root `*.ts` in the root scripts,
then delegate to workspaces with `--if-present`. Drop the
`/pulumi/[^/]+.ts$` exclude from `.pre-commit-config.yaml`. Reformat
and lint the existing root `.ts` files now covered by the hook
(mostly import-block ordering, two `as any` casts replaced with typed
local shapes, and the `.then(success, error)` form in
`abortableStackOperation` rewritten as `async`/`try`/`catch` to
satisfy `promise/prefer-await-to-then`).

Fixes canton-network#3334.

Signed-off-by: Sam Davies <sam@avrofi.com>
The previous form (`npm run format:check && npm run lint:check && npm
run check --workspaces --if-present`) ran each workspace's prettier and
eslint twice: once via the recursive format:check / lint:check, then
again via the workspace's own `check` script (which itself runs
format:check && lint:check && type:check).

Run prettier and eslint directly on the root package's `*.ts` files,
then delegate to each workspace's own `check` so format, lint, and
type-check run once per workspace.

Signed-off-by: Sam Davies <sam@avrofi.com>
@samsondav samsondav force-pushed the sam-avro/issue-3334-pulumi-lint branch from 0532660 to 34db0d4 Compare May 14, 2026 20:51
@samsondav samsondav changed the title fix: lint root pulumi package sources Fix format and lint for root cluster/pulumi sources May 14, 2026
@isegall-da
Copy link
Copy Markdown
Contributor

Thanks @samsondav and apologies for the delay, many people are out this week. I'll try to take a look a bit later today.

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.

fix formatting & linting for cluster/pulumi package sources

5 participants