From 87a94c07ae52f434fd4a92d9f7cead9d84d9b2c4 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Fri, 5 Jul 2024 15:26:12 +0900 Subject: [PATCH 01/19] =?UTF-8?q?build:=20eslint=20&=20prettier=20?= =?UTF-8?q?=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 3 + .prettierrc | 11 + eslint.config.js | 9 + package-lock.json | 1127 +++++++++++++++++++++++++++++++++++++++++++-- package.json | 8 +- 5 files changed, 1118 insertions(+), 40 deletions(-) create mode 100644 .eslintrc create mode 100644 .prettierrc create mode 100644 eslint.config.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..62f705b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["plugin:prettier/recommended"], +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6923972 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "semi": true, + "endOfLine": "lf", + "tabWidth": 2, + "printWidth": 80, + "singleQuote": true, + "bracketSameLine": false, + "bracketSpacing": true, + "arrowParens": "always", + "singleAttributePerLine": true +} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..a027e87 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,9 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; + +export default [ + { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, + pluginJs.configs.recommended, + eslintPluginPrettierRecommended, +]; diff --git a/package-lock.json b/package-lock.json index 2e1d661..4d2383f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,12 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { + "@eslint/js": "^9.6.0", + "eslint": "^9.6.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "globals": "^15.8.0", + "prettier": "3.3.2", "vitest": "^1.6.0" } }, @@ -380,6 +386,135 @@ "node": ">=12" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "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==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", + "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.0.tgz", + "integrity": "sha512-A68TBu6/1mHHuc5YJL0U0VVeGNiklLAL6rRmhTCP2B5XjWLMnrX+HkO+IAXyHvks5cyyY1jjK5ITPQ1HGS2EVA==", + "dev": true, + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.6.0.tgz", + "integrity": "sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", + "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "dev": true, + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -398,6 +533,53 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz", @@ -699,6 +881,15 @@ "node": ">=0.4.0" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/acorn-walk": { "version": "8.3.3", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", @@ -711,6 +902,31 @@ "node": ">=0.4.0" } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", @@ -723,6 +939,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -732,6 +954,22 @@ "node": "*" } }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -741,6 +979,15 @@ "node": ">=8" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/chai": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", @@ -759,6 +1006,37 @@ "node": ">=4" } }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/check-error": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", @@ -771,6 +1049,30 @@ "node": "*" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, "node_modules/confbox": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.7.tgz", @@ -820,6 +1122,12 @@ "node": ">=6" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -867,6 +1175,189 @@ "@esbuild/win32-x64": "0.21.5" } }, + "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" + } + }, + "node_modules/eslint": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-ElQkdLMEEqQNM9Njff+2Y4q2afHk7JpkPvrd7Xh7xefwgQynqPxwf55J7di9+MEibWUGdNjFF9ITG9Pck5M84w==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/config-array": "^0.17.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.6.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.3.0", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.0.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz", + "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.8.6" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", + "integrity": "sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -876,71 +1367,257 @@ "@types/estree": "^1.0.0" } }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", "dev": true, "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^8.0.1", - "human-signals": "^5.0.0", - "is-stream": "^3.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^5.1.0", - "onetime": "^6.0.0", - "signal-exit": "^4.1.0", - "strip-final-newline": "^3.0.0" + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "15.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.8.0.tgz", + "integrity": "sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" }, "engines": { - "node": ">=16.17" + "node": ">=6" }, "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + "node": ">=0.8.19" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { - "node": "*" + "node": ">=0.10.0" } }, - "node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "engines": { - "node": ">=16" + "dependencies": { + "is-extglob": "^2.1.1" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "engines": { + "node": ">=0.10.0" } }, - "node_modules/human-signals": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", - "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "engines": { - "node": ">=16.17.0" + "node": ">=8" } }, "node_modules/is-stream": { @@ -967,6 +1644,58 @@ "integrity": "sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==", "dev": true }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/local-pkg": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", @@ -983,6 +1712,27 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "node_modules/loupe": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", @@ -1019,6 +1769,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/mlly": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.1.tgz", @@ -1055,6 +1817,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, "node_modules/npm-run-path": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", @@ -1097,6 +1865,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", @@ -1112,6 +1897,69 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -1181,6 +2029,42 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -1195,12 +2079,60 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", "dev": true }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rollup": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", @@ -1236,6 +2168,29 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1296,6 +2251,18 @@ "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -1308,6 +2275,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/strip-literal": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-2.1.0.tgz", @@ -1320,6 +2299,40 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/synckit": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz", + "integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==", + "dev": true, + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/tinybench": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.8.0.tgz", @@ -1344,6 +2357,24 @@ "node": ">=14.0.0" } }, + "node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1359,6 +2390,15 @@ "integrity": "sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==", "dev": true }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/vite": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", @@ -1532,6 +2572,15 @@ "node": ">=8" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", diff --git a/package.json b/package.json index 1fe342c..0426eee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "로또 미션을 통해서 학습하는 클린코드", "main": "./src/main.js", - "type": "module", + "type": "module", "scripts": { "start": "node src/main.js", "start:watch": "node --watch src/main.js", @@ -13,6 +13,12 @@ "author": "", "license": "ISC", "devDependencies": { + "@eslint/js": "^9.6.0", + "eslint": "^9.6.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "globals": "^15.8.0", + "prettier": "3.3.2", "vitest": "^1.6.0" } } From bff324c309c01f3d452ffe3b90e18b58867a4583 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:46:40 +0900 Subject: [PATCH 02/19] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/sum.test.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/__tests__/sum.test.js diff --git a/src/__tests__/sum.test.js b/src/__tests__/sum.test.js deleted file mode 100644 index efc011c..0000000 --- a/src/__tests__/sum.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { describe, test, expect } from "vitest"; - -function sum(...args) { - return args.reduce((a, b) => a+ b); -} - -describe('예제 테스트입니다.', () => { - test('sum > ', () => { - expect(sum(1,2,3,4,5)).toBe(15); - }) -}) From 3a47b4f1a6d858113e9cd9c622e03ee8a5c82ebf Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:46:50 +0900 Subject: [PATCH 03/19] =?UTF-8?q?feat:=20View=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/View/View.js | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/View/View.js diff --git a/src/View/View.js b/src/View/View.js new file mode 100644 index 0000000..8b4d437 --- /dev/null +++ b/src/View/View.js @@ -0,0 +1,112 @@ +import { readLineAsync } from '../utils/readline.js'; +import LottoRule from '../domain/LottoRule.js'; + +export default class View { + constructor() { + this.rl = readLineAsync; + } + + async input( + message, + options = { + postProcessFn: undefined, + errorCheckFn: undefined, + }, + ) { + const { postProcessFn, errorCheckFn } = options; + const postProcessFnError = View.getPostProcessFnError(postProcessFn); + const errorCheckFnError = View.getErrorCheckFnError(errorCheckFn); + + if (postProcessFnError !== undefined || errorCheckFnError !== undefined) { + throw new Error(postProcessFnError || errorCheckFnError); + } + + while (true) { + const inputValue = await this.rl(message); + const postInputValue = postProcessFn + ? postProcessFn(inputValue) + : inputValue; + const error = errorCheckFn + ? errorCheckFn(postInputValue) + : postInputValue; + + if (error === undefined) { + return postInputValue; + } + + console.log(error); + } + } + + async inputPurchaseLotto( + options = { + postProcessFn: undefined, + errorCheckFn: undefined, + }, + ) { + return this.input('> 구입금액을 입력해 주세요:', options); + } + + async inputWinLotto( + options = { + postProcessFn: undefined, + errorCheckFn: undefined, + }, + ) { + return this.input('> 당첨 번호를 콤마(,)로 구분해 입력해 주세요:', options); + } + + async inputBonusNumber( + options = { + postProcessFn: undefined, + errorCheckFn: undefined, + }, + ) { + return this.input('> 보너스 번호를 입력해 주세요: ', options); + } + + printPurchaseLotto(quantity) { + console.log(`${quantity}개를 구매했습니다.`); + console.log('\n'); + } + + printAllLotto(lottos) { + lottos.forEach((lotto) => { + console.log(lotto); + }); + console.log('\n'); + } + + printAccordByRank(rankInfo) { + const ranks = Object.keys(rankInfo); + + console.log('당첨 통계'); + console.log('--------------------'); + + ranks.forEach((rank) => { + console.log( + `${LottoRule.ACCROD_STRING_BY_RANK[rank]} - ${rankInfo[rank]}개`, + ); + }); + } + + printRate(rate) { + console.log(`총 수익률은 ${rate}% 입니다.`); + } + + static getPostProcessFnError(postProcessFn) { + if (postProcessFn !== undefined && typeof postProcessFn !== 'function') { + return '후처리 함수(postProcessFn)는 함수 타입이어야 합니다.'; + } + + return undefined; + } + + static getErrorCheckFnError(errorCheckFn) { + if (errorCheckFn !== undefined && typeof errorCheckFn !== 'function') { + return '에러 검사 함수(errorCheckFn)는 함수 타입이어야 합니다.'; + } + + return undefined; + } +} From 23d2915003d9383ad7cbab3aecbf5e7f9e98ddb4 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:47:50 +0900 Subject: [PATCH 04/19] =?UTF-8?q?feat:=20=EB=8F=88=EC=9D=84=20=EC=BD=A4?= =?UTF-8?q?=EB=A7=88=EA=B0=80=20=EC=9E=88=EB=8A=94=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=EC=97=B4=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=9C=A0=ED=8B=B8=20=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/String.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/utils/String.js diff --git a/src/utils/String.js b/src/utils/String.js new file mode 100644 index 0000000..0b23773 --- /dev/null +++ b/src/utils/String.js @@ -0,0 +1,13 @@ +export function makeMoneyForm(money) { + const reversedMoney = String(money).split('').reverse(); + const stack = []; + + reversedMoney.forEach((num, index) => { + if (reversedMoney[index + 1] !== undefined && index % 3 === 0) { + stack.push(','); + } + stack.push(num); + }); + + return stack.reverse().join(''); +} From 1465ccef6f85b954cd708d1b17beb4e77626cf60 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:48:01 +0900 Subject: [PATCH 05/19] =?UTF-8?q?feat:=20readline=20=EC=9C=A0=ED=8B=B8?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/readline.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/utils/readline.js diff --git a/src/utils/readline.js b/src/utils/readline.js new file mode 100644 index 0000000..78e3d39 --- /dev/null +++ b/src/utils/readline.js @@ -0,0 +1,23 @@ +import readline from 'readline'; + +export function readLineAsync(query) { + return new Promise((resolve, reject) => { + if (arguments.length !== 1) { + reject(new Error('arguments must be 1')); + } + + if (typeof query !== 'string') { + reject(new Error('query must be string')); + } + + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + rl.question(query, (input) => { + rl.close(); + resolve(input); + }); + }); +} From a3ca1f473f925244b9be6ca1b2d9d3d0a5b7a23d Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:48:24 +0900 Subject: [PATCH 06/19] =?UTF-8?q?refactoring:=20=EC=9C=A0=ED=8B=B8=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/String.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/String.js b/src/utils/String.js index 0b23773..f909541 100644 --- a/src/utils/String.js +++ b/src/utils/String.js @@ -1,4 +1,4 @@ -export function makeMoneyForm(money) { +export function changeStandardMoneyString(money) { const reversedMoney = String(money).split('').reverse(); const stack = []; From 42993bf304d3a2d6d515f8ca61644016dc443d04 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:48:37 +0900 Subject: [PATCH 07/19] =?UTF-8?q?feat:=20=EB=9E=9C=EB=8D=A4=20=EB=B2=88?= =?UTF-8?q?=ED=98=B8=EB=A5=BC=20=EC=83=9D=EC=84=B1=ED=95=B4=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=EC=9C=A0=ED=8B=B8=ED=95=A8=EC=88=98=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/Number.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/utils/Number.js diff --git a/src/utils/Number.js b/src/utils/Number.js new file mode 100644 index 0000000..14f3a6a --- /dev/null +++ b/src/utils/Number.js @@ -0,0 +1,3 @@ +export function generateRandomNumber(min, max) { + return Math.floor(Math.random() * (max - min) + min); +} From 5ec290a342a6ecab370ec9fd71c7b1e0e7bd27b8 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:50:37 +0900 Subject: [PATCH 08/19] =?UTF-8?q?feat:=20=EB=B0=B0=EC=97=B4=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EA=B3=BC=20=EA=B4=80=EB=A0=A8=EB=90=9C=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - accord: 비교할 두 배열을 받아서 일치하는 개수를 반환하는 함수 - generateRandomNumberArray: 배열의 개수를 받아서 그 개수만큼 랜덤 번호를 생성하는 함수 --- src/utils/Array.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/utils/Array.js diff --git a/src/utils/Array.js b/src/utils/Array.js new file mode 100644 index 0000000..9148894 --- /dev/null +++ b/src/utils/Array.js @@ -0,0 +1,20 @@ +import { generateRandomNumber } from './Number.js'; + +export function accord(base, compare) { + const baseSet = new Set(base); + + return compare.reduce( + (prev, curr) => (baseSet.has(curr) ? prev + 1 : prev), + 0, + ); +} + +export function generateRandomNumberArray(amount, min, max) { + const set = new Set(); + + while (set.size < amount) { + set.add(generateRandomNumber(min, max)); + } + + return [...set].sort((a, b) => a - b); +} From a49de74abfcf7e6d5ad0b50f60f0c5eb53f1e079 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:52:31 +0900 Subject: [PATCH 09/19] =?UTF-8?q?feat:=20Lotto=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/Lotto.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/domain/Lotto.js diff --git a/src/domain/Lotto.js b/src/domain/Lotto.js new file mode 100644 index 0000000..8de624f --- /dev/null +++ b/src/domain/Lotto.js @@ -0,0 +1,35 @@ +export default class Lotto { + _lotto; + + constructor(lotto) { + this.set(lotto); + } + + set(lotto) { + const lottoError = Lotto.getLottoError(lotto); + + if (lottoError !== undefined) { + return lottoError; + } + + this._lotto = lotto; + } + + get() { + return [...this._lotto]; + } + + static getLottoError(lotto) { + const commonError = Lotto.getCommonLottoError(lotto); + + if (commonError !== undefined) return commonError; + + const lottoSet = new Set(lotto); + + if (lottoSet.size !== Lotto.DEFAULT_LENGTH) { + return `일반 로또 번호의 개수는 ${Lotto.DEFAULT_LENGTH}개 여야 합니다.`; + } + + return undefined; + } +} From aefd1e2bd8957e9fab37dc3d24e74fc71b2cf3e3 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:52:44 +0900 Subject: [PATCH 10/19] =?UTF-8?q?feat:=20LottoRule=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/LottoRule.js | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/domain/LottoRule.js diff --git a/src/domain/LottoRule.js b/src/domain/LottoRule.js new file mode 100644 index 0000000..ae8b3ef --- /dev/null +++ b/src/domain/LottoRule.js @@ -0,0 +1,90 @@ +import { generateRandomNumberArray } from '../utils/Array.js'; +import { changeStandardMoneyString } from '../utils/String.js'; + +export default class LottoRule { + static RANK_BY_ACCORD = Object.freeze({ + 3: { bonus: 5, base: 3 }, + 4: { bonus: 4, base: 4 }, + 5: { bonus: 2, base: 3 }, + 6: { bonus: 1, base: 1 }, + }); + static REWARD = Object.freeze({ + 1: 200000000, + 2: 30000000, + 3: 1500000, + 4: 50000, + 5: 5000, + }); + static ACCROD_STRING_BY_RANK = Object.freeze({ + 1: `6개 일치 ${changeStandardMoneyString(LottoRule.REWARD[1])}`, + 2: `5개 일치, 보너스 볼 일치 ${changeStandardMoneyString(LottoRule.REWARD[2])}`, + 3: `5개 일치 ${changeStandardMoneyString(LottoRule.REWARD[3])}`, + 4: `4개 일치 ${changeStandardMoneyString(LottoRule.REWARD[4])}`, + 5: `3개 일치 ${changeStandardMoneyString(LottoRule.REWARD[5])}`, + }); + + static get MAX_NUMBER() { + return 45; + } + + static get MIN_NUMBER() { + return 1; + } + + static get MONEY() { + return 1000; + } + + static get DEFAULT_LENGTH() { + return 6; + } + + static generateLottoNumber() { + return generateRandomNumberArray( + LottoRule.DEFAULT_LENGTH, + LottoRule.MIN_NUMBER, + LottoRule.MAX_NUMBER, + ); + } + + static calculateQuantity(money) { + const moneyError = LottoRule.getMoneyError(money); + + if (moneyError !== undefined) { + throw new Error(moneyError); + } + + return Math.floor(money / LottoRule.MONEY); + } + + static getMoneyError(money) { + if (typeof money !== 'number') { + return '돈은 숫자 타입으로 입력받아야 합니다.'; + } + + if (money < LottoRule.MONEY) { + return `구입금액은 최소 ${LottoRule.MONEY}원부터 가능합니다.`; + } + + return undefined; + } + + static getCommonLottoError(lotto) { + if (Array.isArray(lotto) === false) { + return 'lotto는 배열 형식이어야 합니다.'; + } + + if ( + lotto.some( + (num) => + typeof num !== 'number' || + num < LottoRule.MIN_NUMBER || + num > LottoRule.MAX_NUMBER, + ) + ) { + return 'lotto배열의 요소는 숫자로 이뤄져야 합니다.'; + } + + return undefined; + } +} From 28bd6f29dab3e2d9a2c3f304840407404cbe8b9c Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:52:59 +0900 Subject: [PATCH 11/19] =?UTF-8?q?feat:=20WinLotto=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/WinLotto.js | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/domain/WinLotto.js diff --git a/src/domain/WinLotto.js b/src/domain/WinLotto.js new file mode 100644 index 0000000..b2b3b75 --- /dev/null +++ b/src/domain/WinLotto.js @@ -0,0 +1,78 @@ +import Lotto from './Lotto.js'; +import LottoRule from './LottoRule.js'; +import { accord } from '../utils/Array.js'; + +export default class WinLotto extends Lotto { + _winLotto; + + constructor(lotto) { + super(lotto); + this._winLotto = undefined; + this.set(lotto); + } + + static get DEFAULT_LENGTH() { + return 7; + } + + set(lotto) { + const lottoError = WinLotto.getLottoError(lotto); + + if (lottoError !== undefined) { + throw new Error(lottoError); + } + + this._winLotto = lotto; + } + + get() { + return [...this._winLotto]; + } + + checkRank(compareLotto) { + const compareLottoError = Lotto.getLottoError(compareLotto); + const winLottoError = WinLotto.getLottoError(this._winLotto); + + if (compareLottoError !== undefined || winLottoError !== undefined) { + return compareLottoError || winLottoError; + } + + const accordCount = accord( + this._winLotto.slice(0, LottoRule.DEFAULT_LENGTH), + compareLotto, + ); + const isBonusCorrect = compareLotto.includes(this._winLotto.at(-1)); + + return isBonusCorrect + ? WinLotto.RANK_BY_ACCORD[accordCount].bonus + : WinLotto.RANK_BY_ACCORD[accordCount].base; + } + + static getLottoError(lotto) { + const commonError = Lotto.getCommonLottoError(lotto); + + if (commonError !== undefined) { + return commonError; + } + + const lottoSet = new Set(lotto); + + if (lottoSet.size !== WinLotto.DEFAULT_LENGTH) { + return `당첨 로또 번호의 개수는 ${WinLotto.DEFAULT_LENGTH}개 여야 합니다.`; + } + + return undefined; + } + + static getBonusNumberError(bonusNumber) { + if (typeof bonusNumber !== 'number') { + return 'bonusNumber 가 숫자가 아닙니다.'; + } + + if (bonusNumber < Lotto.MIN_NUMBER || Lotto.MAX_NUMBER < bonusNumber) { + return 'bonusNumber 는 1 ~ 45 사이여야 합니다.'; + } + + return undefined; + } +} From 68aa915cf0d31a2096bf822f96632b3e0404fe6f Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:53:04 +0900 Subject: [PATCH 12/19] =?UTF-8?q?feat:=20main=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 96bab59..1e2e102 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,48 @@ -function main() { - console.log('main의 내용을 채워주세요'); +import View from './View/View.js'; +import LottoRule from './domain/LottoRule.js'; +import Lotto from './domain/Lotto.js'; +import WinLotto from './domain/WinLotto.js'; + +async function main() { + const view = new View(); + const money = await view.inputPurchaseLotto({ + postProcessFn: (input) => Number(input), + errorCheckFn: (input) => LottoRule.getMoneyError(input), + }); + const quantity = LottoRule.calculateQuantity(money); + const lottos = [...new Array(quantity)].map( + () => new Lotto(LottoRule.generateLottoNumber()), + ); + + view.printPurchaseLotto(quantity); + view.printAllLotto(lottos.map((lotto) => lotto.get())); + + const winPureLotto = await view.inputWinLotto({ + postProcessFn: (input) => input.split(',').map((el) => Number(el.trim())), + errorCheckFn: (input) => Lotto.getLottoError(input), + }); + const bonusNumber = await view.inputBonusNumber({ + postProcessFn: (input) => Number(input), + errorCheckFn: (input) => WinLotto.getBonusNumberError(input), + }); + const winLotto = new WinLotto([...winPureLotto, bonusNumber]); + const rankInfo = { + 1: 0, + 2: 0, + 3: 0, + 4: 0, + 5: 0, + }; + lottos.forEach((lotto) => { + rankInfo[winLotto.checkRank(lotto.get())] += 1; + }); + const totalMoney = Object.keys(rankInfo).reduce( + (money, rank) => money + rankInfo[rank] * LottoRule.REWARD[rank], + 0, + ); + + view.printAccordByRank(rankInfo); + view.printRate(totalMoney / money); } main(); From 40e6b10c2d387bdd5e92fc8cfc752cbe3f313df2 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 13:58:24 +0900 Subject: [PATCH 13/19] =?UTF-8?q?fix:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=98=B8=EC=B6=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/Lotto.js | 4 +++- src/domain/WinLotto.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/domain/Lotto.js b/src/domain/Lotto.js index 8de624f..73f7748 100644 --- a/src/domain/Lotto.js +++ b/src/domain/Lotto.js @@ -1,3 +1,5 @@ +import LottoRule from './LottoRule.js'; + export default class Lotto { _lotto; @@ -20,7 +22,7 @@ export default class Lotto { } static getLottoError(lotto) { - const commonError = Lotto.getCommonLottoError(lotto); + const commonError = LottoRule.getCommonLottoError(lotto); if (commonError !== undefined) return commonError; diff --git a/src/domain/WinLotto.js b/src/domain/WinLotto.js index b2b3b75..0b7345d 100644 --- a/src/domain/WinLotto.js +++ b/src/domain/WinLotto.js @@ -49,7 +49,7 @@ export default class WinLotto extends Lotto { } static getLottoError(lotto) { - const commonError = Lotto.getCommonLottoError(lotto); + const commonError = LottoRule.getCommonLottoError(lotto); if (commonError !== undefined) { return commonError; From 34d906c15699dd9ccb902c0f788bb8742be1be18 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 14:05:13 +0900 Subject: [PATCH 14/19] =?UTF-8?q?fix:=20WinLotto=20=EC=9D=98=20checkRank?= =?UTF-8?q?=20=EB=A9=94=EC=84=A3=EB=93=9C=EA=B0=80=20=EC=A0=9C=EB=8C=80?= =?UTF-8?q?=EB=A1=9C=20=EB=8F=99=EC=9E=91=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - LottoRule 의 RANK_BY_ACCORD 프로퍼티가 잘못 작성되어 있던 문제 - Lotto 가 LottoRule 을 상속받지 않도록 변경 --- src/domain/Lotto.js | 4 ++-- src/domain/LottoRule.js | 2 +- src/domain/WinLotto.js | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/domain/Lotto.js b/src/domain/Lotto.js index 73f7748..8bca27f 100644 --- a/src/domain/Lotto.js +++ b/src/domain/Lotto.js @@ -28,8 +28,8 @@ export default class Lotto { const lottoSet = new Set(lotto); - if (lottoSet.size !== Lotto.DEFAULT_LENGTH) { - return `일반 로또 번호의 개수는 ${Lotto.DEFAULT_LENGTH}개 여야 합니다.`; + if (lottoSet.size !== LottoRule.DEFAULT_LENGTH) { + return `일반 로또 번호의 개수는 ${LottoRule.DEFAULT_LENGTH}개 여야 합니다.`; } return undefined; diff --git a/src/domain/LottoRule.js b/src/domain/LottoRule.js index ae8b3ef..22ca3b8 100644 --- a/src/domain/LottoRule.js +++ b/src/domain/LottoRule.js @@ -3,7 +3,7 @@ import { changeStandardMoneyString } from '../utils/String.js'; export default class LottoRule { static RANK_BY_ACCORD = Object.freeze({ - 3: { bonus: 5, base: 3 }, + 3: { bonus: 5, base: 5 }, 4: { bonus: 4, base: 4 }, 5: { bonus: 2, base: 3 }, 6: { bonus: 1, base: 1 }, diff --git a/src/domain/WinLotto.js b/src/domain/WinLotto.js index 0b7345d..dc883da 100644 --- a/src/domain/WinLotto.js +++ b/src/domain/WinLotto.js @@ -7,7 +7,6 @@ export default class WinLotto extends Lotto { constructor(lotto) { super(lotto); - this._winLotto = undefined; this.set(lotto); } @@ -38,14 +37,14 @@ export default class WinLotto extends Lotto { } const accordCount = accord( - this._winLotto.slice(0, LottoRule.DEFAULT_LENGTH), + this.get().slice(0, LottoRule.DEFAULT_LENGTH), compareLotto, ); const isBonusCorrect = compareLotto.includes(this._winLotto.at(-1)); return isBonusCorrect - ? WinLotto.RANK_BY_ACCORD[accordCount].bonus - : WinLotto.RANK_BY_ACCORD[accordCount].base; + ? LottoRule.RANK_BY_ACCORD[accordCount].bonus + : LottoRule.RANK_BY_ACCORD[accordCount].base; } static getLottoError(lotto) { From fdc615b500438c8f1e2d2c015a663a2ed5d48c90 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 14:42:32 +0900 Subject: [PATCH 15/19] =?UTF-8?q?feat:=20WinLotto=20=EC=9D=98=20getBonusNu?= =?UTF-8?q?mberError=20=EA=B0=80=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC=EA=B0=80=20=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Lotto 의 static 이 아니라 LottoRule 의 static 을 참조하도록 변경 --- src/domain/WinLotto.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/domain/WinLotto.js b/src/domain/WinLotto.js index dc883da..3a92a49 100644 --- a/src/domain/WinLotto.js +++ b/src/domain/WinLotto.js @@ -68,7 +68,10 @@ export default class WinLotto extends Lotto { return 'bonusNumber 가 숫자가 아닙니다.'; } - if (bonusNumber < Lotto.MIN_NUMBER || Lotto.MAX_NUMBER < bonusNumber) { + if ( + bonusNumber < LottoRule.MIN_NUMBER || + LottoRule.MAX_NUMBER < bonusNumber + ) { return 'bonusNumber 는 1 ~ 45 사이여야 합니다.'; } From 445e96e92e616be6cb21685a1199dbe878c133fb Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 14:42:45 +0900 Subject: [PATCH 16/19] =?UTF-8?q?feat:=20WinLotto=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EC=97=90=20=EB=8C=80=ED=95=9C=20=EB=8B=A8=EC=9C=84=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/WinLotto.test.js | 148 +++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/__tests__/WinLotto.test.js diff --git a/src/__tests__/WinLotto.test.js b/src/__tests__/WinLotto.test.js new file mode 100644 index 0000000..045f8ca --- /dev/null +++ b/src/__tests__/WinLotto.test.js @@ -0,0 +1,148 @@ +import { describe, expect, test } from 'vitest'; +import WinLotto from '../domain/WinLotto'; + +describe('WinLotto 클래스 단위 테스트', () => { + const initialLotto = [1, 2, 3, 4, 5, 6, 7]; + + test('winLotto 를 초기화할 때 배열 길이가 7이 아니면 에러를 반환한다.', () => { + expect(() => { + makeWinLottoMockingData([1]); + }).toThrow(); + }); + + test('winLotto 를 초기화할 때 숫자로 이뤄진 배열이 아니면 에러를 반환한다.', () => { + expect(() => { + makeWinLottoMockingData(initialLotto.map(String)); + }).toThrow(); + }); + + test('winLotto 를 초기화할 때 중복되는 숫자가 있으면 에러를 반환한다.', () => { + expect(() => { + makeWinLottoMockingData([1, 1, 2, 3, 4, 5, 6]); + }).toThrow(); + }); + + test('winLotto 가 위 조건을 모두 통과하면 에러를 반환하지 않는다.', () => { + expect(() => { + makeWinLottoMockingData(initialLotto); + }).not.toThrow(); + }); + + test.each([ + { + lotto: [1, 2, 3, 4, 5, 6], + rank: 1, + }, + { + lotto: [1, 2, 3, 4, 5, 7], + rank: 2, + }, + { + lotto: [1, 2, 3, 4, 5, 8], + rank: 3, + }, + { + lotto: [1, 2, 3, 4, 8, 9], + rank: 4, + }, + { + lotto: [1, 2, 3, 8, 9, 10], + rank: 5, + }, + ])( + 'checkRank 메서드에 일반 로또($lotto)를 넣으면 당첨 로또와 일치하는 랭크($rank)를 반환한다.', + ({ lotto, rank }) => { + const winLotto = makeWinLottoMockingData(initialLotto); + + expect(winLotto.checkRank(lotto)).toBe(rank); + }, + ); + + test('get 메서드를 사용하면 현재 당첨 로또 번호 7자리를 가져온다.', () => { + const winLotto = makeWinLottoMockingData(initialLotto); + + expect(winLotto.get()).toStrictEqual(initialLotto); + }); + + test('set 메서드를 사용하면 해당 로또 번호를 바꿀 수 있다.', () => { + const winLotto = makeWinLottoMockingData(initialLotto); + const nextLotto = [2, 3, 4, 5, 6, 7, 8]; + winLotto.set(nextLotto); + + expect(winLotto.get()).toStrictEqual(nextLotto); + }); + + test.each([ + { lotto: 1 }, + { lotto: '1' }, + { lotto: {} }, + { lotto: null }, + { lotto: undefined }, + { lotto: function () {} }, + ])( + 'WinLotto의 getLottoError 메서드는 인수인 lotto($lotto)가 배열이 아닌 경우 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(WinLotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([ + { lotto: [0, 1, 2, 3, 4, 5, 6] }, + { lotto: [1, 2, 3, 4, 5, 6, 99] }, + ])( + 'winLotto의 getLottoError 메서드는 1 미만, 45 초과 숫자가 하나라도 있으면 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(WinLotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 1, 2, 3, 4, 5, 6] }])( + 'winLotto의 getLottoError 메서드는 중복되는 숫자가 하나라도 있으면 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(WinLotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5] }, { lotto: [1, 2, 3, 4, 5, 6, 7, 8] }])( + 'winLotto의 getLottoError 메서드는 배열의 길이가 7이 아닌 경우 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(WinLotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5, 6, 7] }])( + 'winLotto의 getLottoError 메서드는 위 조건을 모두 충족하면 undefined 를 반환한다.', + ({ lotto }) => { + expect(WinLotto.getLottoError(lotto)).toBeUndefined(); + }, + ); + + test.each([ + { bonusNumber: '1' }, + { bonusNumber: undefined }, + { bonusNumber: null }, + { bonusNumber: [] }, + { bonusNumber: {} }, + { bonusNumber: function () {} }, + ])( + 'winLotto 의 getBonusNumberError 는 bonusNumber($bonusNumber)가 숫자가 아닌 경우 undefined 를 반환하지 않는다.', + ({ bonusNumber }) => { + expect(WinLotto.getBonusNumberError(bonusNumber)).toBeDefined(); + }, + ); + + test.each([{ bonusNumber: 0 }, { bonusNumber: 46 }])( + 'winLotto 의 getBonusNumberError 는 bonusNumber($bonusNumber)가 1~45 사이의 숫자가 아닌 경우 undefined 를 반환하지 않는다..', + ({ bonusNumber }) => { + expect(WinLotto.getBonusNumberError(bonusNumber)).toBeDefined(); + }, + ); + + test('winLotto 의 getBonusNumberError 는 위 조건을 모두 통과하면 undefined 를 반환한다.', () => { + expect(WinLotto.getBonusNumberError(4)).toBeUndefined(); + }); +}); + +function makeWinLottoMockingData(initialLotto) { + return new WinLotto(initialLotto); +} From c1a762105974364565016d441c700c65e925d3b1 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 14:54:21 +0900 Subject: [PATCH 17/19] =?UTF-8?q?fix:=20Lotto=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EC=9D=B8=EC=8A=A4=ED=84=B4=EC=8A=A4=EA=B0=80=20?= =?UTF-8?q?=EC=98=AC=EB=B0=94=EB=A5=B8=20=EA=B0=92=EC=9D=B4=20=EC=95=84?= =?UTF-8?q?=EB=8B=90=20=EA=B2=BD=EC=9A=B0=20=EC=97=90=EB=9F=AC=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/Lotto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain/Lotto.js b/src/domain/Lotto.js index 8bca27f..df8b743 100644 --- a/src/domain/Lotto.js +++ b/src/domain/Lotto.js @@ -11,7 +11,7 @@ export default class Lotto { const lottoError = Lotto.getLottoError(lotto); if (lottoError !== undefined) { - return lottoError; + throw new Error(lottoError); } this._lotto = lotto; From eacbbfca9e9faa0767d9bb4a32fa82204dfbe295 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 14:54:34 +0900 Subject: [PATCH 18/19] =?UTF-8?q?feat:=20Lotto=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/Lotto.test.js | 94 +++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/__tests__/Lotto.test.js diff --git a/src/__tests__/Lotto.test.js b/src/__tests__/Lotto.test.js new file mode 100644 index 0000000..f234edc --- /dev/null +++ b/src/__tests__/Lotto.test.js @@ -0,0 +1,94 @@ +import { describe, expect, test } from 'vitest'; +import Lotto from '../domain/Lotto'; + +describe('Lotto 클래스에 대한 단위 테스트 작성', () => { + const initialLotto = [1, 2, 3, 4, 5, 6]; + + test.each([ + { lotto: '1' }, + { lotto: {} }, + { lotto: undefined }, + { lotto: null }, + { lotto: function () {} }, + ])( + 'lotto 초기화 시 인스턴스($lotto)가 배열이 아니면 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMockingData(lotto); + }).toThrow(); + }, + ); + + test.each([{ lotto: [0, 1, 2, 3, 4, 5] }, { lotto: [1, 2, 3, 4, 5, 99] }])( + 'lotto 초기화 시 인스턴스($lotto)의 요소가 1~45 범위를 벗어나는 숫자를 가지고 있으면 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMockingData(lotto); + }).toThrow(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5, 5] }])( + 'lotto 초기화 시 인스턴스($lotto)의 요소에 중복되지 않는 6개의 숫자로 이뤄지지 않았다면 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMockingData(lotto); + }).toThrow(); + }, + ); + + test('lotto 초기화시 인스턴스가 위 조건을 모두 충족하면 에러를 반환하지 않는다.', () => { + expect(() => { + makeLottoMockingData([1, 2, 3, 4, 5, 6]); + }).not.toThrow(); + }); + + test('get 메서드는 현재 lotto 의 값을 가져올 수 있다.', () => { + const lotto = makeLottoMockingData(initialLotto); + + expect(lotto.get()).toStrictEqual(initialLotto); + }); + + test('set 메서드는 현재 lotto 의 값을 바꿀 수 있다.', () => { + const lotto = makeLottoMockingData(initialLotto); + const nextLotto = [2, 3, 4, 5, 6, 7]; + lotto.set(nextLotto); + + expect(lotto.get()).toStrictEqual(nextLotto); + }); + + test.each([ + { lotto: '1' }, + { lotto: {} }, + { lotto: undefined }, + { lotto: null }, + { lotto: function () {} }, + ])( + 'getLottoError 메서드는 인수($lotto)가 배열이 아니면 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(Lotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [0, 1, 2, 3, 4, 5] }, { lotto: [1, 2, 3, 4, 5, 99] }])( + 'getLottoError 메서드는 인수($lotto)가 1~45 사이의 숫자로 이뤄져 있지 않으면 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(Lotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5, 5] }, { lotto: [1, 2, 3, 4, 5] }])( + 'getLottoError 메서드는 인수($lotto)가 중복되지 않는 1~45사이의 6개의 숫자로 이뤄져 있지 않으면 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(Lotto.getLottoError(lotto)).toBeDefined(); + }, + ); + + test('getLottoError 메서드는 위 조건을 모두 충족하면 undefined 를 반환한다.', () => { + expect(Lotto.getLottoError(initialLotto)).toBeUndefined(); + }); +}); + +function makeLottoMockingData(initialLotto) { + return new Lotto(initialLotto); +} From 25ddc4b4ca887bb648e4968a0a89dd7c02b27625 Mon Sep 17 00:00:00 2001 From: Suyeon Date: Tue, 9 Jul 2024 15:15:08 +0900 Subject: [PATCH 19/19] =?UTF-8?q?feat:=20LottoRule=20=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/LottoRule.test.js | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/__tests__/LottoRule.test.js diff --git a/src/__tests__/LottoRule.test.js b/src/__tests__/LottoRule.test.js new file mode 100644 index 0000000..2335209 --- /dev/null +++ b/src/__tests__/LottoRule.test.js @@ -0,0 +1,77 @@ +import { describe, expect, test } from 'vitest'; +import LottoRule from '../domain/LottoRule'; + +describe('LottoRule 클래스에 대한 단위 테스트 진행', () => { + test('generateLottoNumber 메서드는 1~45 사이의 숫자로 이뤄진 6개의 배열을 반환한다.', () => { + const lotto = LottoRule.generateLottoNumber(); + + lotto.forEach((num) => + expect(num).greaterThanOrEqual(1).lessThanOrEqual(45), + ); + }); + + test.each([ + { money: 1000, answer: 1 }, + { money: 1222, answer: 1 }, + { money: 2000, answer: 2 }, + ])( + `calculateQuantity 는 숫자 타입의 money($money) 를 받아 ${LottoRule.MONEY} 으로 나눈 몫($answer)을 반환한다.`, + ({ money, answer }) => { + expect(LottoRule.calculateQuantity(money)).toBe(answer); + }, + ); + + test.each([ + { money: '1000' }, + { money: {} }, + { money: [] }, + { money: function () {} }, + ])( + 'getMoneyError 는 money($money)가 숫자 타입이 아닌 경우 undefined 를 반환하지 않는다.', + ({ money }) => { + expect(LottoRule.getMoneyError(money)).toBeDefined(); + }, + ); + + test.each([{ money: 0 }, { money: -100 }])( + `getMoneyError 는 money($money)가 ${LottoRule.MONEY}보다 작은 숫자인 경우 undefined 를 반환하지 않는다.`, + ({ money }) => { + expect(LottoRule.getMoneyError(money)).toBeDefined(); + }, + ); + + test.each([{ money: 10000 }, { money: 1000 }])( + `getMoneyError 는 money($money)가 ${LottoRule.MONEY} 이상의 숫자인 경우 undefined 를 반환한다.`, + ({ money }) => { + expect(LottoRule.getMoneyError(money)).toBeUndefined(); + }, + ); + + test.each([ + { lotto: 1 }, + { lotto: '1' }, + { lotto: {} }, + { lotto: undefined }, + { lotto: null }, + { lotto: function () {} }, + ])( + 'getCommonLottoError는 인자 lotto ($lotto) 가 배열 타입이 아닌 경우 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(LottoRule.getCommonLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5, 99] }, { lotto: [0, 1, 2, 3, 4, 5] }])( + 'getCommonLottoError는 인자 lotto ($lotto) 의 요소가 1~45사이의 숫자를 가지지 않은 경우 undefined 를 반환하지 않는다.', + ({ lotto }) => { + expect(LottoRule.getCommonLottoError(lotto)).toBeDefined(); + }, + ); + + test.each([{ lotto: [1, 2, 3, 4, 5, 6] }, { lotto: [1, 2, 3, 4, 5, 6, 7] }])( + 'getCommonLottoError 의 인자 lotto ($lotto) 가 위 조건을 모두 통과하면 undefined 를 반환한다.', + ({ lotto }) => { + expect(LottoRule.getCommonLottoError(lotto)).toBeUndefined(); + }, + ); +});