Skip to content

Commit 369eb2a

Browse files
authored
Merge pull request #7 from moropo-com/fix/tsconfig-strict
fix: enable TypeScript strict mode and type-check tests in CI
2 parents 6cdf93d + bb1d769 commit 369eb2a

9 files changed

Lines changed: 44 additions & 9 deletions

File tree

.github/workflows/cli-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ jobs:
5858
working-directory: ./cli
5959
run: pnpm lint
6060

61+
- name: Type check (strict, src + tests)
62+
working-directory: ./cli
63+
run: pnpm typecheck
64+
6165
- name: Run CLI tests
6266
working-directory: ./cli
6367
env:

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
- `pnpm dcd <args>` — run the CLI from source via `tsx`.
88
- `pnpm build` — clean, compile TypeScript to `dist/`, and `chmod +x dist/index.js` so the published binary is directly executable.
9-
- `pnpm lint` — ESLint over `src/`.
9+
- `pnpm lint` — ESLint over `src/` and `test/`.
10+
- `pnpm typecheck``tsc --noEmit` over `src/` and `test/` (strict mode; `pnpm build` only compiles `src/`).
1011
- `pnpm test` — runs `scripts/test-runner.mjs`: builds the CLI, boots a mock API, then runs all `test/**/*.test.ts` via mocha + ts-node. The mock API lives in the **sibling `dcd/` repo** (`../dcd/mock-api`). Override its location with `MOCK_API_DIR=/path/to/mock-api`.
1112
- Run a single test: `pnpm mocha test/integration/cloud.integration.test.ts --timeout 60000` (picks up `.mocharc.json` which wires tsx; requires the mock API already running on its expected port).
1213

eslint.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ module.exports = tseslint.config(
7474
'@typescript-eslint/no-require-imports': 'off',
7575
},
7676
},
77+
{
78+
// Chai's property-style assertions (`expect(x).to.be.true`) are
79+
// expression statements by design.
80+
files: ['test/**/*.ts'],
81+
rules: {
82+
'@typescript-eslint/no-unused-expressions': 'off',
83+
},
84+
},
7785
);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@
6060
"dcd": "tsx src/index.ts",
6161
"build": "shx rm -rf dist && tsc -b && shx chmod +x dist/index.js",
6262
"build:binaries": "node scripts/build-binaries.mjs",
63-
"lint": "eslint src --ext .ts",
63+
"lint": "eslint src test --ext .ts",
6464
"prepare": "pnpm build",
65-
"test": "node scripts/test-runner.mjs"
65+
"test": "node scripts/test-runner.mjs",
66+
"typecheck": "tsc --noEmit -p tsconfig.test.json"
6667
},
6768
"version": "5.0.0",
6869
"bugs": {

src/commands/upgrade.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ async function downloadToFile(url: string, dest: string): Promise<void> {
131131
throw new Error(`HTTP ${res.status} fetching ${url}`);
132132
}
133133
// Node 22 exposes Readable.fromWeb for piping a WHATWG ReadableStream.
134-
await pipeline(Readable.fromWeb(res.body), createWriteStream(dest));
134+
await pipeline(
135+
Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]),
136+
createWriteStream(dest),
137+
);
135138
}
136139

137140
async function fetchExpectedChecksum(

src/services/results-polling.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { checkInternetConnectivity } from '../utils/connectivity';
88
import { ux } from '../utils/progress';
99
import { colors, formatTestSummary, table } from '../utils/styling';
1010

11-
type TestResult =
12-
paths['/results/{uploadId}']['get']['responses']['200']['content']['application/json']['results'][number];
11+
type TestResult = NonNullable<
12+
paths['/results/{uploadId}']['get']['responses']['200']['content']['application/json']['results']
13+
>[number];
1314

1415
/**
1516
* Custom error for run failures that includes the polling result
@@ -177,7 +178,7 @@ export class ResultsPollingService {
177178
? 'PASSED'
178179
: 'FAILED',
179180
tests: resultsWithoutEarlierTries.map((r) => ({
180-
durationSeconds: r.duration_seconds,
181+
durationSeconds: r.duration_seconds ?? null,
181182
failReason:
182183
r.status === 'FAILED' ? r.fail_reason || 'No reason provided' : undefined,
183184
fileName: r.test_file_name,

src/services/version.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ export class VersionService {
9292
}
9393
}
9494

95+
if (!resolvedVersion) {
96+
throw new Error(
97+
'Unable to resolve a Maestro version: compatibility data did not provide a default.',
98+
);
99+
}
100+
95101
// Validate Maestro version
96102
if (!supportedVersions.includes(resolvedVersion)) {
97103
throw new Error(

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"module": "commonjs",
55
"outDir": "dist",
66
"rootDir": "src",
7-
"strict": false,
7+
"strict": true,
88
"target": "es2022",
99
"skipLibCheck": true,
10-
"resolveJsonModule": true
10+
"resolveJsonModule": true,
11+
"forceConsistentCasingInFileNames": true
1112
},
1213
"include": ["src/**/*"]
1314
}

tsconfig.test.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"declaration": false,
6+
"rootDir": ".",
7+
"types": ["node", "mocha", "chai"]
8+
},
9+
"include": ["src/**/*", "test/**/*"]
10+
}

0 commit comments

Comments
 (0)