From e39c14ea2a13e424b66820fd32e40c66ec134489 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 14 Aug 2023 14:10:32 -0700 Subject: [PATCH] add eslint --- package-lock.json | 351 ++++++++++++++---- packages/util-address/package.json | 6 +- packages/util-encode-key/.eslintrc copy.json | 20 + packages/util-encode-key/package.json | 8 +- packages/util-invariant/.eslintrc.json | 20 + packages/util-invariant/package.json | 6 + packages/util-logger/.eslintrc.json | 20 + packages/util-logger/package.json | 6 + packages/util-logger/src/util-logger.ts | 21 +- packages/util-template/.eslintrc.json | 20 + packages/util-template/package.json | 6 +- .../src/__snapshots__/template.test.ts.snap | 2 +- packages/util-template/src/template.test.ts | 25 +- packages/util-template/src/template.ts | 41 +- packages/util-uid/.eslintrc.json | 20 + packages/util-uid/package.json | 6 +- packages/util-uid/src/util-uid.ts | 9 +- 17 files changed, 456 insertions(+), 131 deletions(-) create mode 100644 packages/util-encode-key/.eslintrc copy.json create mode 100644 packages/util-invariant/.eslintrc.json create mode 100644 packages/util-logger/.eslintrc.json create mode 100644 packages/util-template/.eslintrc.json create mode 100644 packages/util-uid/.eslintrc.json diff --git a/package-lock.json b/package-lock.json index 5aa7f1dd9..d7ec15b1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2024,9 +2024,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.1.tgz", - "integrity": "sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -2062,9 +2062,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.46.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.46.0.tgz", - "integrity": "sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", + "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -5323,21 +5323,20 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.3.0.tgz", - "integrity": "sha512-IZYjYZ0ifGSLZbwMqIip/nOamFiWJ9AH+T/GYNZBWkVcyNQOFGtSMoWV7RvY4poYCMZ/4lHzNl796WOSNxmk8A==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", + "integrity": "sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.3.0", - "@typescript-eslint/type-utils": "6.3.0", - "@typescript-eslint/utils": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/type-utils": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", "natural-compare": "^1.4.0", - "natural-compare-lite": "^1.4.0", "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, @@ -5386,15 +5385,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.3.0.tgz", - "integrity": "sha512-ibP+y2Gr6p0qsUkhs7InMdXrwldjxZw66wpcQq9/PzAroM45wdwyu81T+7RibNCh8oc0AgrsyCwJByncY0Ongg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.0.tgz", + "integrity": "sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.3.0", - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/typescript-estree": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4" }, "engines": { @@ -5414,13 +5413,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.3.0.tgz", - "integrity": "sha512-WlNFgBEuGu74ahrXzgefiz/QlVb+qg8KDTpknKwR7hMH+lQygWyx0CQFoUmMn1zDkQjTBBIn75IxtWss77iBIQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz", + "integrity": "sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0" + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -5431,13 +5430,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.3.0.tgz", - "integrity": "sha512-7Oj+1ox1T2Yc8PKpBvOKWhoI/4rWFd1j7FA/rPE0lbBPXTKjdbtC+7Ev0SeBjEKkIhKWVeZSP+mR7y1Db1CdfQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz", + "integrity": "sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.3.0", - "@typescript-eslint/utils": "6.3.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/utils": "6.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -5458,9 +5457,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.3.0.tgz", - "integrity": "sha512-K6TZOvfVyc7MO9j60MkRNWyFSf86IbOatTKGrpTQnzarDZPYPVy0oe3myTMq7VjhfsUAbNUW8I5s+2lZvtx1gg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.0.tgz", + "integrity": "sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -5471,13 +5470,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.3.0.tgz", - "integrity": "sha512-Xh4NVDaC4eYKY4O3QGPuQNp5NxBAlEvNQYOqJquR2MePNxO11E5K3t5x4M4Mx53IZvtpW+mBxIT0s274fLUocg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz", + "integrity": "sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -5525,17 +5524,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.3.0.tgz", - "integrity": "sha512-hLLg3BZE07XHnpzglNBG8P/IXq/ZVXraEbgY7FM0Cnc1ehM8RMdn9mat3LubJ3KBeYXXPxV1nugWbQPjGeJk6Q==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.0.tgz", + "integrity": "sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.3.0", - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", "semver": "^7.5.4" }, "engines": { @@ -5577,12 +5576,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.3.0.tgz", - "integrity": "sha512-kEhRRj7HnvaSjux1J9+7dBen15CdWmDnwrpyiHsFX6Qx2iW5LOBUgNefOFeh2PjWPlNwN8TOn6+4eBU3J/gupw==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz", + "integrity": "sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/types": "6.4.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -8664,14 +8663,14 @@ } }, "node_modules/eslint": { - "version": "8.46.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.46.0.tgz", - "integrity": "sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", + "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.1", - "@eslint/js": "^8.46.0", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -8682,7 +8681,7 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.2", + "eslint-visitor-keys": "^3.4.3", "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", @@ -8788,9 +8787,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz", - "integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -10067,9 +10066,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", "dependencies": { "type-fest": "^0.20.2" }, @@ -14602,12 +14601,6 @@ "version": "1.4.0", "license": "MIT" }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/negotiator": { "version": "0.6.3", "dev": true, @@ -20467,9 +20460,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -20584,9 +20577,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -20694,11 +20687,111 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/util-invariant/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-invariant/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-invariant/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-invariant/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-invariant/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-invariant/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-invariant/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-logger": { "name": "@onflow/util-logger", "version": "1.3.0-alpha.0", @@ -20708,10 +20801,110 @@ "@onflow/config": "^1.2.0-alpha.0" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/util-logger/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-logger/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-logger/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-logger/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-logger/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-logger/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-logger/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-template": { "name": "@onflow/util-template", "version": "1.2.0-alpha.0", @@ -20724,9 +20917,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } @@ -20836,9 +21029,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } diff --git a/packages/util-address/package.json b/packages/util-address/package.json index a135af192..25a74c83a 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -18,9 +18,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" diff --git a/packages/util-encode-key/.eslintrc copy.json b/packages/util-encode-key/.eslintrc copy.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-encode-key/.eslintrc copy.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 5ea036fd9..48aad3d78 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -18,9 +18,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -36,7 +36,7 @@ "build": "npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", - "lint": "eslint src/*.ts" + "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", diff --git a/packages/util-invariant/.eslintrc.json b/packages/util-invariant/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-invariant/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index e2d1213ab..c7dcc3cc7 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -13,8 +13,14 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "source": "src/index.ts", diff --git a/packages/util-logger/.eslintrc.json b/packages/util-logger/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-logger/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index 1227c8399..4aae5e268 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -13,7 +13,13 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "source": "src/util-logger.ts", diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts index 3f807abbd..bf036556f 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -2,7 +2,6 @@ import {config} from "@onflow/config" /** * The levels of the logger - * @enum */ export enum LEVELS { debug = 5, @@ -14,12 +13,10 @@ export enum LEVELS { /** * Builds a message formatted for the logger - * - * @param options + * @param options - The options for the log * @param options.title - The title of the log * @param options.message - The message of the log * @returns The message formatted for the logger - * * @example * buildLoggerMessageArgs({ title: "My Title", message: "My Message" }) */ @@ -45,16 +42,13 @@ const buildLoggerMessageArgs = (options: { /** * Logs messages based on the level of the message and the level set in the config - * * @param options - The options for the log * @param options.title - The title of the log * @param options.message - The message of the log * @param options.level - The level of the log * @param options.always - Whether to always show the log - * * @example * log({ title: "My Title", message: "My Message", level: LEVELS.warn, always: false }) - * */ export const log = async (options: { title: string @@ -89,8 +83,7 @@ export const log = async (options: { } /** - * Logs a deprecation notice - * + * Logs a deprecation notice. If a callback is provided this function returns a function that will call the callback and log the deprecation notice, otherwise it just logs the deprecation notice. * @param options - The options for the log * @param options.pkg - The package that is being deprecated * @param options.subject - The subject of the deprecation @@ -98,10 +91,14 @@ export const log = async (options: { * @param options.level - The level of the log * @param options.message - The message of the log * @param options.callback - A callback to run after the log - * + * @returns A function that will call the callback and log the deprecation notice if the callback is provided * @example + * // Logs a deprecation notice * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) - * + * @example + * function someFunction() { ... } + * const deprecatedFunction = log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/foo/bar/TRANSITIONS.md", message: "Descriptive message", level: LEVELS.warn, callback: someFunction }) + * deprecatedFunction() // Calls someFunction and logs the deprecation notice */ log.deprecate = (options: { pkg?: string @@ -110,7 +107,7 @@ log.deprecate = (options: { level?: number message?: string callback?: (...args: T[]) => U -}) => { +}): ((...args: T[]) => Promise) | Promise => { const { pkg, subject, diff --git a/packages/util-template/.eslintrc.json b/packages/util-template/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-template/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 01ee6ae99..6a0356c28 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -16,9 +16,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, diff --git a/packages/util-template/src/__snapshots__/template.test.ts.snap b/packages/util-template/src/__snapshots__/template.test.ts.snap index 5a768939f..614f991a9 100644 --- a/packages/util-template/src/__snapshots__/template.test.ts.snap +++ b/packages/util-template/src/__snapshots__/template.test.ts.snap @@ -10,7 +10,7 @@ exports[`template interop function template(template\`\${o=>o.a}\`)(o) -> 'abc' exports[`template interop function template\`\${o=>o.a}\`(o) -> 'abc' 1`] = `"abc"`; -exports[`template interop more template template(template\`x\${template\`y\${o => o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; +exports[`template interop more template template(template\`x\${template\`y\${(_o: typeof o) => _o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; exports[`template interop more template template\`x\${template\`y\${o=>o.a}\`}\`(o) => 'xyabc' 1`] = `"xyabc"`; diff --git a/packages/util-template/src/template.test.ts b/packages/util-template/src/template.test.ts index e2247dc86..dac1be6cb 100644 --- a/packages/util-template/src/template.test.ts +++ b/packages/util-template/src/template.test.ts @@ -1,4 +1,3 @@ -//@ts-nocheck import {template, interleave} from "./template" describe("interleave", () => { @@ -24,14 +23,14 @@ describe("interleave", () => { }) }) -const _ = (msg, a, b?) => { +const _ = (msg: string, a: unknown, b?: unknown) => { if (b == null) { test(msg, () => expect(a).toMatchSnapshot()) } else { test(msg, () => expect(a).toBe(b)) } } -const t = v => typeof v +const t = (v: T) => typeof v describe("template", () => { describe("input type vs output type", () => { @@ -53,10 +52,10 @@ describe("template", () => { describe("interop function", () => { const o = {a: "abc"} - _("template`${o=>o.a}`(o) -> 'abc'", template`${o => o.a}`(o)) + _("template`${o=>o.a}`(o) -> 'abc'", template`${(_o: typeof o) => _o.a}`(o)) _( "template(template`${o=>o.a}`)(o) -> 'abc'", - template(template`${o => o.a}`)(o) + template(template`${(_o: typeof o) => _o.a}`)(o) ) }) @@ -64,20 +63,20 @@ describe("template", () => { const o = {a: "abc"} _( "template`x${template`y${o=>o.a}`}`(o) => 'xyabc'", - template`x${template`y${o => o.a}`}`(o) + template`x${template`y${(_o: typeof o) => _o.a}`}`(o) ) _( "template`x${template`y${template`z${o=>o.a}`}`}`(o) => 'xyabc'", - template`x${template`y${template`z${o => o.a}`}`}`(o) + template`x${template`y${template`z${(_o: typeof o) => _o.a}`}`}`(o) ) _( - "template(template`x${template`y${o => o.a}`}`)(o) -> 'xyabc'", - template(template`x${template`y${o => o.a}`}`)(o) + "template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) -> 'xyabc'", + template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) ) }) describe("interop nested functions", () => { - const fn = a => b => c => d => e => f => f.a + const fn = () => () => () => () => () => (f: typeof o) => f.a const o = {a: "abc"} _("template`${fn}`(o) -> 'abc'", template`${fn}`(o)) }) @@ -89,8 +88,10 @@ describe("template", () => { describe("object can have non string values", () => { const data = {a: 1, b: NaN, c: undefined, d: null, e: false, f: true} - const tx = template`a:${o => o.a}|b:${o => o.b}|c:${o => o.c}|d:${o => - o.d}|e:${o => o.e}|f:${o => o.f}` + const tx = template`a:${(o: typeof data) => o.a}|b:${(o: typeof data) => + o.b}|c:${(o: typeof data) => o.c}|d:${(o: typeof data) => o.d}|e:${( + o: typeof data + ) => o.e}|f:${(o: typeof data) => o.f}` _("template(data)", tx(data), "a:1|b:NaN|c:undefined|d:null|e:false|f:true") }) }) diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts index e534fc5b4..e2a68ae2e 100644 --- a/packages/util-template/src/template.ts +++ b/packages/util-template/src/template.ts @@ -1,13 +1,23 @@ import {log} from "@onflow/util-logger" -export function interleave( - a: unknown[] = [], - b: unknown[] = [], - c: unknown[] = [] -): unknown[] { +/** + * Interleaves two arrays + * @param a - The first array + * @param b - The second array + * @param c - The target array + * @returns The interleaved array + */ +export function interleave( + a: A[] = [], + b: B[] = [], + c: (A | B)[] = [] +): (A | B)[] { if (!a.length && !b.length) return c if (!a.length) return c - if (!b.length) return [...c, a[0]] + if (!b.length) { + c.push(...a) + return c + } const [aHead, ...aRest] = a const [bHead, ...bRest] = b @@ -18,7 +28,12 @@ export function interleave( return interleave(aRest, bRest, c) } -function recApply(d: unknown): (x: unknown) => string { +/** + * Recursively apply a value to a function + * @param d - The value to apply + * @returns A function that takes a function and applies the value to it + */ +function recApply(d: T): (x: U) => string { return function (arg1) { if (typeof arg1 === "function") { log.deprecate({ @@ -33,14 +48,20 @@ function recApply(d: unknown): (x: unknown) => string { } } +/** + * Creates a template function + * @param head - A string, template string array, or template function + * @param rest - The rest of the arguments + * @returns A template function + */ export function template( - head: string | TemplateStringsArray | ((x: unknown) => string), + head: string | TemplateStringsArray | ((x?: unknown) => string), ...rest: unknown[] ): (x?: unknown) => string { if (typeof head === "string") return () => head if (typeof head === "function") return head - return d => - interleave([...head], rest.map(recApply(d))) + return (x: unknown) => + interleave([...head], rest.map(recApply(x))) .join("") .trim() } diff --git a/packages/util-uid/.eslintrc.json b/packages/util-uid/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-uid/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-uid/package.json b/packages/util-uid/package.json index 72fa3f78d..ef1bb0b6e 100644 --- a/packages/util-uid/package.json +++ b/packages/util-uid/package.json @@ -16,9 +16,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, diff --git a/packages/util-uid/src/util-uid.ts b/packages/util-uid/src/util-uid.ts index 467e769ae..651251ef7 100644 --- a/packages/util-uid/src/util-uid.ts +++ b/packages/util-uid/src/util-uid.ts @@ -1,11 +1,12 @@ -var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -var T = HEX.length +const HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +const T = HEX.length /** - * Generates a unique 32 character alphanumeric string + * Generates a random unique identifier + * @returns 32 character alphanumeric string */ export function uid(): string { - var str = "", + let str = "", num = 32 while (num--) str += HEX[(Math.random() * T) | 0] return str