Skip to content

Commit acf7271

Browse files
committed
fix(lint): lint
1 parent a8989c0 commit acf7271

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

lib/commands/extension.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { join, normalize } from 'node:path';
55
import { W3C_ELEMENT_KEY, errors } from '@appium/base-driver';
66
import { Element, Rect } from '@appium/types';
77
import { NovaWindowsDriver } from '../driver';
8-
import { $, sleep } from '../util';
8+
import { $, getBundledFfmpegPath, sleep } from '../util';
99
import { POWER_SHELL_FEATURE } from '../constants';
1010
import { keyDown,
1111
keyUp,
@@ -30,7 +30,6 @@ import {
3030
pwsh
3131
} from '../powershell';
3232
import { ClickType, Enum, Key } from '../enums';
33-
import { getBundledFfmpegPath } from '../util';
3433

3534
const PLATFORM_COMMAND_PREFIX = 'windows:';
3635

@@ -827,7 +826,7 @@ export async function deleteFile(this: NovaWindowsDriver, args: { path: string }
827826
throw new errors.InvalidArgumentError("'path' must be provided.");
828827
}
829828
const escapedPath = args.path.replace(/'/g, "''");
830-
const useLiteralPath = /[\[\]?]/.test(args.path);
829+
const useLiteralPath = /[[\][]?]/.test(args.path);
831830
const pathParam = useLiteralPath ? `-LiteralPath '${escapedPath}'` : `-Path '${escapedPath}'`;
832831
await this.sendPowerShellCommand(`Remove-Item ${pathParam} -Force -ErrorAction Stop`);
833832
}
@@ -838,7 +837,7 @@ export async function deleteFolder(this: NovaWindowsDriver, args: { path: string
838837
}
839838
const { path: pathArg, recursive = true } = args;
840839
const escapedPath = pathArg.replace(/'/g, "''");
841-
const useLiteralPath = /[\[\]?]/.test(pathArg);
840+
const useLiteralPath = /[[\][]?]/.test(pathArg);
842841
const pathParam = useLiteralPath ? `-LiteralPath '${escapedPath}'` : `-Path '${escapedPath}'`;
843842
const recurseFlag = recursive ? ' -Recurse' : '';
844843
await this.sendPowerShellCommand(`Remove-Item ${pathParam} -Force${recurseFlag} -ErrorAction Stop`);

lib/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { errors } from '@appium/base-driver';
66
*/
77
export function getBundledFfmpegPath(): string | null {
88
try {
9-
// eslint-disable-next-line @typescript-eslint/no-require-imports
109
const mod = require('ffmpeg-static') as string | { default?: string } | undefined;
1110
const path = typeof mod === 'string' ? mod : mod?.default;
1211
return typeof path === 'string' && path.length > 0 ? path : null;

test/commands/extension/deleteFile.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ describe('deleteFile', () => {
2525
const driver = createMockDriver();
2626
await deleteFile.call(driver, { path: 'C:\\temp\\file.txt' });
2727
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
28-
expect.stringContaining("Remove-Item")
28+
expect.stringContaining('Remove-Item')
2929
);
3030
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
31-
expect.stringContaining("-Path 'C:\\temp\\file.txt'")
31+
expect.stringContaining('-Path \'C:\\temp\\file.txt\'')
3232
);
3333
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
34-
expect.stringContaining("-Force")
34+
expect.stringContaining('-Force')
3535
);
3636
});
3737

3838
it('uses -LiteralPath when path contains brackets', async () => {
3939
const driver = createMockDriver();
4040
await deleteFile.call(driver, { path: 'C:\\temp\\file[1].txt' });
4141
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
42-
expect.stringContaining("-LiteralPath")
42+
expect.stringContaining('-LiteralPath')
4343
);
4444
});
4545

4646
it('escapes single quotes in path', async () => {
4747
const driver = createMockDriver();
4848
await deleteFile.call(driver, { path: "C:\\temp\\file's.txt" });
4949
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
50-
expect.stringContaining("file''s.txt")
50+
expect.stringContaining('file\'\'s.txt')
5151
);
5252
});
5353
});

test/commands/extension/deleteFolder.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('deleteFolder', () => {
2222
const driver = createMockDriver();
2323
await deleteFolder.call(driver, { path: 'C:\\temp\\folder' });
2424
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
25-
expect.stringContaining("-Recurse")
25+
expect.stringContaining('-Recurse')
2626
);
2727
});
2828

