diff --git a/.eslintrc.js b/.eslintrc.js index e0b62edef9b..6e223951991 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -48,6 +48,13 @@ module.exports = defineConfig({ leadingUnderscore: 'forbid', trailingUnderscore: 'forbid', }, + { + format: ['PascalCase'], + selector: ['typeParameter'], + prefix: ['T'], + leadingUnderscore: 'forbid', + trailingUnderscore: 'forbid', + }, ], '@typescript-eslint/no-inferrable-types': [ 'error', diff --git a/CHANGELOG.md b/CHANGELOG.md index c79b2b2d7f4..4dc364dcf89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [8.0.0-beta.1](https://github.com/faker-js/faker/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2023-05-06) + + +### Features + +* **helpers:** new method `objectEntry` ([#2123](https://github.com/faker-js/faker/issues/2123)) ([c092aa1](https://github.com/faker-js/faker/commit/c092aa1276a5c249de1ada47e807f12dd6de36f7)) + + +### Bug Fixes + +* **locale:** el county should be city_name ([#2106](https://github.com/faker-js/faker/issues/2106)) ([1cadfb9](https://github.com/faker-js/faker/commit/1cadfb97856da17047fcb5dcb504c3418eeed145)) +* **locale:** remove incorrect and unused city_prefix/suffix for sk ([#2117](https://github.com/faker-js/faker/issues/2117)) ([e094a5a](https://github.com/faker-js/faker/commit/e094a5a7b00bed7da3610bdbb949cc00320d5094)) +* **locale:** remove unrealistic fictional patterns in ne, ro, tr ([#2120](https://github.com/faker-js/faker/issues/2120)) ([d9ec87e](https://github.com/faker-js/faker/commit/d9ec87e6697ac3c814932c7e3ff6fa2e21d62f3a)) +* **locale:** rename city_prefix to city_name for en_NG, en_ZA, en_AU_ocker ([#2111](https://github.com/faker-js/faker/issues/2111)) ([a0fb69d](https://github.com/faker-js/faker/commit/a0fb69d666c85c40b1f8620dbfa0516e9872397f)) +* **location:** no leading zero on building number or secondary address ([#2032](https://github.com/faker-js/faker/issues/2032)) ([a8dc7e0](https://github.com/faker-js/faker/commit/a8dc7e07f6d5ee2ae38724ba5d503d7b88bd7147)) +* **test:** fix failing latitude test ([#2116](https://github.com/faker-js/faker/issues/2116)) ([7f9e9df](https://github.com/faker-js/faker/commit/7f9e9df4221d27b0b41a8ca04ea2cf69e7065613)) + + +### Changed Locales + +* **locale:** add city_name to city_patterns ([#2104](https://github.com/faker-js/faker/issues/2104)) ([b72d52e](https://github.com/faker-js/faker/commit/b72d52e5d5501579f6b98629d020292ceaa78c60)) + + +### New Locales + +* **locale:** add ro_MD locale ([#2084](https://github.com/faker-js/faker/issues/2084)) ([08cf1d8](https://github.com/faker-js/faker/commit/08cf1d85c8ba29991e47dc4b764172abb2cc0705)) + ## [8.0.0-beta.0](https://github.com/faker-js/faker/compare/v8.0.0-alpha.2...v8.0.0-beta.0) (2023-04-29) diff --git a/package.json b/package.json index 03e7a10177b..71ab176c8b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@faker-js/faker", - "version": "8.0.0-beta.0", + "version": "8.0.0-beta.1", "description": "Generate massive amounts of fake contextual data", "keywords": [ "faker", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43819a19ad7..598675fcfae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -293,8 +293,8 @@ packages: js-tokens: 4.0.0 dev: true - /@babel/parser@7.21.5: - resolution: {integrity: sha512-J+IxH2IsxV4HbnTrSWgMAQj0UEo61hDA4Ny8h8PCX0MLXiibqHbqIOVneqdocemSBc22VpBKxt4J6FQzy9HarQ==} + /@babel/parser@7.21.8: + resolution: {integrity: sha512-6zavDGdzG3gUqAdWvlLFfk+36RilI+Pwyuuh7HItyeScCWP3k6i8vKclAQ0bM/0y/Kz/xiwvxhMv9MgTJP5gmA==} engines: {node: '>=6.0.0'} hasBin: true dependencies: @@ -630,21 +630,21 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.39.0 - eslint-visitor-keys: 3.4.0 + eslint-visitor-keys: 3.4.1 dev: true - /@eslint-community/regexpp@4.5.0: - resolution: {integrity: sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==} + /@eslint-community/regexpp@4.5.1: + resolution: {integrity: sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true - /@eslint/eslintrc@2.0.2: - resolution: {integrity: sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==} + /@eslint/eslintrc@2.0.3: + resolution: {integrity: sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 debug: 4.3.4(supports-color@8.1.1) - espree: 9.5.1 + espree: 9.5.2 globals: 13.20.0 ignore: 5.2.4 import-fresh: 3.3.0 @@ -685,6 +685,18 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@isaacs/cliui@8.0.2: + resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} + engines: {node: '>=12'} + dependencies: + string-width: 5.1.2 + string-width-cjs: /string-width@4.2.3 + strip-ansi: 7.0.1 + strip-ansi-cjs: /strip-ansi@6.0.1 + wrap-ansi: 8.1.0 + wrap-ansi-cjs: /wrap-ansi@7.0.0 + dev: true + /@istanbuljs/schema@0.1.3: resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -878,8 +890,8 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node@14.18.43: - resolution: {integrity: sha512-n3eFEaoem0WNwLux+k272P0+aq++5o05bA9CfiwKPdYPB5ZambWKdWoeHy7/OJiizMhzg27NLaZ6uzjLTzXceQ==} + /@types/node@14.18.45: + resolution: {integrity: sha512-Nd+FPp60jEaJpm4LAxuLT3wIhB4k0Jdj9DAP4ydqGyMg8DhE+7oM1we+QkwOkpMySTjcqcNfPOWY5kBuAOhkeg==} dev: true /@types/node@18.16.3: @@ -955,7 +967,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.5.0 + '@eslint-community/regexpp': 4.5.1 '@typescript-eslint/parser': 5.59.1(eslint@8.39.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.59.1 '@typescript-eslint/type-utils': 5.59.1(eslint@8.39.0)(typescript@4.9.5) @@ -1000,6 +1012,14 @@ packages: '@typescript-eslint/visitor-keys': 5.59.1 dev: true + /@typescript-eslint/scope-manager@5.59.2: + resolution: {integrity: sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.59.2 + '@typescript-eslint/visitor-keys': 5.59.2 + dev: true + /@typescript-eslint/type-utils@5.59.1(eslint@8.39.0)(typescript@4.9.5): resolution: {integrity: sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1025,6 +1045,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@typescript-eslint/types@5.59.2: + resolution: {integrity: sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /@typescript-eslint/typescript-estree@5.59.1(typescript@4.9.5): resolution: {integrity: sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1046,6 +1071,27 @@ packages: - supports-color dev: true + /@typescript-eslint/typescript-estree@5.59.2(typescript@4.9.5): + resolution: {integrity: sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 5.59.2 + '@typescript-eslint/visitor-keys': 5.59.2 + debug: 4.3.4(supports-color@8.1.1) + globby: 11.1.0 + is-glob: 4.0.3 + semver: 7.5.0 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/utils@5.59.1(eslint@8.39.0)(typescript@4.9.5): resolution: {integrity: sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1066,12 +1112,40 @@ packages: - typescript dev: true + /@typescript-eslint/utils@5.59.2(eslint@8.39.0)(typescript@4.9.5): + resolution: {integrity: sha512-kSuF6/77TZzyGPhGO4uVp+f0SBoYxCDf+lW3GKhtKru/L8k/Hd7NFQxyWUeY7Z/KGB2C6Fe3yf2vVi4V9TsCSQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.39.0) + '@types/json-schema': 7.0.11 + '@types/semver': 7.3.13 + '@typescript-eslint/scope-manager': 5.59.2 + '@typescript-eslint/types': 5.59.2 + '@typescript-eslint/typescript-estree': 5.59.2(typescript@4.9.5) + eslint: 8.39.0 + eslint-scope: 5.1.1 + semver: 7.5.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/visitor-keys@5.59.1: resolution: {integrity: sha512-6waEYwBTCWryx0VJmP7JaM4FpipLsFl9CvYf2foAE8Qh/Y0s+bxWysciwOs0LTBED4JCaNxTZ5rGadB14M6dwA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.59.1 - eslint-visitor-keys: 3.4.0 + eslint-visitor-keys: 3.4.1 + dev: true + + /@typescript-eslint/visitor-keys@5.59.2: + resolution: {integrity: sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.59.2 + eslint-visitor-keys: 3.4.1 dev: true /@vitejs/plugin-vue@4.2.1(vite@4.3.3)(vue@3.2.47): @@ -1092,7 +1166,7 @@ packages: dependencies: c8: 7.13.0 picocolors: 1.0.0 - std-env: 3.3.2 + std-env: 3.3.3 vitest: 0.30.1(@vitest/ui@0.30.1) dev: true @@ -1150,7 +1224,7 @@ packages: /@vue/compiler-core@3.2.47: resolution: {integrity: sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==} dependencies: - '@babel/parser': 7.21.5 + '@babel/parser': 7.21.8 '@vue/shared': 3.2.47 estree-walker: 2.0.2 source-map: 0.6.1 @@ -1166,7 +1240,7 @@ packages: /@vue/compiler-sfc@3.2.47: resolution: {integrity: sha512-rog05W+2IFfxjMcFw10tM9+f7i/+FFpZJJ5XHX72NP9eC2uRD+42M3pYcQqDXVYoj74kHMSEdQ/WmCjt8JFksQ==} dependencies: - '@babel/parser': 7.21.5 + '@babel/parser': 7.21.8 '@vue/compiler-core': 3.2.47 '@vue/compiler-dom': 3.2.47 '@vue/compiler-ssr': 3.2.47 @@ -1192,7 +1266,7 @@ packages: /@vue/reactivity-transform@3.2.47: resolution: {integrity: sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==} dependencies: - '@babel/parser': 7.21.5 + '@babel/parser': 7.21.8 '@vue/compiler-core': 3.2.47 '@vue/shared': 3.2.47 estree-walker: 2.0.2 @@ -1343,6 +1417,11 @@ packages: engines: {node: '>=8'} dev: true + /ansi-regex@6.0.1: + resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} + engines: {node: '>=12'} + dev: true + /ansi-sequence-parser@1.1.0: resolution: {integrity: sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==} dev: true @@ -1366,6 +1445,11 @@ packages: engines: {node: '>=10'} dev: true + /ansi-styles@6.2.1: + resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} + engines: {node: '>=12'} + dev: true + /arch@2.2.0: resolution: {integrity: sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==} dev: true @@ -1665,15 +1749,6 @@ packages: wrap-ansi: 7.0.0 dev: true - /cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - dev: true - /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -1981,7 +2056,7 @@ packages: dependencies: '@cypress/request': 2.88.11 '@cypress/xvfb': 1.2.4(supports-color@8.1.1) - '@types/node': 14.18.43 + '@types/node': 14.18.45 '@types/sinonjs__fake-timers': 8.1.1 '@types/sizzle': 2.3.3 arch: 2.2.0 @@ -2187,6 +2262,10 @@ packages: minimatch: 3.1.2 dev: true + /eastasianwidth@0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + dev: true + /ecc-jsbn@0.1.2: resolution: {integrity: sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==} dependencies: @@ -2198,6 +2277,10 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true + /emoji-regex@9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + dev: true + /end-of-stream@1.4.4: resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} dependencies: @@ -2365,7 +2448,7 @@ packages: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 typescript: ^3.7.5 || ^4.0.0 || ^5.0.0 dependencies: - '@typescript-eslint/utils': 5.59.1(eslint@8.39.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.59.2(eslint@8.39.0)(typescript@4.9.5) eslint: 8.39.0 tslib: 2.5.0 tsutils: 3.21.0(typescript@4.9.5) @@ -2426,8 +2509,8 @@ packages: estraverse: 5.3.0 dev: true - /eslint-visitor-keys@3.4.0: - resolution: {integrity: sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==} + /eslint-visitor-keys@3.4.1: + resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -2437,8 +2520,8 @@ packages: hasBin: true dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.39.0) - '@eslint-community/regexpp': 4.5.0 - '@eslint/eslintrc': 2.0.2 + '@eslint-community/regexpp': 4.5.1 + '@eslint/eslintrc': 2.0.3 '@eslint/js': 8.39.0 '@humanwhocodes/config-array': 0.11.8 '@humanwhocodes/module-importer': 1.0.1 @@ -2450,8 +2533,8 @@ packages: doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.0 - eslint-visitor-keys: 3.4.0 - espree: 9.5.1 + eslint-visitor-keys: 3.4.1 + espree: 9.5.2 esquery: 1.5.0 esutils: 2.0.3 fast-deep-equal: 3.1.3 @@ -2480,13 +2563,13 @@ packages: - supports-color dev: true - /espree@9.5.1: - resolution: {integrity: sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==} + /espree@9.5.2: + resolution: {integrity: sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: acorn: 8.8.2 acorn-jsx: 5.3.2(acorn@8.8.2) - eslint-visitor-keys: 3.4.0 + eslint-visitor-keys: 3.4.1 dev: true /esquery@1.5.0: @@ -2866,7 +2949,7 @@ packages: hasBin: true dependencies: foreground-child: 3.1.1 - jackspeak: 2.1.1 + jackspeak: 2.2.0 minimatch: 9.0.0 minipass: 5.0.0 path-scurry: 1.7.0 @@ -3299,11 +3382,11 @@ packages: istanbul-lib-report: 3.0.0 dev: true - /jackspeak@2.1.1: - resolution: {integrity: sha512-juf9stUEwUaILepraGOWIJTLwg48bUnBmRqd2ln2Os1sW987zeoj/hzhbvRB95oMuS2ZTpjULmdwHNX4rzZIZw==} + /jackspeak@2.2.0: + resolution: {integrity: sha512-r5XBrqIJfwRIjRt/Xr5fv9Wh09qyhHfKnYddDlpM+ibRR20qrYActpCAgU6U+d53EOEjzkvxPMVHSlgR7leXrQ==} engines: {node: '>=14'} dependencies: - cliui: 8.0.1 + '@isaacs/cliui': 8.0.2 optionalDependencies: '@pkgjs/parseargs': 0.11.0 dev: true @@ -3686,8 +3769,8 @@ packages: dependencies: acorn: 8.8.2 pathe: 1.1.0 - pkg-types: 1.0.2 - ufo: 1.1.1 + pkg-types: 1.0.3 + ufo: 1.1.2 dev: true /modify-values@1.0.1: @@ -4024,8 +4107,8 @@ packages: engines: {node: '>=4'} dev: true - /pkg-types@1.0.2: - resolution: {integrity: sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==} + /pkg-types@1.0.3: + resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} dependencies: jsonc-parser: 3.2.0 mlly: 1.2.0 @@ -4291,8 +4374,8 @@ packages: glob: 10.2.2 dev: true - /rollup@3.21.1: - resolution: {integrity: sha512-GpUgqWCw56OSiBKf7lcAITstYiBV1/EKaKYPl9r8HgAxc6/qYAVw1PaHWnvHWFziRaf4HsVCDLq/IGtBi1K/Zw==} + /rollup@3.21.5: + resolution: {integrity: sha512-a4NTKS4u9PusbUJcfF4IMxuqjFzjm6ifj76P54a7cKnvVzJaG12BLVR+hgU2YDGHzyMMQNxLAZWuALsn8q2oQg==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -4553,8 +4636,8 @@ packages: yargs: 16.2.0 dev: true - /std-env@3.3.2: - resolution: {integrity: sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==} + /std-env@3.3.3: + resolution: {integrity: sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==} dev: true /string-width@4.2.3: @@ -4566,6 +4649,15 @@ packages: strip-ansi: 6.0.1 dev: true + /string-width@5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.0.1 + dev: true + /string.prototype.padend@3.1.4: resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} engines: {node: '>= 0.4'} @@ -4624,6 +4716,13 @@ packages: ansi-regex: 5.0.1 dev: true + /strip-ansi@7.0.1: + resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==} + engines: {node: '>=12'} + dependencies: + ansi-regex: 6.0.1 + dev: true + /strip-bom@3.0.0: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} @@ -4903,8 +5002,8 @@ packages: hasBin: true dev: true - /ufo@1.1.1: - resolution: {integrity: sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==} + /ufo@1.1.2: + resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} dev: true /uglify-js@3.17.4: @@ -4981,7 +5080,7 @@ packages: dev: true /verror@1.10.0: - resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==} + resolution: {integrity: sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=} engines: {'0': node >=0.6.0} dependencies: assert-plus: 1.0.0 @@ -5038,7 +5137,7 @@ packages: '@types/node': 18.16.3 esbuild: 0.17.18 postcss: 8.4.23 - rollup: 3.21.1 + rollup: 3.21.5 optionalDependencies: fsevents: 2.3.2 dev: true @@ -5123,7 +5222,7 @@ packages: pathe: 1.1.0 picocolors: 1.0.0 source-map: 0.6.1 - std-env: 3.3.2 + std-env: 3.3.3 strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.4.0 @@ -5261,6 +5360,15 @@ packages: strip-ansi: 6.0.1 dev: true + /wrap-ansi@8.1.0: + resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} + engines: {node: '>=12'} + dependencies: + ansi-styles: 6.2.1 + string-width: 5.1.2 + strip-ansi: 7.0.1 + dev: true + /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true diff --git a/scripts/apidoc/utils.ts b/scripts/apidoc/utils.ts index 8a002f49335..4f8d34404e6 100644 --- a/scripts/apidoc/utils.ts +++ b/scripts/apidoc/utils.ts @@ -47,10 +47,10 @@ export function adjustUrls(description: string): string { return description.replace(/https:\/\/(next.)?fakerjs.dev\//g, '/'); } -export function mapByName( - input: T[], - valueExtractor: (item: T) => V -): Record { +export function mapByName( + input: TInput[], + valueExtractor: (item: TInput) => TValue +): Record { return input.reduce( (acc, item) => ({ ...acc, [item.name]: valueExtractor(item) }), {} diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 591b6810bbc..b1c4db0e921 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -40,9 +40,10 @@ const pathDocsGuideLocalization = resolve( ); // Workaround for nameOf -type PascalCase = S extends `${infer P1}_${infer P2}` - ? `${Capitalize}${PascalCase}` - : Capitalize; +type PascalCase = + TName extends `${infer Prefix}_${infer Remainder}` + ? `${Capitalize}${PascalCase}` + : Capitalize; type DefinitionType = { [key in keyof LocaleDefinition]-?: PascalCase<`${key}Definition`>; diff --git a/src/definitions/definitions.ts b/src/definitions/definitions.ts index 30f965c30a9..ca495e3477a 100644 --- a/src/definitions/definitions.ts +++ b/src/definitions/definitions.ts @@ -22,8 +22,8 @@ import type { WordDefinition } from './word'; /** * Wrapper type for all definition categories that will make all properties optional and allow extra properties. */ -export type LocaleEntry> = { - [P in keyof T]?: T[P] | null; +export type LocaleEntry> = { + [P in keyof TCategoryDefinition]?: TCategoryDefinition[P] | null; } & Record; // Unsupported & custom entries /** diff --git a/src/locale-proxy.ts b/src/locale-proxy.ts index a4dcc01843e..47b371d66c8 100644 --- a/src/locale-proxy.ts +++ b/src/locale-proxy.ts @@ -61,21 +61,21 @@ export function createLocaleProxy(locale: LocaleDefinition): LocaleProxy { * @param categoryData The module to create the proxy for. */ function createCategoryProxy< - CategoryData extends Record + TCategoryData extends Record >( categoryName: string, - categoryData: CategoryData = {} as CategoryData -): Required { + categoryData: TCategoryData = {} as TCategoryData +): Required { return new Proxy(categoryData, { - has(target: CategoryData, entryName: keyof CategoryData): boolean { + has(target: TCategoryData, entryName: keyof TCategoryData): boolean { const value = target[entryName]; return value != null; }, get( - target: CategoryData, - entryName: keyof CategoryData - ): CategoryData[keyof CategoryData] { + target: TCategoryData, + entryName: keyof TCategoryData + ): TCategoryData[keyof TCategoryData] { const value = target[entryName]; if (typeof entryName === 'symbol' || entryName === 'nodeType') { return value; @@ -97,5 +97,5 @@ function createCategoryProxy< set: throwReadOnlyError, deleteProperty: throwReadOnlyError, - }) as Required; + }) as Required; } diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index e6cf9075b9d..3db15ca4141 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -732,7 +732,7 @@ export class HelpersModule { /** * Returns the result of the callback if the probability check was successful, otherwise `undefined`. * - * @template T The type of result of the given callback. + * @template TResult The type of result of the given callback. * * @param callback The callback to that will be invoked if the probability check was successful. * @param options The options to use. Defaults to `{}`. @@ -745,8 +745,8 @@ export class HelpersModule { * * @since 6.3.0 */ - maybe( - callback: () => T, + maybe( + callback: () => TResult, options: { /** * The probability (`[0.00, 1.00]`) of the callback being invoked. @@ -755,7 +755,7 @@ export class HelpersModule { */ probability?: number; } = {} - ): T | undefined { + ): TResult | undefined { if (this.faker.datatype.boolean(options)) { return callback(); } @@ -990,7 +990,7 @@ export class HelpersModule { * * This does the same as `objectValue` except that it ignores (the values assigned to) the numeric keys added for TypeScript enums. * - * @template EnumType Type of generic enums, automatically inferred by TypeScript. + * @template T Type of generic enums, automatically inferred by TypeScript. * * @param enumObject Enum to pick the value from. * @@ -1006,11 +1006,11 @@ export class HelpersModule { * * @since 8.0.0 */ - enumValue>( - enumObject: EnumType - ): EnumType[keyof EnumType] { + enumValue>( + enumObject: T + ): T[keyof T] { // ignore numeric keys added by TypeScript - const keys: Array = Object.keys(enumObject).filter((key) => + const keys: Array = Object.keys(enumObject).filter((key) => isNaN(Number(key)) ); const randomKey = this.arrayElement(keys); @@ -1280,7 +1280,7 @@ export class HelpersModule { * Generates a unique result using the results of the given method. * Used unique entries will be stored internally and filtered from subsequent calls. * - * @template Method The type of the method to execute. + * @template TMethod The type of the method to execute. * * @param method The method used to generate the values. * @param args The arguments used to call the method. @@ -1304,14 +1304,14 @@ export class HelpersModule { * More info can be found in issue [faker-js/faker #1785](https://github.com/faker-js/faker/issues/1785). */ unique< - Method extends ( + TMethod extends ( // TODO @Shinigami92 2023-02-14: This `any` type can be fixed by anyone if they want to. // eslint-disable-next-line @typescript-eslint/no-explicit-any ...parameters: any[] ) => RecordKey >( - method: Method, - args: Parameters = [] as Parameters, + method: TMethod, + args: Parameters = [] as Parameters, options: { /** * This parameter does nothing. @@ -1358,7 +1358,7 @@ export class HelpersModule { */ store?: Record; } = {} - ): ReturnType { + ): ReturnType { deprecated({ deprecated: 'faker.helpers.unique', proposed: @@ -1387,7 +1387,7 @@ export class HelpersModule { /** * Generates an array containing values returned by the given method. * - * @template T The type of elements. + * @template TResult The type of elements. * * @param method The method used to generate the values. * @param options The optional options object. @@ -1399,8 +1399,8 @@ export class HelpersModule { * * @since 8.0.0 */ - multiple( - method: () => T, + multiple( + method: () => TResult, options: { /** * The number or range of elements to generate. @@ -1420,7 +1420,7 @@ export class HelpersModule { max: number; }; } = {} - ): T[] { + ): TResult[] { const count = this.rangeToNumber(options.count ?? 3); if (count <= 0) { return []; diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts index 90896c6425d..d6bede7ae44 100644 --- a/src/modules/helpers/unique.ts +++ b/src/modules/helpers/unique.ts @@ -57,7 +57,7 @@ Try adjusting maxTime or maxRetries parameters for faker.helpers.unique().` * Generates a unique result using the results of the given method. * Used unique entries will be stored internally and filtered from subsequent calls. * - * @template Method The type of the method to execute. + * @template TMethod The type of the method to execute. * * @param method The method used to generate the values. * @param args The arguments used to call the method. @@ -71,14 +71,14 @@ Try adjusting maxTime or maxRetries parameters for faker.helpers.unique().` * @param options.store The store of unique entries. Defaults to `GLOBAL_UNIQUE_STORE`. */ export function exec< - Method extends ( + TMethod extends ( // TODO @Shinigami92 2023-02-14: This `any` type can be fixed by anyone if they want to. // eslint-disable-next-line @typescript-eslint/no-explicit-any ...parameters: any[] ) => RecordKey >( - method: Method, - args: Parameters, + method: TMethod, + args: Parameters, options: { startTime?: number; maxTime?: number; @@ -88,7 +88,7 @@ export function exec< compare?: (obj: Record, key: RecordKey) => 0 | -1; store?: Record; } = {} -): ReturnType { +): ReturnType { const now = new Date().getTime(); const { @@ -132,7 +132,7 @@ export function exec< } // Execute the provided method to find a potential satisfied value. - const result: ReturnType = method(...args) as ReturnType; + const result: ReturnType = method(...args) as ReturnType; // If the result has not been previously found, add it to the found array and return the value as it's unique. if (compare(store, result) === -1 && exclude.indexOf(result) === -1) { diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 5b5d37a1c8c..1b8455d0e80 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -140,7 +140,7 @@ export class LocationModule { } /** - * Generates a random fictional city name for the locale. + * Generates a random localized city name. * * @example * faker.location.city() // 'East Jarretmouth' diff --git a/src/utils/types.ts b/src/utils/types.ts index 8c1bfe6bc23..c7aaf86c133 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -3,9 +3,9 @@ * * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609 */ -export type LiteralUnion = - | T - | (U & { zz_IGNORE_ME?: never }); +export type LiteralUnion = + | TSuggested + | (TBase & { zz_IGNORE_ME?: never }); /** * A function that returns a value. @@ -22,18 +22,18 @@ export type Callable = ( /** * Type that represents a single method/function name of the given type. */ -export type MethodOf = { - [Key in keyof ObjectType]: ObjectType[Key] extends Signature +export type MethodOf = { + [Key in keyof TObjectType]: TObjectType[Key] extends TSignature ? Key extends string ? Key : never : never; -}[keyof ObjectType]; +}[keyof TObjectType]; /** * Type that represents all method/function names of the given type. */ export type MethodsOf< - ObjectType, - Signature extends Callable = Callable -> = ReadonlyArray>; + TObjectType, + TSignature extends Callable = Callable +> = ReadonlyArray>; diff --git a/test/all_functional.spec.ts b/test/all_functional.spec.ts index 2035f32e932..f18e5feca68 100644 --- a/test/all_functional.spec.ts +++ b/test/all_functional.spec.ts @@ -18,8 +18,8 @@ function isMethodOf(mod: string) { return (meth: string) => typeof fakerEN[mod][meth] === 'function'; } -type SkipConfig = Partial< - Record> +type SkipConfig = Partial< + Record> >; const BROKEN_LOCALE_METHODS = { diff --git a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap index 15bb4d00b25..525b676c4d0 100644 --- a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap +++ b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap @@ -43,7 +43,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = ` "returns": "T", "seeAlsos": [], "since": "", - "sourcePath": "test/scripts/apidoc/signature.example.ts#L356", + "sourcePath": "test/scripts/apidoc/signature.example.ts#L357", "throws": undefined, } `; diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts index 6bb835c1819..5d557a3f3b9 100644 --- a/test/scripts/apidoc/signature.example.ts +++ b/test/scripts/apidoc/signature.example.ts @@ -349,6 +349,7 @@ export class SignatureTest { * Complex array parameter. * * @template T The type of the entries to pick from. + * * @param array Array to pick the value from. * @param array[].weight The weight of the value. * @param array[].value The value to pick. diff --git a/test/support/seededRuns.ts b/test/support/seededRuns.ts index 5926fb5c4ed..74db7208c82 100644 --- a/test/support/seededRuns.ts +++ b/test/support/seededRuns.ts @@ -30,15 +30,15 @@ type OnlyMethodsFaker = { /** * The type allowing only the names of methods that have exactly zero arguments. */ -type NoArgsMethodOf = MethodOf & +type NoArgsMethodOf = MethodOf & { - [Key in MethodOf unknown>]: ObjectType[Key] extends ( + [Key in MethodOf unknown>]: TObjectType[Key] extends ( arg0: string | number | boolean | Record, ...args: unknown[] ) => unknown ? Key : never; - }[MethodOf unknown>]; + }[MethodOf unknown>]; /** * Method that prepares seeded tests. @@ -68,19 +68,16 @@ type NoArgsMethodOf = MethodOf & * }) */ export function seededTests< - K extends FakerModule, - M extends Record = OnlyMethodsFaker[K] + TFakerModule extends FakerModule, + TModule extends Record = OnlyMethodsFaker[TFakerModule] >( faker: Faker, - module: K, - factory: (tg: TestGenerator, setup: () => void) => void + module: TFakerModule, + factory: (tg: TestGenerator, setup: () => void) => void ): void { describe.each(seededRuns)('%s', (seed) => { - const testGenerator: TestGenerator = new TestGenerator( - faker, - seed, - module - ); + const testGenerator: TestGenerator = + new TestGenerator(faker, seed, module); factory(testGenerator, () => testGenerator.setup()); testGenerator.expectAllMethodsToBeTested(); @@ -93,18 +90,18 @@ export function seededTests< * The individual methods generate default test blocks, that use test snapshots to verify consistent return values. */ class TestGenerator< - ModuleName extends FakerModule, - Module extends Record = OnlyMethodsFaker[ModuleName] + TModuleName extends FakerModule, + TModule extends Record = OnlyMethodsFaker[TModuleName] > { - private readonly tested: Set> = new Set(); - private readonly module: Module; + private readonly tested: Set> = new Set(); + private readonly module: TModule; constructor( private readonly faker: Faker, private readonly seed: number, - private readonly moduleName: ModuleName + private readonly moduleName: TModuleName ) { - this.module = this.faker[moduleName] as unknown as Module; + this.module = this.faker[moduleName] as unknown as TModule; } /** @@ -112,7 +109,7 @@ class TestGenerator< * * @param method The method name to check. */ - private expectNotTested(method: MethodOf): void { + private expectNotTested(method: MethodOf): void { expect( this.tested.has(method), `${method} not to be tested yet` @@ -139,9 +136,9 @@ class TestGenerator< * @param args The arguments to call it with. * @param repetitions The number of times to call it. */ - private callAndVerify>( - method: MethodName, - args: Parameters, + private callAndVerify>( + method: TMethodName, + args: Parameters, repetitions: number = 1 ): void { this.setup(); @@ -157,7 +154,7 @@ class TestGenerator< * * @param method The name of the method. */ - skip(method: MethodOf): this { + skip(method: MethodOf): this { this.expectNotTested(method); vi_it.skip(method); return this; @@ -170,7 +167,7 @@ class TestGenerator< * * @deprecated Implement a proper test. */ - todo(method: MethodOf): this { + todo(method: MethodOf): this { this.expectNotTested(method); vi_it.todo(method); return this; @@ -181,7 +178,7 @@ class TestGenerator< * * @param method The name of the method. */ - it>(method: MethodName): this { + it>(method: TMethodName): this { return this.itRepeated(method, 1); } @@ -192,15 +189,15 @@ class TestGenerator< * @param method The name of the method. * @param repetitions The number of repetitions to run. */ - itRepeated>( - method: MethodName, + itRepeated>( + method: TMethodName, repetitions: number ): this { this.expectNotTested(method); vi_it(method, () => this.callAndVerify( method, - [] as unknown as Parameters, + [] as unknown as Parameters, repetitions ) ); @@ -212,8 +209,8 @@ class TestGenerator< * * @param methods The names of the methods. */ - itEach>( - ...methods: MethodName[] + itEach>( + ...methods: TMethodName[] ): this { for (const method of methods) { this.it(method); @@ -229,12 +226,12 @@ class TestGenerator< * @param method The name of the method. * @param factory The factory used to generate the individual tests. */ - describe>( - method: MethodName, - factory: (tester: MethodTester) => void + describe>( + method: TMethodName, + factory: (tester: MethodTester) => void ): this { this.expectNotTested(method); - const callAndVerify: TestGenerator['callAndVerify'] = + const callAndVerify: TestGenerator['callAndVerify'] = this.callAndVerify.bind(this); const variantNames = new Set(); const expectVariantNotTested = (name: string): void => { @@ -245,8 +242,8 @@ class TestGenerator< variantNames.add(name); }; - const tester: MethodTester = { - it(name: string, ...args: Parameters) { + const tester: MethodTester = { + it(name: string, ...args: Parameters) { expectVariantNotTested(name); vi_it(name, () => callAndVerify(method, args)); return tester; @@ -254,7 +251,7 @@ class TestGenerator< itRepeated( name: string, repetitions: number, - ...args: Parameters + ...args: Parameters ) { expectVariantNotTested(name); vi_it(name, () => callAndVerify(method, args, repetitions)); @@ -273,9 +270,9 @@ class TestGenerator< * * @param methods The names of the methods to generate the tests for. */ - describeEach>( - ...methods: MethodName[] - ): (factory: (tester: MethodTester) => void) => this { + describeEach>( + ...methods: TMethodName[] + ): (factory: (tester: MethodTester) => void) => this { return (factory) => { for (const method of methods) { this.describe(method, factory); @@ -306,14 +303,14 @@ class TestGenerator< /** * Simple interface for a test generator for a given method. */ -interface MethodTester { +interface MethodTester { /** * Generates a test for the method. * * @param name The name of the test case. * @param args The arguments to use in the test. */ - it(name: string, ...args: Parameters): this; + it(name: string, ...args: Parameters): this; /** * Generates a repeated test for the method. @@ -326,6 +323,6 @@ interface MethodTester { itRepeated( name: string, repetitions: number, - ...args: Parameters + ...args: Parameters ): this; }