Skip to content

Commit a677a77

Browse files
committed
chore: fix lint errors
1 parent 2129eb8 commit a677a77

4 files changed

Lines changed: 12 additions & 25 deletions

File tree

packages/hd-cli/src/__tests__/pinentry.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ describe('decodeAssuanData', () => {
2323
});
2424

2525
it('decodes CR (%0D) and LF (%0A)', () => {
26-
expect(decodeAssuanData('line1%0Dline2%0Aline3')).toBe(
27-
'line1\rline2\nline3'
28-
);
26+
expect(decodeAssuanData('line1%0Dline2%0Aline3')).toBe('line1\rline2\nline3');
2927
});
3028

3129
it('handles trailing percent encoding', () => {
@@ -84,8 +82,7 @@ describe('decodeAssuanData', () => {
8482

8583
describe('parsePinentryStdout', () => {
8684
it('parses a real pinentry-mac success response', () => {
87-
const stdout =
88-
'OK Pleased to meet you, process 38946\nOK\nOK\nD a%25b%25c\nOK\n';
85+
const stdout = 'OK Pleased to meet you, process 38946\nOK\nOK\nD a%25b%25c\nOK\n';
8986
expect(parsePinentryStdout(stdout)).toEqual({
9087
data: 'a%b%c',
9188
cancelled: false,
@@ -99,8 +96,7 @@ describe('parsePinentryStdout', () => {
9996
});
10097

10198
it('flags cancellation via ERR 83886179', () => {
102-
const stdout =
103-
'OK Pleased to meet you\nOK\nOK\nERR 83886179 Operation cancelled\n';
99+
const stdout = 'OK Pleased to meet you\nOK\nOK\nERR 83886179 Operation cancelled\n';
104100
expect(parsePinentryStdout(stdout)).toEqual({ cancelled: true });
105101
});
106102

packages/hd-cli/src/pinentry.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@
1414

1515
import { execFile, execFileSync } from 'node:child_process';
1616

17-
const PINENTRY_PROGRAMS = [
18-
'pinentry-mac',
19-
'pinentry',
20-
'pinentry-gnome3',
21-
'pinentry-qt',
22-
];
17+
const PINENTRY_PROGRAMS = ['pinentry-mac', 'pinentry', 'pinentry-gnome3', 'pinentry-qt'];
2318

2419
// Assuan protocol percent-encodes %, CR, and LF in D data lines.
2520
// Without decoding, a passphrase containing `%` would be silently corrupted
@@ -46,8 +41,7 @@ export function parsePinentryStdout(stdout: string): {
4641
} {
4742
// Pinentry error code 83886179 is the canonical "user cancelled" signal —
4843
// surfaces either as a non-zero exit or as an ERR line.
49-
const cancelled =
50-
stdout.includes('ERR 83886179') || stdout.includes('Operation cancelled');
44+
const cancelled = stdout.includes('ERR 83886179') || stdout.includes('Operation cancelled');
5145

5246
const dataChunks = stdout
5347
.split(/\r?\n/)
@@ -89,9 +83,7 @@ export function promptPassphraseViaPinentry(): Promise<PinentryResult> {
8983
return new Promise((resolve, reject) => {
9084
const pinentryBin = findPinentry();
9185
if (!pinentryBin) {
92-
process.stderr.write(
93-
'[onekey-hw] No pinentry found, falling back to on-device entry.\n'
94-
);
86+
process.stderr.write('[onekey-hw] No pinentry found, falling back to on-device entry.\n');
9587
resolve({ value: '', passphraseOnDevice: true });
9688
return;
9789
}

packages/hd-cli/src/sdk.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ let sdkReadyPromise: Promise<typeof HardwareSDK> | null = null;
5656
* 2. Hidden wallet — enter passphrase via pinentry (secure OS dialog)
5757
* 3. Hidden wallet — enter passphrase on device screen
5858
*/
59-
function resolvePassphraseByChoice(
60-
choice: '1' | '2' | '3'
61-
): Promise<PinentryResult> {
59+
function resolvePassphraseByChoice(choice: '1' | '2' | '3'): Promise<PinentryResult> {
6260
if (choice === '1') return Promise.resolve({ value: '', passphraseOnDevice: false });
6361
if (choice === '2') return promptPassphraseViaPinentry();
6462
return Promise.resolve({ value: '', passphraseOnDevice: true });

packages/hwk-adapter-core/src/__tests__/core-types.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { HardwareErrorCode } from '../index';
99
describe('HardwareErrorCode contract', () => {
1010
it('every code is 5-digit (>= 10000)', () => {
1111
for (const [name, value] of Object.entries(HardwareErrorCode)) {
12-
if (typeof value !== 'number') continue;
13-
expect({ name, value }).toMatchObject({ name, value: expect.any(Number) });
14-
expect(value).toBeGreaterThanOrEqual(10000);
15-
expect(value).toBeLessThanOrEqual(99999);
12+
if (typeof value === 'number') {
13+
expect({ name, value }).toMatchObject({ name, value: expect.any(Number) });
14+
expect(value).toBeGreaterThanOrEqual(10000);
15+
expect(value).toBeLessThanOrEqual(99999);
16+
}
1617
}
1718
});
1819

0 commit comments

Comments
 (0)