Skip to content

Commit e163aeb

Browse files
committed
Fix CLI lint for native binding typing
1 parent f979e54 commit e163aeb

2 files changed

Lines changed: 35 additions & 35 deletions

File tree

cli/env.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
/**
66
* CLI version injected at build time from package.json
77
*/
8-
declare const __CLI_VERSION__: string;
8+
declare const __CLI_VERSION__: string
99

1010
/**
1111
* CLI package name injected at build time from package.json
1212
*/
13-
declare const __CLI_PACKAGE_NAME__: string;
13+
declare const __CLI_PACKAGE_NAME__: string
1414

1515
/**
1616
* Kiro global powers registry JSON string injected at build time
1717
*/
18-
declare const __KIRO_GLOBAL_POWERS_REGISTRY__: string;
18+
declare const __KIRO_GLOBAL_POWERS_REGISTRY__: string
1919

2020
interface GlobalThis {
21-
__TNMSC_TEST_NATIVE_BINDING__?: object;
21+
__TNMSC_TEST_NATIVE_BINDING__?: object
2222
}

cli/src/core/native-binding.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
import { createRequire } from "node:module";
2-
import process from "node:process";
1+
import {createRequire} from 'node:module'
2+
import process from 'node:process'
33

44
function shouldSkipNativeBinding(): boolean {
5-
if (process.env["TNMSC_FORCE_NATIVE_BINDING"] === "1") return false;
6-
if (process.env["TNMSC_DISABLE_NATIVE_BINDING"] === "1") return true;
5+
if (process.env['TNMSC_FORCE_NATIVE_BINDING'] === '1') return false
6+
if (process.env['TNMSC_DISABLE_NATIVE_BINDING'] === '1') return true
77

8-
return process.env["NODE_ENV"] === "test" || process.env["VITEST"] != null || process.env["VITEST_WORKER_ID"] != null;
8+
return process.env['NODE_ENV'] === 'test' || process.env['VITEST'] != null || process.env['VITEST_WORKER_ID'] != null
99
}
1010

1111
export function tryLoadNativeBinding<T extends object>(): T | undefined {
12-
const testGlobals = globalThis as typeof globalThis & { __TNMSC_TEST_NATIVE_BINDING__?: object };
13-
const testBinding: unknown = testGlobals.__TNMSC_TEST_NATIVE_BINDING__;
14-
if (testBinding != null && typeof testBinding === "object") return testBinding as T;
15-
if (shouldSkipNativeBinding()) return void 0;
12+
const testGlobals = globalThis as typeof globalThis & {__TNMSC_TEST_NATIVE_BINDING__?: object}
13+
const testBinding: unknown = testGlobals.__TNMSC_TEST_NATIVE_BINDING__
14+
if (testBinding != null && typeof testBinding === 'object') return testBinding as T
15+
if (shouldSkipNativeBinding()) return void 0
1616

1717
const suffixMap: Readonly<Record<string, string>> = {
18-
"win32-x64": "win32-x64-msvc",
19-
"linux-x64": "linux-x64-gnu",
20-
"linux-arm64": "linux-arm64-gnu",
21-
"darwin-arm64": "darwin-arm64",
22-
"darwin-x64": "darwin-x64",
23-
};
24-
const suffix = suffixMap[`${process.platform}-${process.arch}`];
25-
if (suffix == null) return void 0;
18+
'win32-x64': 'win32-x64-msvc',
19+
'linux-x64': 'linux-x64-gnu',
20+
'linux-arm64': 'linux-arm64-gnu',
21+
'darwin-arm64': 'darwin-arm64',
22+
'darwin-x64': 'darwin-x64'
23+
}
24+
const suffix = suffixMap[`${process.platform}-${process.arch}`]
25+
if (suffix == null) return void 0
2626

2727
try {
28-
const _require = createRequire(import.meta.url);
29-
const packageName = `@truenine/memory-sync-cli-${suffix}`;
30-
const binaryFile = `napi-memory-sync-cli.${suffix}.node`;
28+
const _require = createRequire(import.meta.url)
29+
const packageName = `@truenine/memory-sync-cli-${suffix}`
30+
const binaryFile = `napi-memory-sync-cli.${suffix}.node`
3131
const candidates = [
3232
packageName,
3333
`${packageName}/${binaryFile}`,
3434
`./${binaryFile}`,
3535
`../npm/${suffix}`,
3636
`../npm/${suffix}/${binaryFile}`,
3737
`../../npm/${suffix}`,
38-
`../../npm/${suffix}/${binaryFile}`,
39-
];
38+
`../../npm/${suffix}/${binaryFile}`
39+
]
4040

4141
for (const specifier of candidates) {
4242
try {
43-
const loaded = _require(specifier) as unknown;
43+
const loaded = _require(specifier) as unknown
4444
const possibleBindings = [
45-
(loaded as { config?: unknown })?.config,
46-
(loaded as { default?: { config?: unknown } })?.default?.config,
47-
(loaded as { default?: unknown })?.default,
48-
loaded,
49-
];
45+
(loaded as {config?: unknown})?.config,
46+
(loaded as {default?: {config?: unknown}})?.default?.config,
47+
(loaded as {default?: unknown})?.default,
48+
loaded
49+
]
5050

5151
for (const candidate of possibleBindings) {
52-
if (candidate != null && typeof candidate === "object") return candidate as T;
52+
if (candidate != null && typeof candidate === 'object') return candidate as T
5353
}
5454
} catch {}
5555
}
5656
} catch {}
5757

58-
return void 0;
58+
return void 0
5959
}
6060

6161
export function getNativeBinding<T extends object>(): T | undefined {
62-
return tryLoadNativeBinding<T>();
62+
return tryLoadNativeBinding<T>()
6363
}

0 commit comments

Comments
 (0)