@anjianshi/utils 2.4.16 → 2.4.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-deprecated */
1
2
  /**
2
3
  * 自动计算最合适的 rem 大小,应用到页面样式上。
3
4
  *
@@ -7,7 +7,7 @@ export default async function loadScript(url) {
7
7
  const script = document.createElement('script');
8
8
  script.src = url;
9
9
  script.onload = () => resolve();
10
- script.onerror = err => reject(err);
10
+ script.onerror = err => reject(err); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors
11
11
  window.document.head.appendChild(script);
12
12
  });
13
13
  }
@@ -12,5 +12,5 @@ export declare function isVConsoleEnabled(): boolean;
12
12
  export declare function detectVConsole(): void;
13
13
  export declare function enableVConsole(): void;
14
14
  export declare function disableVConsole(): void;
15
- export declare function runVConsole(): undefined;
15
+ export declare function runVConsole(): void;
16
16
  export declare function destoryVConsole(): void;
@@ -27,7 +27,7 @@ export function runVConsole() {
27
27
  if (window.VConsole !== null)
28
28
  return;
29
29
  if (VConsoleLib === undefined)
30
- return void console.warn('尚未传入 VConsole 对象,无法启动');
30
+ return console.warn('尚未传入 VConsole 对象,无法启动');
31
31
  window.VConsole = new VConsoleLib();
32
32
  }
33
33
  export function destoryVConsole() {
@@ -147,7 +147,7 @@ export class FileHandler extends LogHandler {
147
147
  else {
148
148
  fs.appendFile(this.filepath, content, error => {
149
149
  if (error)
150
- console.error('[logger] write failed: ' + String(error));
150
+ console.error('[logger] write failed: ', error);
151
151
  });
152
152
  }
153
153
  }
@@ -14,5 +14,7 @@ import { type CSSInterpolation } from '@emotion/serialize';
14
14
  export declare const useEmotionCache: () => EmotionCache | undefined;
15
15
  export declare const EmotionCacheProvider: import("react").FC<{
16
16
  children: React.ReactNode;
17
- } & import("react").ClassAttributes<any>>;
17
+ } & import("react").RefAttributes<any>> | import("react").ForwardRefExoticComponent<{
18
+ children: React.ReactNode;
19
+ } & import("react").RefAttributes<any>>;
18
20
  export declare function useEmotionClassName(): (...args: CSSInterpolation[]) => string;
@@ -2,6 +2,5 @@
2
2
  * 开发后端服务能用到的工具库
3
3
  */
4
4
  export * from './env-reader.js';
5
- export * from './redis-cache.js';
6
5
  export * from './controllers.js';
7
6
  export * from './tasks.js';
@@ -2,6 +2,5 @@
2
2
  * 开发后端服务能用到的工具库
3
3
  */
4
4
  export * from './env-reader.js';
5
- export * from './redis-cache.js';
6
5
  export * from './controllers.js';
7
6
  export * from './tasks.js';
@@ -17,6 +17,7 @@ export function getPrismaLoggingOptions(debug) {
17
17
  ],
18
18
  };
19
19
  }
20
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
20
21
  export function adaptPrismaLogging(prisma, baseLogger) {
21
22
  // 记录 Prisma 相关日志
22
23
  const queryLogger = baseLogger.getChild('query');
@@ -14,6 +14,7 @@
14
14
  * 为保证其他扩展也应用到修改过的这些方法,此扩展应尽可能放在最前面。
15
15
  */
16
16
  import { Prisma } from '@prisma/client/extension';
17
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
17
18
  function getModel(that) {
18
19
  const context = Prisma.getExtensionContext(that);
19
20
  // 1. 此扩展修改了 Prisma 原生的方法,所以要通过 context.$parent[context.$name] 获取上一层的 model,不然会自己调用自己导致死循环。
@@ -29,6 +30,7 @@ function getModel(that) {
29
30
  }
30
31
  function query(that, inputArgs, method) {
31
32
  const { model, supportSoftDelete } = getModel(that);
33
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
32
34
  const { withDeleted = false, ...args } = inputArgs;
33
35
  return model[method]({
34
36
  ...args,
package/lang/async.js CHANGED
@@ -23,7 +23,7 @@ export async function timeout(promise, timeoutMS, silent = false) {
23
23
  promise.then(result => {
24
24
  if (!isTimeout)
25
25
  resolve(result);
26
- }, error => {
26
+ }, (error) => {
27
27
  if (!isTimeout)
28
28
  reject(error);
29
29
  });
package/lang/string.js CHANGED
@@ -81,6 +81,7 @@ export function readableSize(bytes, si = false, dp = 1) {
81
81
  /**
82
82
  * 解析 JSON,失败时不抛出异常,而是返回 undefined
83
83
  */
84
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
84
85
  export function safeParseJSON(json) {
85
86
  try {
86
87
  return JSON.parse(json);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "2.4.16",
3
+ "version": "2.4.17",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {
@@ -20,24 +20,24 @@
20
20
  "lodash": "^4.17.21"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/lodash": "^4.17.10",
24
- "@types/node": "^20.16.11",
25
- "@types/react": "^18.3.11",
26
- "dotenv": "^16.4.5",
23
+ "@types/lodash": "^4.17.14",
24
+ "@types/node": "^20.17.14",
25
+ "@types/react": "^18.3.18",
26
+ "dotenv": "^16.4.7",
27
27
  "redis": "^4.7.0",
28
- "typescript": "^5.6.3",
28
+ "typescript": "^5.7.3",
29
29
  "vconsole": "^3.15.1",
30
- "@anjianshi/presets-eslint-node": "4.0.15",
31
- "@anjianshi/presets-eslint-react": "4.0.14",
32
- "@anjianshi/presets-eslint-typescript": "5.0.12",
33
- "@anjianshi/presets-prettier": "3.0.1",
30
+ "@anjianshi/presets-eslint-node": "4.2.2",
31
+ "@anjianshi/presets-eslint-react": "4.2.2",
32
+ "@anjianshi/presets-eslint-typescript": "5.2.2",
33
+ "@anjianshi/presets-prettier": "3.0.2",
34
34
  "@anjianshi/presets-typescript": "3.2.3"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@emotion/react": "^11.13.3",
38
38
  "@emotion/serialize": "^1.3.1",
39
39
  "@emotion/utils": "^1.4.0",
40
- "@prisma/client": "^5.20.0",
40
+ "@prisma/client": "^6.2.1",
41
41
  "chalk": "^5.3.0",
42
42
  "dayjs": "^1.11.10",
43
43
  "dotenv": "^16.4.5",