Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Dec 17, 2024
1 parent 72c1bc5 commit 88b764d
Show file tree
Hide file tree
Showing 60 changed files with 79 additions and 64 deletions.
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const srcRules = {
await genModuleAbsolutePathIfExists(projectDir, 'node_modules/@mwcp/share') ?? '.',
],
}],
'id-length': 0,
"@typescript-eslint/no-unused-vars": 0,
'@typescript-eslint/prefer-ts-expect-error': 0,
'@typescript-eslint/no-duplicate-enum-values': 0,
'node/no-extraneous-import': 0,
'unicorn/filename-case': 0,
"linebreak-style": 0,
'node/shebang': 0,
}
const testRules = {
'@typescript-eslint/no-explicit-any': 0,
Expand Down
3 changes: 2 additions & 1 deletion packages/win32-api/src/lib/comctl32/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Comctl32 } from './api.types.js'


export {
DefComctl32, Comctl32,
Comctl32,
DefComctl32,
}

export const dllName = DllNames.comctl32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const GetClassInfoExW_mapper: MultipleChoiceMapper<Params, DefParams> = (
assert(Array.isArray(row))
const defArg = row[1]

// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (typeof lpszClass) {
case 'string': {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
1 change: 1 addition & 0 deletions packages/win32-api/src/lib/winspool/api.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-type-parameters */
/* c8 ignore start */
import type * as S from 'win32-def/struct'
import type * as T from 'win32-def/types'
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-api/src/util/winspool/winspool.index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export * from './winspool.types.js'
export type * from './winspool.types.js'
export * from './ClosePrinter.js'
export * from './EndDocPrinter.js'
export * from './EnumPrinters.js'
Expand Down
1 change: 1 addition & 0 deletions packages/win32-api/test/0.dummy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fileShortPath } from '@waiting/shared-core'

import { testConfig } from '#@/root.config.js'


describe(fileShortPath(import.meta.url), () => {

describe('should work', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
import { fileShortPath } from '@waiting/shared-core'
import { ucsBufferFrom } from 'win32-def'

import { Kernel32 as Lib, DllNames } from '##/index.js'
import { DllNames, Kernel32 as Lib } from '##/index.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
import { fileShortPath } from '@waiting/shared-core'
import { ucsBufferFrom } from 'win32-def'

import { Kernel32 as Lib, DllNames, ffi } from '##/index.js'
import { DllNames, Kernel32 as Lib, ffi } from '##/index.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileShortPath } from '@waiting/shared-core'
import { WNDCLASSEXW_Factory } from 'win32-def/struct'
import type { WNDCLASSEXW_Type } from 'win32-def/struct'

import { User32 as Lib, Kernel32 } from '##/index.js'
import { Kernel32, User32 as Lib } from '##/index.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ucsBufferFrom } from 'win32-def'
import { WNDCLASSEXW_Factory } from 'win32-def/struct'
import type { WNDCLASSEXW_Type } from 'win32-def/struct'

import { User32 as Lib, Kernel32 } from '##/index.js'
import { Kernel32, User32 as Lib } from '##/index.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spawn } from 'node:child_process'
import { fileShortPath, sleep } from '@waiting/shared-core'
import { ucsBufferToString } from 'win32-def'

import { User32 as Lib, Kernel32 } from '##/index.js'
import { Kernel32, User32 as Lib } from '##/index.js'
import { FindWindowEx } from '##/index.util.js'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'

import { fileShortPath, sleep } from '@waiting/shared-core'

import { OpenPrinter, GetPrinter, ClosePrinter } from '##/index.util.js'
import { ClosePrinter, GetPrinter, OpenPrinter } from '##/index.util.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import assert from 'node:assert'
import { rm } from 'node:fs/promises'
import { homedir } from 'node:os'

import { fileShortPath, sleep, isFileExists } from '@waiting/shared-core'
import { fileShortPath, isFileExists, sleep } from '@waiting/shared-core'
import { PRINTER_STATUS } from 'win32-def/consts'
import { DOC_INFO_1_Factory } from 'win32-def/struct'

import { EndDocPrinter, OpenPrinter, GetPrinter, ClosePrinter, StartDocPrinter } from '##/index.util.js'
import { ClosePrinter, EndDocPrinter, GetPrinter, OpenPrinter, StartDocPrinter } from '##/index.util.js'
import { testConfig } from '#@/root.config.js'


Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/demo/EnumPrintersW.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env tsx
/* eslint-disable import/no-extraneous-dependencies */


import ffi from 'koffi'
import { PrinterEnumFlags } from 'win32-def/consts'
Expand Down
6 changes: 3 additions & 3 deletions packages/win32-def/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
},
"license": "MIT",
"dependencies": {
"@waiting/shared-core": "^23.19.0",
"koffi": "^2.8.11"
"@waiting/shared-core": "^23.25.3",
"koffi": "^2.9.2"
},
"engines": {
"node": ">=16.12.0"
"node": ">=18.11.0"
},
"files": [
"README.*.md",
Expand Down
4 changes: 2 additions & 2 deletions packages/win32-def/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import ffi from 'koffi'
export * from './lib/config.js'
export * from './lib/def.enum.js'

export * from './lib/common.types.js'
export type * from './lib/common.types.js'
export * from './lib/loader/loader.js'
export * from './lib/ffi.types.js'
export * from './lib/struct/struct.helper.js'
export * from './lib/struct/struct.factory-map.js'
export * from './lib/types.js'
export type * from './lib/types.js'
export * from './lib/util.js'

export { ffi }
Expand Down
4 changes: 2 additions & 2 deletions packages/win32-def/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export * from './lib/common.types.js'
export type * from './lib/common.types.js'
export * from './lib/ffi.types.js'
export * from './lib/types.js'
export type * from './lib/types.js'

export type{
EnumPrinters_Level,
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/src/lib/consts/virtual-key.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-duplicate-enum-values */

/**
* Virtual-Key Codes
*
Expand Down
1 change: 0 additions & 1 deletion packages/win32-def/src/lib/def.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable id-length */

/**
* @link https://koffi.dev/input
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/src/lib/ffi.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/prefer-ts-expect-error */

import type { BigIntStr, MethodTypeUnknown } from '@waiting/shared-types'


Expand Down
6 changes: 3 additions & 3 deletions packages/win32-def/src/lib/loader/loader.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import koffi from 'koffi'
import { loadOptionsDefault } from '##/lib/config.js'
import { Def } from '##/lib/def.enum.js'
import { CallingConvention } from '##/lib/ffi.types.js'
import type { FuncDefListInner, FnDefArgs, FnDefFullParams } from '##/lib/ffi.types.js'
import type { FnDefArgs, FnDefFullParams, FuncDefListInner } from '##/lib/ffi.types.js'
import { structFactoryMap } from '##/lib/struct/struct.factory-map.js'
import type {
FLib,
IKoffiLib,
KoffiFunction,
LoadOptions,
MultipleChoiceMapperList,
UpdateMultipleChoiceMapperOptions,
StructFactory,
UpdateMultipleChoiceMapperOptions,
} from '##/lib/types.js'

import { LoaderCache } from './loader.cache.js'
Expand Down Expand Up @@ -245,7 +245,7 @@ function retrieveStructTypeStringFromParams(params: string[]): string[] {
// '_Inout_ POINT*' or 'POINT *' or 'POINT*'
const regex = /\b(\w+)\s?\*$/u
params.map((val) => {
const match = val.match(regex)
const match = regex.exec(val)
const key = match?.[1]?.trim()
if (key) {
// if Def contains key, then skip
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/src/lib/loader/loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert'

import type { DllFuncsType } from '##/lib/ffi.types.js'
import type { LoadOptions, FLib } from '##/lib/types.js'
import type { FLib, LoadOptions } from '##/lib/types.js'

import { processDefList } from './def.helper.js'
import { LoaderCache } from './loader.cache.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/win32-def/src/lib/loader/loader.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { AsyncMethodType, MethodType } from '@waiting/shared-types'

import type { CallingConvention, FnDefCallParams, FuncDefListInner, DllFuncsType, FnDefFullParams, FnDefRetType, FnDefParam } from '##/lib/ffi.types.js'
import type { IKoffiLib, FLib, LoadOptions, MultipleChoiceMapperList } from '##/lib/types.js'
import type { CallingConvention, DllFuncsType, FnDefCallParams, FnDefFullParams, FnDefParam, FnDefRetType, FuncDefListInner } from '##/lib/ffi.types.js'
import type { FLib, IKoffiLib, LoadOptions, MultipleChoiceMapperList } from '##/lib/types.js'


export interface BindOptions<T extends object = DllFuncsType> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/no-unnecessary-type-parameters */
import assert from 'node:assert'

import type { FnDefArgs } from '##/lib/ffi.types.js'
import type { IKoffiLib, MultipleChoiceMapperList, MultipleChoiceMapperSet } from '##/lib/types.js'

import { LoaderCache } from './loader.cache.js'
import type { CreateProxyMethodOptions, CreateKoffiFunctionOpts, KoffiFunctionLike } from './loader.types.js'
import type { CreateKoffiFunctionOpts, CreateProxyMethodOptions, KoffiFunctionLike } from './loader.types.js'


export function createProxyMethod(options: CreateProxyMethodOptions): KoffiFunctionLike {
Expand All @@ -31,7 +32,7 @@ interface CreateFnOptions {
args: unknown[]
}

function createExecutionFn<R>(options: CreateFnOptions): R {
function createExecutionFn<R = unknown>(options: CreateFnOptions): R {
const { lib, name, args, type } = options

// args includes the last callback function for async call
Expand Down
2 changes: 2 additions & 0 deletions packages/win32-def/src/lib/struct/struct.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type PRINTER_INFO_X_Ptr_Type<X extends PRINTER_INFO_LEVEL> = X extends 1


export function getPRINTER_INFO_X_Ptr<X extends PRINTER_INFO_LEVEL>(level: X): PRINTER_INFO_X_Ptr_Type<X> {
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (level) {
case 1: return PPRINTER_INFO_1 as PRINTER_INFO_X_Ptr_Type<X>

Expand All @@ -53,6 +54,7 @@ export function getPRINTER_INFO_X_Ptr<X extends PRINTER_INFO_LEVEL>(level: X): P
}

export function PRINTER_INFO_X_Factory<X extends PRINTER_INFO_LEVEL>(level: X): StructFactoryResult<PRINTER_INFO_X_Type<X>> {
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (level) {
case 1: return PRINTER_INFO_1_Factory() as StructFactoryResult<PRINTER_INFO_X_Type<X>>

Expand Down
4 changes: 2 additions & 2 deletions packages/win32-def/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { ToAsyncFunction } from '@waiting/shared-types'
import type { IKoffiLib, IKoffiCType, TypeSpecWithAlignment } from 'koffi'
import type { IKoffiCType, IKoffiLib, TypeSpecWithAlignment } from 'koffi'

import type {
CallingConvention,
DllFuncsType,
FnDefName,
FnDefFullParams,
FnDefName,
FuncDefList,
} from './ffi.types.js'

Expand Down
1 change: 1 addition & 0 deletions packages/win32-def/test/0.dummy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fileShortPath } from '@waiting/shared-core'

import { testConfig } from '#@/root.config.js'


describe(fileShortPath(import.meta.url), () => {

describe('should work', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/def.class/20.loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { LoadOptions } from '##/index.js'
import { POINT_Factory } from '##/index.struct.js'
import type { POINT_Type } from '##/index.struct.js'

import { DefWin32Fake, DefWin32 } from './api.helper.js'
import { DefWin32, DefWin32Fake } from './api.helper.js'
import type { Win32 } from './api.helper.js'


Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/def.const/20c.loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { LoadOptions } from '##/index.js'
import { POINT_Factory } from '##/index.struct.js'
import type { POINT_Type } from '##/index.struct.js'

import { defWin32Fake, defWin32 } from './api.helper.js'
import { defWin32, defWin32Fake } from './api.helper.js'
import type { Win32Fns } from './api.helper.js'


Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/lib/24.LoaderCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'node:assert'
import { fileShortPath } from '@waiting/shared-core'

import type { KoffiFunction } from '##/index.js'
import type { MultipleChoiceMapperList, MultipleChoiceMapper, MultipleChoiceMapperSet } from '##/index.types.js'
import type { MultipleChoiceMapper, MultipleChoiceMapperList, MultipleChoiceMapperSet } from '##/index.types.js'
import { LoaderCache } from '##/lib/loader/loader.cache.js'
import { loadIKoffiLib } from '##/lib/loader/loader.helper.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/lib/31.ucsBufferToString.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert'

import { fileShortPath } from '@waiting/shared-core'

import { ucsBufferToString, ucsBufferFrom } from '##/lib/util.js'
import { ucsBufferFrom, ucsBufferToString } from '##/lib/util.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'node:assert'
import { fileShortPath } from '@waiting/shared-core'

import type { StructInitPlainType } from '##/index.js'
import { POINT_Init, LPPOINT, genSimpleStruct } from '##/index.struct.js'
import { LPPOINT, POINT_Init, genSimpleStruct } from '##/index.struct.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert'

import { fileShortPath } from '@waiting/shared-core'

import { POINT_Init, LPPOINT, genComplexStruct } from '##/index.struct.js'
import { LPPOINT, POINT_Init, genComplexStruct } from '##/index.struct.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileShortPath } from '@waiting/shared-core'

import * as D from '##/index.def.js'
import type { StructInitPlainType } from '##/index.js'
import { genSimpleStruct, genUnion, POINT_Init } from '##/index.struct.js'
import { POINT_Init, genSimpleStruct, genUnion } from '##/index.struct.js'
import { StructUnionCache } from '##/lib/struct/struct.cache.js'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert'

import { fileShortPath, sleep } from '@waiting/shared-core'

import { load, decodeInt16Array } from '##/index.js'
import { decodeInt16Array, load } from '##/index.js'
import type { LoadOptions } from '##/index.js'
import { DISPLAY_DEVICEW_Factory } from '##/index.struct.js'
import { DefWin32 } from '#@/def.class/api.helper.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileShortPath } from '@waiting/shared-core'

import { SYSTEMTIME_Factory, LPSYSTEMTIME } from '##/index.struct.js'
import { LPSYSTEMTIME, SYSTEMTIME_Factory } from '##/index.struct.js'
import { assertStructUnion } from '#@/helper.js'


Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/lib/struct/windef/301.RECT.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'

import { fileShortPath } from '@waiting/shared-core'

import { RECT_Factory, LPRECT } from '##/index.struct.js'
import { LPRECT, RECT_Factory } from '##/index.struct.js'
import { assertStructUnion } from '#@/helper.js'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'

import { fileShortPath } from '@waiting/shared-core'

import { POINT_Factory, LPPOINT } from '##/index.struct.js'
import { LPPOINT, POINT_Factory } from '##/index.struct.js'
import { assertStructUnion } from '#@/helper.js'


Expand Down
Loading

0 comments on commit 88b764d

Please sign in to comment.