Fix format and lint for root cluster/pulumi sources#5472
Open
samsondav wants to merge 2 commits into
Open
Conversation
f441164 to
d4992ab
Compare
b16bbc9 to
0532660
Compare
`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>
0532660 to
34db0d4
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3334.
The root
cluster/pulumiformat:fix/lint:fix/checkscripts only delegated to--workspaces, soscripts/fix-ts.pycouldn't run on root.tsfiles:npm run format:fix -- <file>rejected the positional arg. To keep pre-commit working,.pre-commit-config.yamlexcluded/pulumi/[^/]+.ts$, which left the root files uncovered.This PR:
prettier/eslintdirectly oncluster/pulumi/*.tsin the root scripts, then delegates to workspaces with--if-present./pulumi/[^/]+.ts$exclude from the pre-commit hook..tsfiles now in scope. Mostly import-block ordering; twoas anycasts replaced with typed local shapes; one.then(success, error)rewritten asasync/try/catchto satisfypromise/prefer-await-to-then.The root
checkscript runs prettier and eslint on the root once, then delegates to each workspace's owncheck(which itself runs format / lint / type-check). The naive formformat:check && lint:check && check --workspaceswould have run workspace format/lint twice.Test plan
python3 scripts/fix-ts.py cluster/pulumi/*.tsreformats nothing (all files already clean)npm run checkfromcluster/pulumipasses (root + every workspace)source .envrc.vars; source cluster/deployment/mock/.envrc.vars; make cluster/pulumi/test -j8