diff --git a/eslint.config.cjs b/eslint.config.cjs index 618433f..f018b6c 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -55,6 +55,8 @@ module.exports = [ '@typescript-eslint/await-thenable': 'off', '@typescript-eslint/no-unsafe-return': 'off', '@typescript-eslint/no-redundant-type-constituents': 'off', + '@typescript-eslint/prefer-promise-reject-errors': 'off', + '@typescript-eslint/no-require-imports': 'off', 'unicorn/no-array-for-each': 'off', 'unicorn/no-await-expression-member': 'off', diff --git a/package.json b/package.json index 8de6717..a01f9d0 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "tslib": "^2.6.3" }, "devDependencies": { - "@eslint/js": "^9.7.0", + "@eslint/js": "^9.8.0", "@iarna/toml": "^2.2.5", "@jest/core": "^29", "@jest/types": "^29", @@ -70,27 +70,27 @@ "@types/eslint": "^9.6.0", "@types/jest": "^29.5.12", "@types/micromatch": "^4.0.9", - "@types/node": "^20.14.12", - "@typescript-eslint/eslint-plugin": "^7.17.0", - "@typescript-eslint/parser": "^7.17.0", + "@types/node": "^22.0.2", + "@typescript-eslint/eslint-plugin": "^8.0.0", + "@typescript-eslint/parser": "^8.0.0", "compressing": "^1.10.1", - "eslint": "^9.7.0", + "eslint": "^9.8.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-unicorn": "^54.0.0", - "husky": "^9.1.1", + "eslint-plugin-unicorn": "^55.0.0", + "husky": "^9.1.4", "jest": "^29.7.0", "json5": "^2.2.3", "micromatch": "^4.0.7", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", "standard-version": "^9.5.0", - "ts-jest": "^29.2.3", + "ts-jest": "^29.2.4", "ts-node": "^10.9.2", "typedoc": "^0.26.5", "typescript": "^5.5.4", - "typescript-eslint": "^7.17.0", + "typescript-eslint": "^8.0.0", "windows-process-tree": "^0.4.0" }, "peerDependencies": { @@ -108,6 +108,5 @@ "@iarna/toml": { "optional": true } - }, - "packageManager": "pnpm@9.1.1" + } } diff --git a/src/common/async.ts b/src/common/async.ts index e170f1b..343b0b7 100644 --- a/src/common/async.ts +++ b/src/common/async.ts @@ -2,7 +2,7 @@ * @Author: lzw * @Date: 2022-01-12 15:10:41 * @LastEditors: renxia - * @LastEditTime: 2024-03-12 15:36:09 + * @LastEditTime: 2024-08-02 13:42:47 * @Description: * @see src\vs\base\common\async.ts */ @@ -408,7 +408,7 @@ export async function retry( } } - throw lastError; + throw lastError!; } /** * 并发执行多任务 diff --git a/src/common/is.ts b/src/common/is.ts index da50170..d00cfd1 100644 --- a/src/common/is.ts +++ b/src/common/is.ts @@ -1,5 +1,12 @@ -// eslint-disable-next-line @typescript-eslint/ban-types -export function isObject(obj: unknown): obj is Object { +/* + * @Author: renxia + * @Date: 2023-03-23 23:05:16 + * @LastEditors: renxia + * @LastEditTime: 2024-08-02 13:40:01 + * @Description: + */ + +export function isObject(obj: unknown): obj is object { return ( typeof obj === 'object' && obj !== null && @@ -41,7 +48,7 @@ export function isUndefinedOrNull(value: unknown) { return null == value; } -// eslint-disable-next-line @typescript-eslint/ban-types +// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type export function isFunction(obj: unknown): obj is Function { return typeof obj === 'function'; } diff --git a/src/common/lib/Logger.ts b/src/common/lib/Logger.ts index c47787e..5bbe63c 100644 --- a/src/common/lib/Logger.ts +++ b/src/common/lib/Logger.ts @@ -2,7 +2,7 @@ * @Author: lzw * @Date: 2022-04-08 10:30:02 * @LastEditors: renxia - * @LastEditTime: 2024-03-07 09:43:33 + * @LastEditTime: 2024-08-02 13:39:45 * @Description: */ /* eslint no-console: 0 */ @@ -88,7 +88,7 @@ export class Logger { protected options: LoggerOptions = {} ) { const match = /(\w+)/.exec(tag); - if (!match) throw 'Logger tag expected'; + if (!match) throw new Error('Logger tag expected'); this.tag = tag.startsWith('[') ? tag : `[${tag}]`; if (!options.levelType || !(options.levelType in LogLevel)) { diff --git a/src/common/objects.spec.ts b/src/common/objects.spec.ts index c645f93..f43a5cf 100644 --- a/src/common/objects.spec.ts +++ b/src/common/objects.spec.ts @@ -1,3 +1,4 @@ +import { AnyObject } from '../types'; import { assign, mergeArrayLike, @@ -77,7 +78,7 @@ describe('objects/assign', () => { expect(c.b.c).toBeNull(); expect(c.b.d).toBe(5); - expect(mixin(null, a)).toEqual(a); + expect(mixin(null as never as AnyObject, a)).toEqual(a); }); it('mergeArrayLike', () => { diff --git a/src/common/objects.ts b/src/common/objects.ts index be650f8..1822b36 100644 --- a/src/common/objects.ts +++ b/src/common/objects.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any, unicorn/prefer-top-level-await */ +import type { AnyObject } from '../types'; import { isObject, isSet, isMap, isArray } from './is'; let JSON5: typeof globalThis.JSON; @@ -73,8 +74,8 @@ export function deepClone(obj: T): T { return result; } -export function mixin(destination: any, source: any, overwrite = true): T { - if (!isObject(destination)) return source; +export function mixin(destination: AnyObject, source: AnyObject, overwrite = true): T { + if (!isObject(destination)) return source as T; if (isObject(source)) { for (const key of Object.keys(source)) { @@ -91,7 +92,7 @@ export function mixin(destination: any, source: any, overwrite = true): } } } - return destination; + return destination as T; } /** 合并类数组对象。若执行了合并,会去除重复的值 */ diff --git a/src/node/ps.ts b/src/node/ps.ts index 847b862..3be15f4 100644 --- a/src/node/ps.ts +++ b/src/node/ps.ts @@ -205,7 +205,7 @@ export function listProcesses(rootPid: number, formatName?: (cmd: string) => str reject(err || new Error(stderr.toString())); } else { parsePsOutput(stdout, addToTree); - rootItem ? resolve(rootItem) : reject(new Error(`Root process ${rootPid} not found`)); + return rootItem ? resolve(rootItem) : reject(new Error(`Root process ${rootPid} not found`)); } }); }