Skip to content

Commit

Permalink
chore: 更新依赖,适配 ESLint 和 tsc 新规则
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Aug 2, 2024
1 parent 2de1129 commit a9b8df5
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec flh --commitlint
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec flh --tscheck --eslint --jest --only-changes --fix
npm run fix:prettier -- --cache
2 changes: 2 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,35 @@
"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",
"@lzwme/fed-lint-helper": "^2.6.2",
"@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": {
Expand All @@ -108,6 +108,5 @@
"@iarna/toml": {
"optional": true
}
},
"packageManager": "pnpm@9.1.1"
}
}
4 changes: 2 additions & 2 deletions src/common/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -408,7 +408,7 @@ export async function retry<T>(
}
}

throw lastError;
throw lastError!;
}
/**
* 并发执行多任务
Expand Down
13 changes: 10 additions & 3 deletions src/common/is.ts
Original file line number Diff line number Diff line change
@@ -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 &&
Expand Down Expand Up @@ -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';
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/lib/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion src/common/objects.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AnyObject } from '../types';
import {
assign,
mergeArrayLike,
Expand Down Expand Up @@ -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', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/common/objects.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -73,8 +74,8 @@ export function deepClone<T extends object>(obj: T): T {
return result;
}

export function mixin<T = any>(destination: any, source: any, overwrite = true): T {
if (!isObject(destination)) return source;
export function mixin<T = any>(destination: AnyObject, source: AnyObject, overwrite = true): T {
if (!isObject(destination)) return source as T;

if (isObject(source)) {
for (const key of Object.keys(source)) {
Expand All @@ -91,7 +92,7 @@ export function mixin<T = any>(destination: any, source: any, overwrite = true):
}
}
}
return destination;
return destination as T;
}

/** 合并类数组对象。若执行了合并,会去除重复的值 */
Expand Down
2 changes: 1 addition & 1 deletion src/node/ps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
}
});
}
Expand Down

0 comments on commit a9b8df5

Please sign in to comment.