Skip to content

Commit 7eaa83a

Browse files
committed
build: enable noUncheckedIndexedAccess
1 parent ea21793 commit 7eaa83a

59 files changed

Lines changed: 331 additions & 228 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/__tests__/cli-batch.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('batch --steps parses JSON and forwards batchSteps only', async () => {
3737
]);
3838
assert.equal(result.code, null);
3939
assert.equal(result.calls.length, 1);
40-
const req = result.calls[0];
40+
const req = result.calls[0]!;
4141
assert.equal(req.command, 'batch');
4242
assert.equal(req.session, 'sim');
4343
assert.equal(req.flags?.platform, 'ios');
@@ -53,7 +53,7 @@ test('batch --steps-file parses file payload', async () => {
5353
const result = await runCliCapture(['batch', '--steps-file', stepsPath, '--json']);
5454
assert.equal(result.code, null);
5555
assert.equal(result.calls.length, 1);
56-
const req = result.calls[0];
56+
const req = result.calls[0]!;
5757
assert.equal(req.command, 'batch');
5858
assert.equal((req.flags?.batchSteps ?? [])[0]?.command, 'wait');
5959
});

src/__tests__/client-companion-tunnel-worker.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function decodeWebSocketPayload(payload: Buffer, mask: Buffer | null): Buffer {
121121

122122
const decoded = Buffer.from(payload);
123123
for (let index = 0; index < decoded.length; index += 1) {
124-
decoded[index] ^= mask[index % 4];
124+
decoded[index]! ^= mask[index % 4]!;
125125
}
126126
return decoded;
127127
}