@@ -37,7 +37,7 @@ describe('deleteFolder', () => {
3737
const driver = createMockDriver();
3838
await deleteFolder.call(driver, { path: 'C:\\temp\\folder[1]' });
3939
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
40-
expect.stringContaining("-LiteralPath")
40+
expect.stringContaining('-LiteralPath')
4141
);
4242
});
4343
});

test/commands/extension/execute.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*/
44
import { describe, it, expect, vi, beforeEach } from 'vitest';
55
import * as extension from '../../../lib/commands/extension';
6-
import { createMockDriver } from '../../fixtures/driver';
7-
import { MOCK_ELEMENT } from '../../fixtures/driver';
6+
import { createMockDriver, MOCK_ELEMENT } from '../../fixtures/driver';
87

98
describe('execute (command router)', () => {
109
let driver: ReturnType<typeof createMockDriver> & Record<string, any>;
@@ -30,7 +29,7 @@ describe('execute (command router)', () => {
3029
it('routes windows:deleteFile to deleteFile with args', async () => {
3130
await extension.execute.call(driver, 'windows: deleteFile', [{ path: 'C:\\temp\\file.txt' }]);
3231
expect(driver.sendPowerShellCommand).toHaveBeenCalledWith(
33-
expect.stringContaining("Remove-Item")
32+
expect.stringContaining('Remove-Item')
3433
);
3534
});
3635

test/commands/extension/input.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ describe('executeClick', () => {
8585
let callCount = 0;
8686
driver.sendPowerShellCommand.mockImplementation(() => {
8787
callCount++;
88-
if (callCount === 1) return Promise.resolve('True');
89-
if (callCount === 2) return Promise.resolve('1.2.3.4.5');
88+
if (callCount === 1) {
89+
return Promise.resolve('True');
90+
}
91+
if (callCount === 2) {
92+
return Promise.resolve('1.2.3.4.5');
93+
}
9094
return Promise.resolve(rectJson);
9195
});
9296
const { mouseMoveAbsolute } = await import('../../../lib/winapi/user32');

test/commands/extension/pattern.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import {
2323
focusElement,
2424
} from '../../../lib/commands/extension';
2525
import { W3C_ELEMENT_KEY } from '@appium/base-driver';
26-
import { createMockDriver } from '../../fixtures/driver';
27-
import { MOCK_ELEMENT } from '../../fixtures/driver';
26+
import { createMockDriver, MOCK_ELEMENT } from '../../fixtures/driver';
2827

2928
const PATTERN_COMMANDS = [
3029
{ name: 'patternInvoke', fn: patternInvoke, expectInCommand: 'InvokePattern' },

test/commands/extension/stopRecordingScreen.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ describe('stopRecordingScreen', () => {
3535
driver.recordingProcess = {
3636
stdin: mockStdin,
3737
on: vi.fn((event: string, cb: () => void) => {
38-
if (event === 'exit') setTimeout(cb, 0);
38+
if (event === 'exit') {
39+
setTimeout(cb, 0);
40+
}
3941
}),
4042
};
4143
driver.recordingOutputPath = 'C:\\temp\\rec.mp4';
@@ -54,7 +56,9 @@ describe('stopRecordingScreen', () => {
5456
driver.recordingProcess = {
5557
stdin: mockStdin,
5658
on: vi.fn((event: string, cb: () => void) => {
57-
if (event === 'exit') setTimeout(cb, 0);
59+
if (event === 'exit') {
60+
setTimeout(cb, 0);
61+
}
5862
}),
5963
};
6064
driver.recordingOutputPath = 'C:\\temp\\rec.mp4';
@@ -70,7 +74,9 @@ describe('stopRecordingScreen', () => {
7074
driver.recordingProcess = {
7175
stdin: { write: vi.fn() },
7276
on: vi.fn((event: string, cb: () => void) => {
73-
if (event === 'exit') setTimeout(cb, 0);
77+
if (event === 'exit') {
78+
setTimeout(cb, 0);
79+
}
7480
}),
7581
};
7682
driver.recordingOutputPath = 'C:\\temp\\rec.mp4';

0 commit comments

Comments
 (0)