From 5ca0d2da9da0f0bacd256f6b178479e28d216d0a Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 23 Dec 2022 16:42:56 +0800 Subject: [PATCH] refactor: fix eslint --- package.json | 4 +- pnpm-lock.yaml | 120 +++++++++++++++++------------------ src/utilities/assertions.ts | 4 +- src/utilities/conditional.ts | 2 +- src/utilities/pick.ts | 2 +- src/utilities/types.test.ts | 2 +- tsconfig.build.json | 4 ++ tsconfig.json | 3 +- 8 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index 87acc07..f48d926 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lib" ], "scripts": { - "build": "rm -rf lib/ && tsc", + "build": "rm -rf lib/ && tsc -p tsconfig.build.json", "build:test": "rm -rf lib/ && tsc -p tsconfig.test.json", "prepack": "pnpm test && pnpm build", "lint": "eslint --ext .ts src", @@ -27,7 +27,7 @@ "@silverhand/ts-config": "1.2.1", "@types/jest": "^29.2.4", "@types/node": "^16.9.1", - "eslint": "^8.22.0", + "eslint": "^8.30.0", "expect-type": "^0.14.0", "jest": "^29.3.1", "jest-environment-jsdom": "^29.3.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fcef2e..be2657d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,11 +1,15 @@ lockfileVersion: 5.4 +overrides: + '@typescript-eslint/eslint-plugin': 5.36.2 + '@typescript-eslint/parser': 5.36.2 + specifiers: '@silverhand/eslint-config': 1.3.0 '@silverhand/ts-config': 1.2.1 '@types/jest': ^29.2.4 '@types/node': ^16.9.1 - eslint: ^8.22.0 + eslint: ^8.30.0 expect-type: ^0.14.0 jest: ^29.3.1 jest-environment-jsdom: ^29.3.1 @@ -734,23 +738,23 @@ packages: prettier: ^2.7.1 dependencies: '@silverhand/eslint-plugin-fp': 2.5.0_eslint@8.30.0 - '@typescript-eslint/eslint-plugin': 5.47.0_ncmi6noazr3nzas7jxykisekym - '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/eslint-plugin': 5.36.2_fppnmnoyc6ujklmuhonnmta66m + '@typescript-eslint/parser': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa eslint: 8.30.0 eslint-config-prettier: 8.5.0_eslint@8.30.0 eslint-config-xo: 0.42.0_eslint@8.30.0 - eslint-config-xo-typescript: 0.53.2_qbm5x4mewwucm77gjb5cop3dfi + eslint-config-xo-typescript: 0.53.2_djs3ildaqxdf33ifqukctbyfki eslint-import-resolver-typescript: 3.5.2_2lbwmhbr7bncddqbzzpg77o75m eslint-plugin-consistent-default-export-name: 0.0.15 eslint-plugin-eslint-comments: 3.2.0_eslint@8.30.0 - eslint-plugin-import: 2.26.0_p6eswnf3xl3aaa2djfyukgz5eq + eslint-plugin-import: 2.26.0_whmrthf4vun5dv3xirur7qt5hu eslint-plugin-no-use-extend-native: 0.5.0 eslint-plugin-node: 11.1.0_eslint@8.30.0 eslint-plugin-prettier: 4.2.1_kl4pe43v5b43npmso5hoplpbyi eslint-plugin-promise: 6.1.1_eslint@8.30.0 eslint-plugin-sql: 2.1.0_eslint@8.30.0 eslint-plugin-unicorn: 43.0.2_eslint@8.30.0 - eslint-plugin-unused-imports: 2.0.0_juver2u3xbiwnjfu6d55vmnoem + eslint-plugin-unused-imports: 2.0.0_fcsnxv453y4fexnznw3qsranya prettier: 2.8.1 transitivePeerDependencies: - eslint-import-resolver-webpack @@ -895,10 +899,6 @@ packages: resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} dev: true - /@types/semver/7.3.13: - resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} - dev: true - /@types/stack-utils/2.0.1: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true @@ -917,8 +917,8 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin/5.47.0_ncmi6noazr3nzas7jxykisekym: - resolution: {integrity: sha512-AHZtlXAMGkDmyLuLZsRpH3p4G/1iARIwc/T0vIem2YB+xW6pZaXYXzCBnZSF/5fdM97R9QqZWZ+h3iW10XgevQ==} + /@typescript-eslint/eslint-plugin/5.36.2_fppnmnoyc6ujklmuhonnmta66m: + resolution: {integrity: sha512-OwwR8LRwSnI98tdc2z7mJYgY60gf7I9ZfGjN5EjCwwns9bdTuQfAXcsjSB2wSQ/TVNYSGKf4kzVXbNGaZvwiXw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -928,14 +928,14 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa - '@typescript-eslint/scope-manager': 5.47.0 - '@typescript-eslint/type-utils': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa - '@typescript-eslint/utils': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/parser': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/scope-manager': 5.36.2 + '@typescript-eslint/type-utils': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/utils': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa debug: 4.3.4 eslint: 8.30.0 + functional-red-black-tree: 1.0.1 ignore: 5.2.4 - natural-compare-lite: 1.4.0 regexpp: 3.2.0 semver: 7.3.8 tsutils: 3.21.0_typescript@4.9.4 @@ -944,8 +944,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.47.0_lzzuuodtsqwxnvqeq4g4likcqa: - resolution: {integrity: sha512-udPU4ckK+R1JWCGdQC4Qa27NtBg7w020ffHqGyAK8pAgOVuNw7YaKXGChk+udh+iiGIJf6/E/0xhVXyPAbsczw==} + /@typescript-eslint/parser/5.36.2_lzzuuodtsqwxnvqeq4g4likcqa: + resolution: {integrity: sha512-qS/Kb0yzy8sR0idFspI9Z6+t7mqk/oRjnAYfewG+VN73opAUvmYL3oPIMmgOX6CnQS6gmVIXGshlb5RY/R22pA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -954,9 +954,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.47.0 - '@typescript-eslint/types': 5.47.0 - '@typescript-eslint/typescript-estree': 5.47.0_typescript@4.9.4 + '@typescript-eslint/scope-manager': 5.36.2 + '@typescript-eslint/types': 5.36.2 + '@typescript-eslint/typescript-estree': 5.36.2_typescript@4.9.4 debug: 4.3.4 eslint: 8.30.0 typescript: 4.9.4 @@ -964,16 +964,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/5.47.0: - resolution: {integrity: sha512-dvJab4bFf7JVvjPuh3sfBUWsiD73aiftKBpWSfi3sUkysDQ4W8x+ZcFpNp7Kgv0weldhpmMOZBjx1wKN8uWvAw==} + /@typescript-eslint/scope-manager/5.36.2: + resolution: {integrity: sha512-cNNP51L8SkIFSfce8B1NSUBTJTu2Ts4nWeWbFrdaqjmn9yKrAaJUBHkyTZc0cL06OFHpb+JZq5AUHROS398Orw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.47.0 - '@typescript-eslint/visitor-keys': 5.47.0 + '@typescript-eslint/types': 5.36.2 + '@typescript-eslint/visitor-keys': 5.36.2 dev: true - /@typescript-eslint/type-utils/5.47.0_lzzuuodtsqwxnvqeq4g4likcqa: - resolution: {integrity: sha512-1J+DFFrYoDUXQE1b7QjrNGARZE6uVhBqIvdaXTe5IN+NmEyD68qXR1qX1g2u4voA+nCaelQyG8w30SAOihhEYg==} + /@typescript-eslint/type-utils/5.36.2_lzzuuodtsqwxnvqeq4g4likcqa: + resolution: {integrity: sha512-rPQtS5rfijUWLouhy6UmyNquKDPhQjKsaKH0WnY6hl/07lasj8gPaH2UD8xWkePn6SC+jW2i9c2DZVDnL+Dokw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -982,8 +982,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.47.0_typescript@4.9.4 - '@typescript-eslint/utils': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/typescript-estree': 5.36.2_typescript@4.9.4 + '@typescript-eslint/utils': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa debug: 4.3.4 eslint: 8.30.0 tsutils: 3.21.0_typescript@4.9.4 @@ -992,13 +992,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types/5.47.0: - resolution: {integrity: sha512-eslFG0Qy8wpGzDdYKu58CEr3WLkjwC5Usa6XbuV89ce/yN5RITLe1O8e+WFEuxnfftHiJImkkOBADj58ahRxSg==} + /@typescript-eslint/types/5.36.2: + resolution: {integrity: sha512-9OJSvvwuF1L5eS2EQgFUbECb99F0mwq501w0H0EkYULkhFa19Qq7WFbycdw1PexAc929asupbZcgjVIe6OK/XQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.47.0_typescript@4.9.4: - resolution: {integrity: sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q==} + /@typescript-eslint/typescript-estree/5.36.2_typescript@4.9.4: + resolution: {integrity: sha512-8fyH+RfbKc0mTspfuEjlfqA4YywcwQK2Amcf6TDOwaRLg7Vwdu4bZzyvBZp4bjt1RRjQ5MDnOZahxMrt2l5v9w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -1006,8 +1006,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.47.0 - '@typescript-eslint/visitor-keys': 5.47.0 + '@typescript-eslint/types': 5.36.2 + '@typescript-eslint/visitor-keys': 5.36.2 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -1018,31 +1018,29 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.47.0_lzzuuodtsqwxnvqeq4g4likcqa: - resolution: {integrity: sha512-U9xcc0N7xINrCdGVPwABjbAKqx4GK67xuMV87toI+HUqgXj26m6RBp9UshEXcTrgCkdGYFzgKLt8kxu49RilDw==} + /@typescript-eslint/utils/5.36.2_lzzuuodtsqwxnvqeq4g4likcqa: + resolution: {integrity: sha512-uNcopWonEITX96v9pefk9DC1bWMdkweeSsewJ6GeC7L6j2t0SJywisgkr9wUTtXk90fi2Eljj90HSHm3OGdGRg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.11 - '@types/semver': 7.3.13 - '@typescript-eslint/scope-manager': 5.47.0 - '@typescript-eslint/types': 5.47.0 - '@typescript-eslint/typescript-estree': 5.47.0_typescript@4.9.4 + '@typescript-eslint/scope-manager': 5.36.2 + '@typescript-eslint/types': 5.36.2 + '@typescript-eslint/typescript-estree': 5.36.2_typescript@4.9.4 eslint: 8.30.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.30.0 - semver: 7.3.8 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys/5.47.0: - resolution: {integrity: sha512-ByPi5iMa6QqDXe/GmT/hR6MZtVPi0SqMQPDx15FczCBXJo/7M8T88xReOALAfpBLm+zxpPfmhuEvPb577JRAEg==} + /@typescript-eslint/visitor-keys/5.36.2: + resolution: {integrity: sha512-BtRvSR6dEdrNt7Net2/XDjbYKU5Ml6GqJgVfXT0CxTCJlnIqK7rAGreuWKMT2t8cFUT2Msv5oxw0GMRD7T5J7A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.47.0 + '@typescript-eslint/types': 5.36.2 eslint-visitor-keys: 3.3.0 dev: true @@ -1700,7 +1698,7 @@ packages: eslint: 8.30.0 dev: true - /eslint-config-xo-typescript/0.53.2_qbm5x4mewwucm77gjb5cop3dfi: + /eslint-config-xo-typescript/0.53.2_djs3ildaqxdf33ifqukctbyfki: resolution: {integrity: sha512-yi910dDnKq7uLssrhcwI6fj0vnpk//qTx1dbUOTmMm1DctOrNImYeepJYq6/BQdvVL5VKkQiQLHaJnZWcACG9g==} engines: {node: '>=12'} peerDependencies: @@ -1709,8 +1707,8 @@ packages: eslint: '>=8.0.0' typescript: '>=4.4' dependencies: - '@typescript-eslint/eslint-plugin': 5.47.0_ncmi6noazr3nzas7jxykisekym - '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/eslint-plugin': 5.36.2_fppnmnoyc6ujklmuhonnmta66m + '@typescript-eslint/parser': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa eslint: 8.30.0 typescript: 4.9.4 dev: true @@ -1744,7 +1742,7 @@ packages: debug: 4.3.4 enhanced-resolve: 5.12.0 eslint: 8.30.0 - eslint-plugin-import: 2.26.0_p6eswnf3xl3aaa2djfyukgz5eq + eslint-plugin-import: 2.26.0_whmrthf4vun5dv3xirur7qt5hu get-tsconfig: 4.2.0 globby: 13.1.3 is-core-module: 2.11.0 @@ -1754,7 +1752,7 @@ packages: - supports-color dev: true - /eslint-module-utils/2.7.4_zdsb5ko3hocyqbh4wogr2krc6u: + /eslint-module-utils/2.7.4_7pnd5fbaignmfnfnjwjdgm6dsq: resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: @@ -1775,7 +1773,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/parser': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa debug: 3.2.7 eslint: 8.30.0 eslint-import-resolver-node: 0.3.6 @@ -1814,7 +1812,7 @@ packages: ignore: 5.2.4 dev: true - /eslint-plugin-import/2.26.0_p6eswnf3xl3aaa2djfyukgz5eq: + /eslint-plugin-import/2.26.0_whmrthf4vun5dv3xirur7qt5hu: resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} engines: {node: '>=4'} peerDependencies: @@ -1824,14 +1822,14 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa + '@typescript-eslint/parser': 5.36.2_lzzuuodtsqwxnvqeq4g4likcqa array-includes: 3.1.6 array.prototype.flat: 1.3.1 debug: 2.6.9 doctrine: 2.1.0 eslint: 8.30.0 eslint-import-resolver-node: 0.3.6 - eslint-module-utils: 2.7.4_zdsb5ko3hocyqbh4wogr2krc6u + eslint-module-utils: 2.7.4_7pnd5fbaignmfnfnjwjdgm6dsq has: 1.0.3 is-core-module: 2.11.0 is-glob: 4.0.3 @@ -1935,7 +1933,7 @@ packages: strip-indent: 3.0.0 dev: true - /eslint-plugin-unused-imports/2.0.0_juver2u3xbiwnjfu6d55vmnoem: + /eslint-plugin-unused-imports/2.0.0_fcsnxv453y4fexnznw3qsranya: resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1945,7 +1943,7 @@ packages: '@typescript-eslint/eslint-plugin': optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.47.0_ncmi6noazr3nzas7jxykisekym + '@typescript-eslint/eslint-plugin': 5.36.2_fppnmnoyc6ujklmuhonnmta66m eslint: 8.30.0 eslint-rule-composer: 0.3.0 dev: true @@ -2251,6 +2249,10 @@ packages: functions-have-names: 1.2.3 dev: true + /functional-red-black-tree/1.0.1: + resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==} + dev: true + /functions-have-names/1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} dev: true @@ -3479,10 +3481,6 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true - /natural-compare-lite/1.4.0: - resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} - dev: true - /natural-compare/1.4.0: resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=} dev: true diff --git a/src/utilities/assertions.ts b/src/utilities/assertions.ts index cf5e00c..47367b3 100644 --- a/src/utilities/assertions.ts +++ b/src/utilities/assertions.ts @@ -1,6 +1,6 @@ -import { Truthy } from './types.js'; +import type { Truthy } from './types.js'; -// eslint-disable-next-line id-length, complexity +// eslint-disable-next-line id-length const compareFunction = (a: T, b: T) => { if (typeof a === 'string' && typeof b === 'string') { return a.localeCompare(b); diff --git a/src/utilities/conditional.ts b/src/utilities/conditional.ts index b608701..2d2e740 100644 --- a/src/utilities/conditional.ts +++ b/src/utilities/conditional.ts @@ -1,5 +1,5 @@ import { notFalsy } from './assertions.js'; -import { Nullable, Optional, Truthy } from './types.js'; +import type { Nullable, Optional, Truthy } from './types.js'; export const nullable = (exp: T): Nullable> => (notFalsy(exp) ? exp : null); diff --git a/src/utilities/pick.ts b/src/utilities/pick.ts index 59218c4..d328985 100644 --- a/src/utilities/pick.ts +++ b/src/utilities/pick.ts @@ -1,4 +1,4 @@ -import { Picked, PlainObject } from './types.js'; +import type { Picked, PlainObject } from './types.js'; export const pick = >( object: T, diff --git a/src/utilities/types.test.ts b/src/utilities/types.test.ts index 36051b9..9e1b3ea 100644 --- a/src/utilities/types.test.ts +++ b/src/utilities/types.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { KeysToCamelCase } from './types.js'; +import type { KeysToCamelCase } from './types.js'; describe('Check type conversion', () => { test('Snake case to camel case key mapping conversion', () => { diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..ce14650 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig", + "exclude": ["src/**/*.test.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 6d6f974..5d9d141 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,5 @@ }, "include": [ "src" - ], - "exclude": ["src/**/*.test.ts"], + ] }