src/__tests__/selectors-public.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const nodes: SnapshotNode[] = [
3737

3838
test('public selector subpath exposes platform-aware matching helpers', () => {
3939
const chain: SelectorChain = parseSelectorChain('role=button label="Continue" visible=true');
40-
const firstSelector: Selector = chain.selectors[0];
40+
const firstSelector: Selector = chain.selectors[0]!;
4141
assert.equal(firstSelector.raw, 'role=button label="Continue" visible=true');
4242
assert.equal(tryParseSelectorChain(chain.raw)?.raw, chain.raw);
4343
assert.equal(isSelectorToken('visible=true'), true);
@@ -55,8 +55,8 @@ test('public selector subpath exposes platform-aware matching helpers', () => {
5555
});
5656
assert.equal(resolved?.node.ref, 'e1');
5757

58-
assert.equal(isNodeVisible(nodes[0]), true);
59-
assert.equal(isNodeEditable(nodes[1], 'android'), true);
58+
assert.equal(isNodeVisible(nodes[0]!), true);
59+
assert.equal(isNodeEditable(nodes[1]!, 'android'), true);
6060
});
6161

6262
test('public selector diagnostics format failures', () => {

src/__tests__/upload-client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ test('uploadArtifact disables macOS AppleDouble entries when archiving app bundl
427427
(cmd, args, options) => {
428428
if (cmd !== 'tar') return undefined;
429429
tarEnv = options.env;
430-
const archivePath = args[1];
430+
const archivePath = args[1]!;
431431
assert.equal(args[0], 'czf');
432432
assert.equal(typeof archivePath, 'string');
433433
fs.writeFileSync(archivePath, 'fake-archive');

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ function hasExplicitMetroRuntimeOverrides(explicitFlagKeys: Set<FlagKey>): boole
481481
function guessSessionFromArgv(argv: string[]): string | null {
482482
for (let i = 0; i < argv.length; i += 1) {
483483
const token = argv[i];
484+
if (token === undefined) continue;
484485
if (token.startsWith('--session=')) {
485486
const inline = token.slice('--session='.length).trim();
486487
return inline.length > 0 ? inline : null;

src/command-codecs/targets.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ export function elementTargetToPositionals(options: ElementTarget): string[] {
6060
}
6161

6262
export function readFillTargetFromPositionals(positionals: string[]): DecodedFillTarget {
63-
if (positionals[0]?.startsWith('@')) {
63+
const ref = positionals[0];
64+
if (ref?.startsWith('@')) {
6465
const text =
6566
positionals.length >= 3 ? positionals.slice(2).join(' ') : positionals.slice(1).join(' ');
67+
const maybeLabel = positionals[1];
6668
return {
6769
kind: 'ref',
6870
target: {
69-
ref: positionals[0],
70-
label: positionals.length >= 3 ? optionalTrimmedText([positionals[1]]) : undefined,
71+
ref,
72+
label:
73+
positionals.length >= 3 && maybeLabel !== undefined
74+
? optionalTrimmedText([maybeLabel])
75+
: undefined,
7176
},
7277
text,
7378
};

src/command-codecs/wait.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,21 @@ export function waitOptionsToPositionals(options: WaitCommandOptions): string[]
6767

6868
export function parseWaitPositionals(args: string[]): WaitParsed | null {
6969
if (args.length === 0) return null;
70+
const firstArg = args[0];
71+
if (firstArg === undefined) return null;
7072

71-
const sleepMs = parseTimeout(args[0]);
73+
const sleepMs = parseTimeout(firstArg);
7274
if (sleepMs !== null) return { kind: 'sleep', durationMs: sleepMs };
7375

74-
if (args[0] === 'text') {
76+
if (firstArg === 'text') {
7577
const timeoutMs = parseTimeout(args[args.length - 1]);
7678
const text = timeoutMs !== null ? args.slice(1, -1).join(' ') : args.slice(1).join(' ');
7779
return { kind: 'text', text: text.trim(), timeoutMs };
7880
}
7981

80-
if (args[0].startsWith('@')) {
82+
if (firstArg.startsWith('@')) {
8183
const timeoutMs = parseTimeout(args[args.length - 1]);
82-
return { kind: 'ref', rawRef: args[0], timeoutMs };
84+
return { kind: 'ref', rawRef: firstArg, timeoutMs };
8385
}
8486

8587
const timeoutMs = parseTimeout(args[args.length - 1]);

src/commands/interaction-targeting.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ function findPreferredActionableDescendant(
8080
if (sameRectChildren.length !== 1) {
8181
break;
8282
}
83-
current = sameRectChildren[0];
83+
const next = sameRectChildren[0];
84+
if (next === undefined) break;
85+
current = next;
8486
}
8587

8688
return current === node ? null : current;

src/commands/react-native/overlay.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,17 @@ function actionFromDismissNode(node: SnapshotNode): ReactNativeOverlayDismissTar
177177
function chooseCollapsedWarningNode(nodes: SnapshotNode[]): SnapshotNode | null {
178178
const withRect = nodes.filter((node) => node.rect);
179179
if (withRect.length === 0) return null;
180-
return withRect.sort((a, b) => {
181-
const aHittable = a.hittable === true ? 1 : 0;
182-
const bHittable = b.hittable === true ? 1 : 0;
183-
if (aHittable !== bHittable) return bHittable - aHittable;
184-
const aWidth = a.rect?.width ?? 0;
185-
const bWidth = b.rect?.width ?? 0;
186-
if (aWidth !== bWidth) return bWidth - aWidth;
187-
return (b.rect?.y ?? 0) - (a.rect?.y ?? 0);
188-
})[0];
180+
return (
181+
withRect.sort((a, b) => {
182+
const aHittable = a.hittable === true ? 1 : 0;
183+
const bHittable = b.hittable === true ? 1 : 0;
184+
if (aHittable !== bHittable) return bHittable - aHittable;
185+
const aWidth = a.rect?.width ?? 0;
186+
const bWidth = b.rect?.width ?? 0;
187+
if (aWidth !== bWidth) return bWidth - aWidth;
188+
return (b.rect?.y ?? 0) - (a.rect?.y ?? 0);
189+
})[0] ?? null
190+
);
189191
}
190192

191193
function collapsedBannerClosePoint(node: SnapshotNode): Point {

src/compat/maestro/support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function requireStringValue(command: string, value: unknown): string {
114114

115115
export function resolveMaestroString(value: string, context: MaestroParseContext): string {
116116
return value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (match, key: string) => {
117-
return Object.prototype.hasOwnProperty.call(context.env, key) ? context.env[key] : match;
117+
return context.env[key] ?? match;
118118
});
119119
}
120120

0 commit comments

Comments
 (0)