From f7471a225f388c6bc0ec47ebad759ee1051e1106 Mon Sep 17 00:00:00 2001 From: Miraziz Khidoyatov <49793609+Mirazyzz@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:05:10 +0100 Subject: [PATCH 1/5] feat(locale): add uzbek locale (uz_UZ_latin) (#2686) --- docs/guide/localization.md | 1 + src/locale/index.ts | 3 + src/locale/uz_UZ_latin.ts | 13 + src/locales/index.ts | 1 + src/locales/uz_UZ_latin/index.ts | 14 ++ src/locales/uz_UZ_latin/metadata.ts | 14 ++ src/locales/uz_UZ_latin/person/bio_parts.ts | 37 +++ .../uz_UZ_latin/person/female_first_name.ts | 135 +++++++++++ .../uz_UZ_latin/person/female_last_name.ts | 211 ++++++++++++++++ .../person/female_last_name_pattern.ts | 1 + src/locales/uz_UZ_latin/person/index.ts | 28 +++ src/locales/uz_UZ_latin/person/job_title.ts | 26 ++ .../uz_UZ_latin/person/male_first_name.ts | 229 ++++++++++++++++++ .../uz_UZ_latin/person/male_last_name.ts | 211 ++++++++++++++++ .../person/male_last_name_pattern.ts | 1 + src/locales/uz_UZ_latin/person/sex.ts | 1 + 16 files changed, 926 insertions(+) create mode 100644 src/locale/uz_UZ_latin.ts create mode 100644 src/locales/uz_UZ_latin/index.ts create mode 100644 src/locales/uz_UZ_latin/metadata.ts create mode 100644 src/locales/uz_UZ_latin/person/bio_parts.ts create mode 100644 src/locales/uz_UZ_latin/person/female_first_name.ts create mode 100644 src/locales/uz_UZ_latin/person/female_last_name.ts create mode 100644 src/locales/uz_UZ_latin/person/female_last_name_pattern.ts create mode 100644 src/locales/uz_UZ_latin/person/index.ts create mode 100644 src/locales/uz_UZ_latin/person/job_title.ts create mode 100644 src/locales/uz_UZ_latin/person/male_first_name.ts create mode 100644 src/locales/uz_UZ_latin/person/male_last_name.ts create mode 100644 src/locales/uz_UZ_latin/person/male_last_name_pattern.ts create mode 100644 src/locales/uz_UZ_latin/person/sex.ts diff --git a/docs/guide/localization.md b/docs/guide/localization.md index 8f8c1333d5b..a351ef4069d 100644 --- a/docs/guide/localization.md +++ b/docs/guide/localization.md @@ -137,6 +137,7 @@ In this example there are 5 locales. Each of these is checked in order, and the | `tr` | Turkish | `fakerTR` | | `uk` | Ukrainian | `fakerUK` | | `ur` | Urdu | `fakerUR` | +| `uz_UZ_latin` | Uzbek (Uzbekistan, Latin) | `fakerUZ_UZ_latin` | | `vi` | Vietnamese | `fakerVI` | | `yo_NG` | Yoruba (Nigeria) | `fakerYO_NG` | | `zh_CN` | Chinese (China) | `fakerZH_CN` | diff --git a/src/locale/index.ts b/src/locale/index.ts index b4c0799f257..5f5b0b7bc9e 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -66,6 +66,7 @@ import { faker as fakerTH } from './th'; import { faker as fakerTR } from './tr'; import { faker as fakerUK } from './uk'; import { faker as fakerUR } from './ur'; +import { faker as fakerUZ_UZ_latin } from './uz_UZ_latin'; import { faker as fakerVI } from './vi'; import { faker as fakerYO_NG } from './yo_NG'; import { faker as fakerZH_CN } from './zh_CN'; @@ -136,6 +137,7 @@ export { fakerTR, fakerUK, fakerUR, + fakerUZ_UZ_latin, fakerVI, fakerYO_NG, fakerZH_CN, @@ -207,6 +209,7 @@ export const allFakers = { tr: fakerTR, uk: fakerUK, ur: fakerUR, + uz_UZ_latin: fakerUZ_UZ_latin, vi: fakerVI, yo_NG: fakerYO_NG, zh_CN: fakerZH_CN, diff --git a/src/locale/uz_UZ_latin.ts b/src/locale/uz_UZ_latin.ts new file mode 100644 index 00000000000..5bddc232879 --- /dev/null +++ b/src/locale/uz_UZ_latin.ts @@ -0,0 +1,13 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate:locales' to update. + */ + +import { Faker } from '../faker'; +import base from '../locales/base'; +import en from '../locales/en'; +import uz_UZ_latin from '../locales/uz_UZ_latin'; + +export const faker = new Faker({ + locale: [uz_UZ_latin, en, base], +}); diff --git a/src/locales/index.ts b/src/locales/index.ts index 3ca1c0e2e93..b5124015908 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -66,6 +66,7 @@ export { default as th } from './th'; export { default as tr } from './tr'; export { default as uk } from './uk'; export { default as ur } from './ur'; +export { default as uz_UZ_latin } from './uz_UZ_latin'; export { default as vi } from './vi'; export { default as yo_NG } from './yo_NG'; export { default as zh_CN } from './zh_CN'; diff --git a/src/locales/uz_UZ_latin/index.ts b/src/locales/uz_UZ_latin/index.ts new file mode 100644 index 00000000000..025d9196cc3 --- /dev/null +++ b/src/locales/uz_UZ_latin/index.ts @@ -0,0 +1,14 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate:locales' to update. + */ +import type { LocaleDefinition } from '../..'; +import metadata from './metadata'; +import person from './person'; + +const uz_UZ_latin: LocaleDefinition = { + metadata, + person, +}; + +export default uz_UZ_latin; diff --git a/src/locales/uz_UZ_latin/metadata.ts b/src/locales/uz_UZ_latin/metadata.ts new file mode 100644 index 00000000000..24adec9a696 --- /dev/null +++ b/src/locales/uz_UZ_latin/metadata.ts @@ -0,0 +1,14 @@ +import type { PreBuiltMetadataDefinitionForCountry } from '../../definitions/metadata'; + +const metadata: PreBuiltMetadataDefinitionForCountry = { + title: 'Uzbek (Uzbekistan, Latin)', + code: 'uz_UZ_latin', + country: 'UZ', + language: 'uz', + variant: 'latin', + endonym: "O'zbekcha", + dir: 'ltr', + script: 'Latn', +}; + +export default metadata; diff --git a/src/locales/uz_UZ_latin/person/bio_parts.ts b/src/locales/uz_UZ_latin/person/bio_parts.ts new file mode 100644 index 00000000000..342bfaf995e --- /dev/null +++ b/src/locales/uz_UZ_latin/person/bio_parts.ts @@ -0,0 +1,37 @@ +export default [ + 'bitiruvchi', + 'biznes egasi', + 'blogger', + 'do‘st', + 'dizayner', + 'dasturchi', + 'ekolog', + 'faoliyatchi', + 'falsafachi', + 'film ishqibi', + 'fotoqrafer', + 'geymer', + 'ilmshunos', + 'jamolchi', + 'kinorejissyor', + 'model', + 'muallif', + 'mualim', + 'muhandis', + 'musiqachi', + 'o‘ila odobi', + 'o‘qituvchi', + 'o‘yinchim', + 'odam', + 'qo‘shiqchi', + 'rivojlanuvchi', + "san'atkor", + 'sayahatchi', + 'strimer', + 'tadbirkor', + 'talaba', + 'tayyorlashchi', + 'tuzuvchi', + 'vatanparvar', + 'veteran', +]; diff --git a/src/locales/uz_UZ_latin/person/female_first_name.ts b/src/locales/uz_UZ_latin/person/female_first_name.ts new file mode 100644 index 00000000000..68b24cc111d --- /dev/null +++ b/src/locales/uz_UZ_latin/person/female_first_name.ts @@ -0,0 +1,135 @@ +export default [ + 'Adiba', + 'Afzuna', + 'Afruza', + 'Akifa', + 'Alima', + 'Anora', + 'Asal', + 'Asila', + 'Asliya', + 'Asolat', + 'Aziza', + 'Barchinoy', + 'Barno', + 'Begoyim', + 'Binafsha', + 'Davriya', + 'Dilafruz', + 'Dilbar', + 'Dildora', + 'Dilfuza', + 'Dilnoza', + 'Dilorom', + 'Dilrabo', + 'Dilso‘z', + 'Diyora', + 'Durdona', + 'E’zoza', + 'Fazilat', + 'Farangiz', + 'Farida', + 'Feruza', + 'Fotima', + 'Gavxar', + 'Gulbaxor', + 'Gulchexra', + 'Guljamol', + 'Guljaxon', + 'Gulnoza', + 'Gulnora', + 'Guloy', + 'Gulsora', + 'Gulzira', + 'Gulzoda', + 'Hanifa', + 'Halima', + 'Hilola', + 'Hosiyat', + 'Hurshida', + 'Husida', + 'Husnida', + 'Husniya', + 'Husnora', + 'Iffar', + 'Ifora', + 'Iroda', + 'Jamila', + 'Jasmina', + 'Jumagul', + 'Kamola', + 'Karima', + 'Komila', + 'Kumush', + 'Latofat', + 'Laylo', + 'Lobar', + 'Lola', + 'Lutfiya', + 'Madina', + 'Malika', + 'Maloxat', + 'Mashxura', + 'Mavluda', + 'Maxbuba', + 'Maxfuza', + 'Maxsuma', + 'Moxigul', + 'Moxidil', + 'Moxina', + 'Moxinur', + 'Moxira', + 'Muazzam', + 'Muattar', + 'Mubina', + 'Muyassar', + 'Nafisa', + 'Nargiza', + 'Nasiba', + 'Nigora', + 'Nilufar', + 'Nodira', + 'Noila', + 'Nozima', + 'Omina', + 'Orzu', + 'Oyga', + 'Oysha', + 'Ozoda', + 'Oynur', + 'Qizilgul', + 'Ramziya', + 'Rasifa', + 'Ra’no', + 'Rayona', + 'Rayxona', + 'Robiya', + 'Roziya', + 'Saboxat', + 'Saboxon', + 'Sadoqat', + 'Saida', + 'Samina', + 'Samira', + 'Samiya', + 'Sanobar', + 'Saodat', + 'Sarvinoz', + 'Saxida', + 'Sayyora', + 'Sevara', + 'Safiya', + 'Safura', + 'Skipped', + 'Suyuna', + 'Tug‘ol', + 'Uqbaloy', + 'Umida', + 'Uzbegim', + 'Vasliddin', + 'Waqila', + 'Xalima', + 'Yozida', + 'Zilola', + 'Zuxra', +]; diff --git a/src/locales/uz_UZ_latin/person/female_last_name.ts b/src/locales/uz_UZ_latin/person/female_last_name.ts new file mode 100644 index 00000000000..7634e44fbdb --- /dev/null +++ b/src/locales/uz_UZ_latin/person/female_last_name.ts @@ -0,0 +1,211 @@ +export default [ + 'Abbosova', + 'Abdulahadyeva', + 'Abdulazimova', + 'Abdulazizova', + 'Abdulboriyeva', + 'Abdulhafizova', + 'Abdulhakimova', + 'Abdulhayova', + 'Abdulholiqova', + 'Abduljabborova', + 'Abduljalilova', + 'Abdulkarimova', + 'Abdullatifova', + 'Abdulmalikova', + 'Abdulqahhorova', + 'Abdulqodirova', + 'Abdulvaliyeva', + 'Abdulvahhobova', + 'Abdulvohidova', + 'Ahrorova', + 'Akmalova', + 'Akramova', + 'Aliyeva', + 'Alisherova', + 'Anasova', + 'Anvaryeva', + 'Arslonova', + 'Asadova', + 'Asadullohyeva', + 'Asilbekova', + 'Avazyeva', + 'Azamatova', + 'Azizova', + 'Bahodirova', + 'Bahromova', + 'Bahriddinova', + 'Bakhtiyorova', + 'Behruzova', + 'Bekmurodyeva', + 'Bilolyeva', + 'Boburova', + 'Botiryeva', + 'Burhonova', + 'Davronova', + 'Dilmurodyeva', + 'Diyorova', + 'Dovudova', + 'Elbekova', + 'Eldorova', + 'Elmurodyeva', + 'Elnurova', + 'Elyorova', + 'Fahriddinova', + 'Farruhova', + 'Fayzbekova', + 'Fazliddinyeva', + 'Fitratova', + 'Firdavsyeva', + 'Fotihova', + "G'afforova", + "G'afurova", + "G'iyosov", + "G'ulomov", + 'Habibova', + 'Halilyeva', + 'Hamidova', + 'Hamzayeva', + 'Hikmatova', + 'Hojimurodyeva', + 'Hurramova', + 'Ibodullohyeva', + 'Ibrohimova', + 'Ihtiyorova', + 'Ikromova', + 'Ilyosova', + 'Imronova', + 'Islomova', + 'Ismoilova', + 'Jalolova', + 'Jamolova', + 'Jamshidova', + 'Javlonova', + 'Javohirova', + 'Jasuryeva', + 'Kamoliddinyeva', + 'Kamolova', + 'Komilova', + 'Komronova', + 'Kubadova', + 'Lazizova', + 'Lutfiyeva', + 'Lutfullohova', + 'Mabrukova', + 'Madidova', + 'Mahanova', + 'Mahrusova', + 'Mansurova', + 'Mardonova', + 'Maqsudova', + 'Mavdudyeva', + 'Mavlonova', + 'Mirazizova', + 'Mirziyoyeva', + 'Mironova', + 'Miranova', + 'Mohirova', + 'Mo‘minova', + 'Mufizova', + 'Muhammadova', + 'Muhsinova', + 'Muhtorova', + 'Murodova', + 'Musulmonova', + 'Mustafoyeva', + 'Munifyeva', + 'Muzaffarova', + 'Nazifova', + 'Nazrullohyeva', + 'Najmiddinova', + 'Narimonova', + 'Nasriddinova', + 'Ne’matullohyeva', + 'Nizomiddinova', + 'Nizomova', + 'Nurbekova', + 'Nurlanova', + 'Nusratova', + 'Nusratullohyeva', + 'Nosirjonova', + 'Nosirova', + 'Nuriddinova', + 'Obidova', + 'Odilyeva', + 'Olimova', + 'Omadova', + 'Oqilyeva', + 'Otabekova', + 'O‘ktamova', + 'O‘tkirova', + 'Oybekova', + 'Ozodbekova', + 'Ozodova', + 'Orifova', + 'Ramziddinova', + 'Rafidyeva', + 'Rahimova', + 'Rajabova', + 'Raifyeva', + 'Rashidova', + 'Raufyeva', + 'Ravshanova', + 'Raxmatullohyeva', + 'Rizvonyeva', + 'Rustamova', + 'Saadiyeva', + 'Sa’dullohyeva', + 'Sadriddinova', + 'Safiryeva', + 'Safoyeva', + 'Saidova', + 'Salohova', + 'Samandarova', + 'Samiryeva', + 'Sarvarova', + 'Sardorova', + 'Sirojiddinova', + 'Shahobiddinova', + 'Shahbozova', + 'Shahriyorova', + 'Shahzodova', + 'Shamsiddinova', + 'Sherzodova', + 'Shodiyorova', + 'Shohibova', + 'Shukrulloha', + 'Sobitova', + 'Sodiqova', + 'Suhrobova', + 'Sulaymonova', + 'Sultonova', + 'Tabrisova', + 'Tohirova', + 'To‘lqinyeva', + 'Toyipova', + 'Ubaydullohyeva', + 'Uchqunova', + 'Ulug‘bekova', + 'Umarova', + 'Umidullohyeva', + 'Umidyeva', + 'Urfonova', + 'Usmonova', + 'Uzayrova', + 'Vafoyeva', + 'Vosilyeva', + 'Yahyoyeva', + 'Yorbekova', + 'Yoznurova', + 'Yunusova', + 'Yusufyeva', + 'Yoqubova', + 'Zabirova', + 'Zafarova', + 'Zaydova', + 'Zayniddinova', + 'Ziyoyeva', + 'Zohidova', + 'Zohirova', + 'Zubayrova', +]; diff --git a/src/locales/uz_UZ_latin/person/female_last_name_pattern.ts b/src/locales/uz_UZ_latin/person/female_last_name_pattern.ts new file mode 100644 index 00000000000..3f920674763 --- /dev/null +++ b/src/locales/uz_UZ_latin/person/female_last_name_pattern.ts @@ -0,0 +1 @@ +export default [{ value: '{{person.female_last_name}}', weight: 1 }]; diff --git a/src/locales/uz_UZ_latin/person/index.ts b/src/locales/uz_UZ_latin/person/index.ts new file mode 100644 index 00000000000..7d4e559035c --- /dev/null +++ b/src/locales/uz_UZ_latin/person/index.ts @@ -0,0 +1,28 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate:locales' to update. + */ +import type { PersonDefinition } from '../../..'; +import bio_parts from './bio_parts'; +import female_first_name from './female_first_name'; +import female_last_name from './female_last_name'; +import female_last_name_pattern from './female_last_name_pattern'; +import job_title from './job_title'; +import male_first_name from './male_first_name'; +import male_last_name from './male_last_name'; +import male_last_name_pattern from './male_last_name_pattern'; +import sex from './sex'; + +const person: PersonDefinition = { + bio_parts, + female_first_name, + female_last_name, + female_last_name_pattern, + job_title, + male_first_name, + male_last_name, + male_last_name_pattern, + sex, +}; + +export default person; diff --git a/src/locales/uz_UZ_latin/person/job_title.ts b/src/locales/uz_UZ_latin/person/job_title.ts new file mode 100644 index 00000000000..037f319b044 --- /dev/null +++ b/src/locales/uz_UZ_latin/person/job_title.ts @@ -0,0 +1,26 @@ +export default [ + 'agent', + 'aloqa mutaxassis', + 'analitik', + 'arxitektor', + 'assistant', + 'boshqaruvchi', + 'consultant', + 'coordinator', + 'dasturchi', + 'dizayner', + 'direktor', + 'hamkor', + 'konsultant', + 'menejer', + 'muhandis', + 'mutaxassis', + 'nazoratchi', + 'orchestrator', + 'produktor', + 'reja muharriri', + 'strateg', + 'texnik', + 'vazir', + 'yordamchi', +]; diff --git a/src/locales/uz_UZ_latin/person/male_first_name.ts b/src/locales/uz_UZ_latin/person/male_first_name.ts new file mode 100644 index 00000000000..a145a7fb413 --- /dev/null +++ b/src/locales/uz_UZ_latin/person/male_first_name.ts @@ -0,0 +1,229 @@ +export default [ + 'Abbos', + 'Abdulahad', + 'Abdulazim', + 'Abdulaziz', + 'Abdulboriy', + 'Abdulhafiz', + 'Abdulhakim', + 'Abdulhay', + 'Abdulholiq', + 'Abduljabbor', + 'Abduljalil', + 'Abdulkarim', + 'Abdullatif', + 'Abdulmalik', + 'Abdulqahhor', + 'Abdulqodir', + 'Abdurrahiym', + 'Abdurrahmon', + 'Abdurrauf', + 'Abdurrazzoq', + 'Abdussamad', + 'Abdulvali', + 'Abdulvahhob', + 'Abdulvohid', + 'Ahror', + 'Akmal', + 'Akram', + 'Ali', + 'Alisher', + 'Anas', + 'Anvar', + 'Arslon', + 'Asad', + 'Asadulloh', + 'Asilbek', + 'Avaz', + 'Azamat', + 'Aziz', + 'Bahodir', + 'Bahrom', + 'Bahriddin', + 'Bakhtiyor', + 'Bekmurod', + 'Behruz', + 'Bilol', + 'Bobur', + 'Botir', + 'Burhon', + 'Davron', + 'Dilmurod', + 'Diyor', + 'Dovud', + 'Elbek', + 'Eldor', + 'Elmurod', + 'Elnur', + 'Elyor', + 'Farruh', + 'Fazliddin', + 'Fahriddin', + 'Fayzbek', + 'Firdavs', + 'Fitrat', + 'Fotih', + "G'afur", + "G'affor", + "G'iyos", + "G'ulom", + 'Habib', + 'Halil', + 'Hamid', + 'Hamza', + 'Hikmat', + 'Hojimurod', + 'Hurram', + 'Ibodulloh', + 'Ibrohim', + 'Ihtiyor', + 'Ikrom', + 'Ilyos', + 'Imron', + 'Islom', + 'Ismoil', + 'Jalol', + 'Jamol', + 'Jamshid', + 'Jasur', + 'Javlon', + 'Javohir', + 'Kamol', + 'Kamoliddin', + 'Komil', + 'Komron', + 'Kubad', + 'Laziz', + 'Lutfi', + 'Lutfulloh', + 'Mabruk', + 'Mavdud', + 'Mavlon', + 'Madid', + 'Mazbut', + 'Mansur', + 'Mardon', + 'Maqsud', + 'Mahan', + 'Mahrus', + 'Mahmud', + 'Mahzan', + 'Ma’sud', + 'Ma’mur', + 'Miraziz', + 'Mirziyo', + 'Miron', + 'Miran', + 'Mohir', + 'Ma’ruf', + 'Murod', + 'Muzaffar', + 'Musulmon', + 'Mufiz', + 'Muhsin', + 'Muhammad', + 'Muhtor', + 'Munif', + 'Mustafo', + 'Mo‘min', + 'Nazrulloh', + 'Nazif', + 'Narimon', + 'Najmiddin', + 'Nasriddin', + 'Ne’matulloh', + 'Nosir', + 'Nosirjon', + 'Nuriddin', + 'Nusratulloh', + 'Nusrat', + 'Nurbek', + 'Nizom', + 'Nizomiddin', + 'Nurlan', + 'Obid', + 'Odil', + 'Oybek', + 'Ozod', + 'Ozodbek', + 'Otabek', + 'Olim', + 'Orif', + 'Oqil', + 'Omad', + 'O‘ktam', + 'O‘tkir', + 'Qobil', + 'Qosim', + 'Qudrat', + 'Ramziddin', + 'Rafid', + 'Raxmatulloh', + 'Ravshan', + 'Rahim', + 'Rajab', + 'Raif', + 'Rauf', + 'Rashid', + 'Rizvon', + 'Rustam', + 'Sadriddin', + 'Saloh', + 'Saadi', + 'Sadar', + 'Samandar', + 'Samir', + 'Safir', + 'Safo', + 'Said', + 'Sa’dulloh', + 'Sarvar', + 'Sardor', + 'Sirojiddin', + 'Sodiq', + 'Sobit', + 'Sohib', + 'Sulaymon', + 'Sulton', + 'Suhrob', + 'Tabris', + 'To‘lqin', + 'Tohir', + 'Toyip', + 'Ubaydulloh', + 'Ulug‘bek', + 'Umid', + 'Umidulloh', + 'Umar', + 'Uzayr', + 'Urfon', + 'Usmon', + 'Uchqun', + 'Vafo', + 'Vosil', + 'Yahyo', + 'Yunus', + 'Yusuf', + 'Yoqub', + 'Yoznur', + 'Yorbek', + 'Yorqin', + 'Zafar', + 'Zayniddin', + 'Zayd', + 'Zoyir', + 'Zokir', + 'Ziyo', + 'Zabir', + 'Zohid', + 'Zohir', + 'Zubayr', + 'Shamsiddin', + 'Shahobiddin', + 'Shahboz', + 'Shahzod', + 'Shahriyor', + 'Shodiyor', + 'Shukrulloh', + 'Sherzod', +]; diff --git a/src/locales/uz_UZ_latin/person/male_last_name.ts b/src/locales/uz_UZ_latin/person/male_last_name.ts new file mode 100644 index 00000000000..bef6f77484c --- /dev/null +++ b/src/locales/uz_UZ_latin/person/male_last_name.ts @@ -0,0 +1,211 @@ +export default [ + 'Abbosov', + 'Abdulahadyev', + 'Abdulazimov', + 'Abdulazizov', + 'Abdulboriyev', + 'Abdulhafizov', + 'Abdulhakimov', + 'Abdulhayov', + 'Abdulholiqov', + 'Abduljabborov', + 'Abduljalilov', + 'Abdulkarimov', + 'Abdullatifov', + 'Abdulmalikov', + 'Abdulqahhorov', + 'Abdulqodirov', + 'Abdulvaliyev', + 'Abdulvahhobov', + 'Abdulvohidov', + 'Ahrorov', + 'Akmalov', + 'Akramov', + 'Aliyev', + 'Alisherov', + 'Anasov', + 'Anvaryev', + 'Arslonov', + 'Asadov', + 'Asadullohyev', + 'Asilbekov', + 'Avazyev', + 'Azamatov', + 'Azizov', + 'Bahodirov', + 'Bahromov', + 'Bahriddinov', + 'Bakhtiyorov', + 'Behruzov', + 'Bekmurodyev', + 'Bilolyev', + 'Boburov', + 'Botiryev', + 'Burhonov', + 'Davronov', + 'Dilmurodyev', + 'Diyorov', + 'Dovudov', + 'Elbekov', + 'Eldorov', + 'Elmurodyev', + 'Elnurov', + 'Elyorov', + 'Fahriddinov', + 'Farruhov', + 'Fayzbekov', + 'Fazliddinyev', + 'Fitratov', + 'Firdavsyev', + 'Fotihov', + "G'afforov", + "G'afurov", + "G'iyosov", + "G'ulomov", + 'Habibov', + 'Halilyev', + 'Hamidov', + 'Hamzayev', + 'Hikmatov', + 'Hojimurodyev', + 'Hurramov', + 'Ibodullohyev', + 'Ibrohimov', + 'Ihtiyorov', + 'Ikromov', + 'Ilyosov', + 'Imronov', + 'Islomov', + 'Ismoilov', + 'Jalolov', + 'Jamolov', + 'Jamshidov', + 'Javlonov', + 'Javohirov', + 'Jasuryev', + 'Kamoliddinyev', + 'Kamolov', + 'Komilov', + 'Komronov', + 'Kubadov', + 'Lazizov', + 'Lutfiyev', + 'Lutfullohov', + 'Mabrukov', + 'Madidov', + 'Mahanov', + 'Mahrusov', + 'Mansurov', + 'Mardonov', + 'Maqsudov', + 'Mavdudyev', + 'Mavlonov', + 'Mirazizov', + 'Mirziyoyev', + 'Mironov', + 'Miranov', + 'Mohirov', + 'Mo‘minov', + 'Mufizov', + 'Muhammadov', + 'Muhsinov', + 'Muhtorov', + 'Murodov', + 'Musulmonov', + 'Mustafoyev', + 'Munifyev', + 'Muzaffarov', + 'Nazifov', + 'Nazrullohyev', + 'Najmiddinov', + 'Narimonov', + 'Nasriddinov', + 'Ne’matullohyev', + 'Nizomiddinov', + 'Nizomov', + 'Nurbekov', + 'Nurlanov', + 'Nusratov', + 'Nusratullohyev', + 'Nosirjonov', + 'Nosirov', + 'Nuriddinov', + 'Obidov', + 'Odilyev', + 'Olimov', + 'Omadov', + 'Oqilyev', + 'Otabekov', + 'O‘ktamov', + 'O‘tkirov', + 'Oybekov', + 'Ozodbekov', + 'Ozodov', + 'Orifov', + 'Ramziddinov', + 'Rafidyev', + 'Rahimov', + 'Rajabov', + 'Raifyev', + 'Rashidov', + 'Raufyev', + 'Ravshanov', + 'Raxmatullohyev', + 'Rizvonyev', + 'Rustamov', + 'Saadiyev', + 'Sa’dullohyev', + 'Sadriddinov', + 'Safiryev', + 'Safoyev', + 'Saidov', + 'Salohov', + 'Samandarov', + 'Samiryev', + 'Sarvarov', + 'Sardorov', + 'Sirojiddinov', + 'Shahobiddinov', + 'Shahbozov', + 'Shahriyorov', + 'Shahzodov', + 'Shamsiddinov', + 'Sherzodov', + 'Shodiyorov', + 'Shohibov', + 'Shukrulloh', + 'Sobitov', + 'Sodiqov', + 'Suhrobov', + 'Sulaymonov', + 'Sultonov', + 'Tabrisov', + 'Tohirov', + 'To‘lqinyev', + 'Toyipov', + 'Ubaydullohyev', + 'Uchqunov', + 'Ulug‘bekov', + 'Umarov', + 'Umidullohyev', + 'Umidyev', + 'Urfonov', + 'Usmonov', + 'Uzayrov', + 'Vafoyev', + 'Vosilyev', + 'Yahyoyev', + 'Yorbekov', + 'Yoznurov', + 'Yunusov', + 'Yusufyev', + 'Yoqubov', + 'Zabirov', + 'Zafarov', + 'Zaydov', + 'Zayniddinov', + 'Ziyoyev', + 'Zohidov', + 'Zohirov', + 'Zubayrov', +]; diff --git a/src/locales/uz_UZ_latin/person/male_last_name_pattern.ts b/src/locales/uz_UZ_latin/person/male_last_name_pattern.ts new file mode 100644 index 00000000000..75cb2c10bdb --- /dev/null +++ b/src/locales/uz_UZ_latin/person/male_last_name_pattern.ts @@ -0,0 +1 @@ +export default [{ value: '{{person.male_last_name}}', weight: 1 }]; diff --git a/src/locales/uz_UZ_latin/person/sex.ts b/src/locales/uz_UZ_latin/person/sex.ts new file mode 100644 index 00000000000..b3d5c973e81 --- /dev/null +++ b/src/locales/uz_UZ_latin/person/sex.ts @@ -0,0 +1 @@ +export default ['Erkak', 'Ayol']; From 2bf897464cdda53886380590d64236658102cdda Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Tue, 5 Mar 2024 06:10:07 +0100 Subject: [PATCH 2/5] infra(typescript-eslint): consistent-type-exports (#2714) --- .eslintrc.cjs | 1 + test/scripts/apidoc/signature.example.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index eb5c3e2318b..198153defc3 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -63,6 +63,7 @@ module.exports = defineConfig({ 'error', { default: 'array-simple', readonly: 'generic' }, ], + '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/explicit-module-boundary-types': 'error', '@typescript-eslint/naming-convention': [ diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts index af04ee90f2f..c42d2d454ce 100644 --- a/test/scripts/apidoc/signature.example.ts +++ b/test/scripts/apidoc/signature.example.ts @@ -4,7 +4,7 @@ import type { AlphaNumericChar } from '../../../src/modules/string'; import type { LiteralUnion } from '../../../src/utils/types'; // explicitly export types so they show up in the docs as decomposed types export type { NumberColorFormat, StringColorFormat } from '../../../src'; -export { AlphaNumericChar, Casing, ColorFormat, LiteralUnion }; +export type { AlphaNumericChar, Casing, ColorFormat, LiteralUnion }; /** * Parameter options type with default from signature. From e868060c87cbca3c1bf90465d61fc39a4eea1f9c Mon Sep 17 00:00:00 2001 From: Shinigami Date: Tue, 5 Mar 2024 10:56:25 +0100 Subject: [PATCH 3/5] refactor(date)!: remove v8 deprecated date methods (#2704) --- docs/guide/upgrading_v9/2704.md | 14 + src/modules/date/index.ts | 847 ++----------------- test/all-functional.spec.ts | 4 + test/modules/__snapshots__/date.spec.ts.snap | 216 ----- test/modules/date.spec.ts | 277 +----- 5 files changed, 87 insertions(+), 1271 deletions(-) create mode 100644 docs/guide/upgrading_v9/2704.md diff --git a/docs/guide/upgrading_v9/2704.md b/docs/guide/upgrading_v9/2704.md new file mode 100644 index 00000000000..26c2b46104e --- /dev/null +++ b/docs/guide/upgrading_v9/2704.md @@ -0,0 +1,14 @@ +### Remove deprecated date methods + +Removed deprecated date methods + +| old | replacement | +| -------------------------------------- | ------------------------------------------ | +| `faker.date.past(years, refDate)` | `faker.date.past({ years, refDate })` | +| `faker.date.future(years, refDate)` | `faker.date.future({ years, refDate })` | +| `faker.date.between(from, to)` | `faker.date.between({ from, to })` | +| `faker.date.betweens(from, to, count)` | `faker.date.betweens({ from, to, count })` | +| `faker.date.recent(days, refDate)` | `faker.date.recent({ days, refDate })` | +| `faker.date.soon(days, refDate)` | `faker.date.soon({ days, refDate })` | +| `faker.date.month({ abbr })` | `faker.date.month({ abbreviated })` | +| `faker.date.weekday({ abbr })` | `faker.date.weekday({ abbreviated })` | diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts index 9e8002d2d9c..2729c8496a3 100644 --- a/src/modules/date/index.ts +++ b/src/modules/date/index.ts @@ -1,7 +1,6 @@ import type { Faker } from '../..'; import type { DateEntryDefinition } from '../../definitions'; import { FakerError } from '../../errors/faker-error'; -import { deprecated } from '../../internal/deprecated'; import { SimpleModuleBase } from '../../internal/module-base'; import { assertLocaleData } from '../../locale-proxy'; @@ -83,94 +82,23 @@ export class SimpleDateModule extends SimpleModuleBase { * * @since 8.0.0 */ - past(options?: { - /** - * The range of years the date may be in the past. - * - * @default 1 - */ - years?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }): Date; - /** - * Generates a random date in the past. - * - * @param years The range of years the date may be in the past. Defaults to `1`. - * @param refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * - * @see faker.date.recent(): For generating dates in the recent past (days instead of years). - * - * @example - * faker.date.past() // '2021-12-03T05:40:44.408Z' - * faker.date.past(10) // '2017-10-25T21:34:19.488Z' - * faker.date.past(10, '2020-01-01T00:00:00.000Z') // '2017-08-18T02:59:12.350Z' - * - * @since 2.0.1 - * - * @deprecated Use `faker.date.past({ years, refDate })` instead. - */ - past(years?: number, refDate?: string | Date | number): Date; - /** - * Generates a random date in the past. - * - * @param options The optional options object. - * @param options.years The range of years the date may be in the past. Defaults to `1`. - * @param options.refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * @param legacyRefDate Deprecated, use `options.refDate` instead. - * - * @see faker.date.recent(): For generating dates in the recent past (days instead of years). - * - * @example - * faker.date.past() // '2021-12-03T05:40:44.408Z' - * faker.date.past({ years: 10 }) // '2017-10-25T21:34:19.488Z' - * faker.date.past({ years: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2017-08-18T02:59:12.350Z' - * - * @since 8.0.0 - */ - past( - options?: - | number - | { - /** - * The range of years the date may be in the past. - * - * @default 1 - */ - years?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }, - legacyRefDate?: string | Date | number - ): Date; past( - options: - | number - | { - years?: number; - refDate?: string | Date | number; - } = {}, - legacyRefDate?: string | Date | number + options: { + /** + * The range of years the date may be in the past. + * + * @default 1 + */ + years?: number; + /** + * The date to use as reference point for the newly generated date. + * + * @default faker.defaultRefDate() + */ + refDate?: string | Date | number; + } = {} ): Date { - if (typeof options === 'number') { - deprecated({ - deprecated: 'faker.date.past(years, refDate)', - proposed: 'faker.date.past({ years, refDate })', - since: '8.0', - until: '9.0', - }); - options = { years: options }; - } - - const { years = 1, refDate = legacyRefDate } = options; + const { years = 1, refDate } = options; if (years <= 0) { throw new FakerError('Years must be greater than 0.'); @@ -205,94 +133,23 @@ export class SimpleDateModule extends SimpleModuleBase { * * @since 8.0.0 */ - future(options?: { - /** - * The range of years the date may be in the future. - * - * @default 1 - */ - years?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }): Date; - /** - * Generates a random date in the future. - * - * @param years The range of years the date may be in the future. Defaults to `1`. - * @param refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * - * @see faker.date.soon(): For generating dates in the near future (days instead of years). - * - * @example - * faker.date.future() // '2022-11-19T05:52:49.100Z' - * faker.date.future(10) // '2030-11-23T09:38:28.710Z' - * faker.date.future(10, '2020-01-01T00:00:00.000Z') // '2020-12-13T22:45:10.252Z' - * - * @since 2.0.1 - * - * @deprecated Use `faker.date.future({ years, refDate })` instead. - */ - future(years?: number, refDate?: string | Date | number): Date; - /** - * Generates a random date in the future. - * - * @param options The optional options object. - * @param options.years The range of years the date may be in the future. Defaults to `1`. - * @param options.refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * @param legacyRefDate Deprecated, use `options.refDate` instead. - * - * @see faker.date.soon(): For generating dates in the near future (days instead of years). - * - * @example - * faker.date.future() // '2022-11-19T05:52:49.100Z' - * faker.date.future({ years: 10 }) // '2030-11-23T09:38:28.710Z' - * faker.date.future({ years: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2020-12-13T22:45:10.252Z' - * - * @since 8.0.0 - */ - future( - options?: - | number - | { - /** - * The range of years the date may be in the future. - * - * @default 1 - */ - years?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }, - legacyRefDate?: string | Date | number - ): Date; future( - options: - | number - | { - years?: number; - refDate?: string | Date | number; - } = {}, - legacyRefDate?: string | Date | number + options: { + /** + * The range of years the date may be in the future. + * + * @default 1 + */ + years?: number; + /** + * The date to use as reference point for the newly generated date. + * + * @default faker.defaultRefDate() + */ + refDate?: string | Date | number; + } = {} ): Date { - if (typeof options === 'number') { - deprecated({ - deprecated: 'faker.date.future(years, refDate)', - proposed: 'faker.date.future({ years, refDate })', - since: '8.0', - until: '9.0', - }); - options = { years: options }; - } - - const { years = 1, refDate = legacyRefDate } = options; + const { years = 1, refDate } = options; if (years <= 0) { throw new FakerError('Years must be greater than 0.'); @@ -332,73 +189,7 @@ export class SimpleDateModule extends SimpleModuleBase { * The late date boundary. */ to: string | Date | number; - }): Date; - /** - * Generates a random date between the given boundaries. - * - * @param from The early date boundary. - * @param to The late date boundary. - * - * @example - * faker.date.between('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z') // '2026-05-16T02:22:53.002Z' - * - * @since 2.0.1 - * - * @deprecated Use `faker.date.between({ from, to })` instead. - */ - between(from: string | Date | number, to: string | Date | number): Date; - /** - * Generates a random date between the given boundaries. - * - * @param options The optional options object. - * @param options.from The early date boundary. - * @param options.to The late date boundary. - * @param legacyTo Deprecated, use `options.to` instead. - * - * @example - * faker.date.between({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z' }) // '2026-05-16T02:22:53.002Z' - * - * @since 8.0.0 - */ - between( - options: - | string - | Date - | number - | { - /** - * The early date boundary. - */ - from: string | Date | number; - /** - * The late date boundary. - */ - to: string | Date | number; - }, - legacyTo?: string | Date | number - ): Date; - between( - options: - | string - | Date - | number - | { - from: string | Date | number; - to: string | Date | number; - }, - legacyTo?: string | Date | number - ): Date { - if (options instanceof Date || typeof options !== 'object') { - deprecated({ - deprecated: 'faker.date.between(from, to)', - proposed: 'faker.date.between({ from, to })', - since: '8.0', - until: '9.0', - }); - // We use options as fallback for legacyTo avoid TS errors for unintended usage. - options = { from: options, to: legacyTo ?? options }; - } - + }): Date { const { from, to } = options; const fromMs = toDate(from, this.faker.defaultRefDate).getTime(); @@ -460,122 +251,7 @@ export class SimpleDateModule extends SimpleModuleBase { */ max: number; }; - }): Date[]; - /** - * Generates random dates between the given boundaries. - * - * @param from The early date boundary. - * @param to The late date boundary. - * @param count The number of dates to generate. Defaults to `3`. - * @param count.min The minimum number of dates to generate. - * @param count.max The maximum number of dates to generate. - * - * @example - * faker.date.betweens('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z') - * // [ - * // 2022-07-02T06:00:00.000Z, - * // 2024-12-31T12:00:00.000Z, - * // 2027-07-02T18:00:00.000Z - * // ] - * faker.date.betweens('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z', 2) - * // [ 2023-05-02T16:00:00.000Z, 2026-09-01T08:00:00.000Z ] - * - * @since 5.4.0 - * - * @deprecated Use `faker.date.betweens({ from, to, count })` instead. - */ - betweens( - from: string | Date | number, - to: string | Date | number, - count?: number - ): Date[]; - /** - * Generates random dates between the given boundaries. - * - * @param options The optional options object. - * @param options.from The early date boundary. - * @param options.to The late date boundary. - * @param options.count The number of dates to generate. Defaults to `3`. - * @param legacyTo Deprecated, use `options.to` instead. - * @param legacyCount Deprecated, use `options.count` instead. Defaults to `3`. - * - * @example - * faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z' }) - * // [ - * // 2022-07-02T06:00:00.000Z, - * // 2024-12-31T12:00:00.000Z, - * // 2027-07-02T18:00:00.000Z - * // ] - * faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z', count: 2 }) - * // [ 2023-05-02T16:00:00.000Z, 2026-09-01T08:00:00.000Z ] - * faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z', count: { min: 2, max: 5 }}) - * // [ - * // 2021-12-19T06:35:40.191Z, - * // 2022-09-10T08:03:51.351Z, - * // 2023-04-19T11:41:17.501Z - * // ] - * - * @since 8.0.0 - */ - betweens( - options: - | string - | Date - | number - | { - /** - * The early date boundary. - */ - from: string | Date | number; - /** - * The late date boundary. - */ - to: string | Date | number; - /** - * The number of dates to generate. - * - * @default 3 - */ - count?: - | number - | { - /** - * The minimum number of dates to generate. - */ - min: number; - /** - * The maximum number of dates to generate. - */ - max: number; - }; - }, - legacyTo?: string | Date | number, - legacyCount?: number - ): Date[]; - betweens( - options: - | string - | Date - | number - | { - from: string | Date | number; - to: string | Date | number; - count?: number | { min: number; max: number }; - }, - legacyTo?: string | Date | number, - legacyCount: number = 3 - ): Date[] { - if (options instanceof Date || typeof options !== 'object') { - deprecated({ - deprecated: 'faker.date.betweens(from, to, count)', - proposed: 'faker.date.betweens({ from, to, count })', - since: '8.0', - until: '9.0', - }); - // We use options as fallback for legacyTo avoid TS errors for unintended usage. - options = { from: options, to: legacyTo ?? options, count: legacyCount }; - } - + }): Date[] { const { from, to, count = 3 } = options; return this.faker.helpers @@ -599,89 +275,23 @@ export class SimpleDateModule extends SimpleModuleBase { * * @since 8.0.0 */ - recent(options?: { - /** - * The range of days the date may be in the past. - * - * @default 1 - */ - days?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }): Date; - /** - * Generates a random date in the recent past. - * - * @param days The range of days the date may be in the past. Defaults to `1`. - * @param refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * - * @see faker.date.past(): For generating dates further back in time (years instead of days). - * - * @example - * faker.date.recent() // '2022-02-04T02:09:35.077Z' - * faker.date.recent(10) // '2022-01-29T06:12:12.829Z' - * faker.date.recent(10, '2020-01-01T00:00:00.000Z') // '2019-12-27T18:11:19.117Z' - * - * @since 2.0.1 - * - * @deprecated Use `faker.date.recent({ days, refDate })` instead. - */ - recent(days?: number, refDate?: string | Date | number): Date; - /** - * Generates a random date in the recent past. - * - * @param options The optional options object. - * @param options.days The range of days the date may be in the past. Defaults to `1`. - * @param options.refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * @param legacyRefDate Deprecated, use `options.refDate` instead. - * - * @see faker.date.past(): For generating dates further back in time (years instead of days). - * - * @example - * faker.date.recent() // '2022-02-04T02:09:35.077Z' - * faker.date.recent({ days: 10 }) // '2022-01-29T06:12:12.829Z' - * faker.date.recent({ days: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2019-12-27T18:11:19.117Z' - * - * @since 8.0.0 - */ - recent( - options?: - | number - | { - /** - * The range of days the date may be in the past. - * - * @default 1 - */ - days?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }, - legacyRefDate?: string | Date | number - ): Date; recent( - options: number | { days?: number; refDate?: string | Date | number } = {}, - legacyRefDate?: string | Date | number + options: { + /** + * The range of days the date may be in the past. + * + * @default 1 + */ + days?: number; + /** + * The date to use as reference point for the newly generated date. + * + * @default faker.defaultRefDate() + */ + refDate?: string | Date | number; + } = {} ): Date { - if (typeof options === 'number') { - deprecated({ - deprecated: 'faker.date.recent(days, refDate)', - proposed: 'faker.date.recent({ days, refDate })', - since: '8.0', - until: '9.0', - }); - options = { days: options }; - } - - const { days = 1, refDate = legacyRefDate } = options; + const { days = 1, refDate } = options; if (days <= 0) { throw new FakerError('Days must be greater than 0.'); @@ -716,89 +326,23 @@ export class SimpleDateModule extends SimpleModuleBase { * * @since 8.0.0 */ - soon(options?: { - /** - * The range of days the date may be in the future. - * - * @default 1 - */ - days?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }): Date; - /** - * Generates a random date in the near future. - * - * @param days The range of days the date may be in the future. Defaults to `1`. - * @param refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * - * @see faker.date.future(): For generating dates further in the future (years instead of days). - * - * @example - * faker.date.soon() // '2022-02-05T09:55:39.216Z' - * faker.date.soon(10) // '2022-02-11T05:14:39.138Z' - * faker.date.soon(10, '2020-01-01T00:00:00.000Z') // '2020-01-01T02:40:44.990Z' - * - * @since 5.0.0 - * - * @deprecated Use `faker.date.soon({ days, refDate })` instead. - */ - soon(days?: number, refDate?: string | Date | number): Date; - /** - * Generates a random date in the near future. - * - * @param options The optional options object. - * @param options.days The range of days the date may be in the future. Defaults to `1`. - * @param options.refDate The date to use as reference point for the newly generated date. Defaults to `faker.defaultRefDate()`. - * @param legacyRefDate Deprecated, use `options.refDate` instead. - * - * @see faker.date.future(): For generating dates further in the future (years instead of days). - * - * @example - * faker.date.soon() // '2022-02-05T09:55:39.216Z' - * faker.date.soon({ days: 10 }) // '2022-02-11T05:14:39.138Z' - * faker.date.soon({ days: 10, refDate: '2020-01-01T00:00:00.000Z' }) // '2020-01-01T02:40:44.990Z' - * - * @since 8.0.0 - */ soon( - options?: - | number - | { - /** - * The range of days the date may be in the future. - * - * @default 1 - */ - days?: number; - /** - * The date to use as reference point for the newly generated date. - * - * @default faker.defaultRefDate() - */ - refDate?: string | Date | number; - }, - legacyRefDate?: string | Date | number - ): Date; - soon( - options: number | { days?: number; refDate?: string | Date | number } = {}, - legacyRefDate?: string | Date | number + options: { + /** + * The range of days the date may be in the future. + * + * @default 1 + */ + days?: number; + /** + * The date to use as reference point for the newly generated date. + * + * @default faker.defaultRefDate() + */ + refDate?: string | Date | number; + } = {} ): Date { - if (typeof options === 'number') { - deprecated({ - deprecated: 'faker.date.soon(days, refDate)', - proposed: 'faker.date.soon({ days, refDate })', - since: '8.0', - until: '9.0', - }); - options = { days: options }; - } - - const { days = 1, refDate = legacyRefDate } = options; + const { days = 1, refDate } = options; if (days <= 0) { throw new FakerError('Days must be greater than 0.'); @@ -940,129 +484,8 @@ export class DateModule extends SimpleDateModule { * * @since 3.0.1 */ - month(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - */ - abbreviated?: boolean; - /** - * Whether to return the name of a month in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random name of a month. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.context Whether to return the name of a month in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. Defaults to `false`. - * - * @example - * faker.date.month() // 'October' - * faker.date.month({ abbr: true }) // 'Feb' - * faker.date.month({ context: true }) // 'June' - * faker.date.month({ abbr: true, context: true }) // 'Sep' - * - * @since 3.0.1 - * - * @deprecated Use `faker.date.month({ abbreviated, ... })` instead. - */ - month(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; - /** - * Whether to return the name of a month in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random name of a month. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.abbreviated Whether to return an abbreviation. Defaults to `false`. - * @param options.context Whether to return the name of a month in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. Defaults to `false`. - * - * @example - * faker.date.month() // 'October' - * faker.date.month({ abbreviated: true }) // 'Feb' - * faker.date.month({ context: true }) // 'June' - * faker.date.month({ abbreviated: true, context: true }) // 'Sep' - * - * @since 3.0.1 - */ - month(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; - /** - * Whether to return an abbreviation. - * - * @default false - */ - abbreviated?: boolean; - /** - * Whether to return the name of a month in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random name of a month. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.abbreviated Whether to return an abbreviation. Defaults to `false`. - * @param options.context Whether to return the name of a month in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'январь'` with `{ context: false }` and `'января'` with `{ context: true }` in `ru`. Defaults to `false`. - * - * @example - * faker.date.month() // 'October' - * faker.date.month({ abbreviated: true }) // 'Feb' - * faker.date.month({ context: true }) // 'June' - * faker.date.month({ abbreviated: true, context: true }) // 'Sep' - * - * @since 3.0.1 - */ month( options: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; /** * Whether to return an abbreviation. * @@ -1081,17 +504,7 @@ export class DateModule extends SimpleDateModule { context?: boolean; } = {} ): string { - // eslint-disable-next-line deprecation/deprecation - const { abbr, abbreviated = abbr ?? false, context = false } = options; - - if (abbr != null) { - deprecated({ - deprecated: 'faker.date.month({ abbr })', - proposed: 'faker.date.month({ abbreviated })', - since: '8.0', - until: '9.0', - }); - } + const { abbreviated = false, context = false } = options; const source = this.faker.definitions.date.month; let type: keyof DateEntryDefinition; @@ -1123,130 +536,8 @@ export class DateModule extends SimpleDateModule { * * @since 3.0.1 */ - weekday(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - */ - abbreviated?: boolean; - /** - * Whether to return the day of the week in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random day of the week. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.abbreviated Whether to return an abbreviation. Defaults to `false`. - * @param options.context Whether to return the day of the week in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. Defaults to `false`. - * - * @example - * faker.date.weekday() // 'Monday' - * faker.date.weekday({ abbr: true }) // 'Thu' - * faker.date.weekday({ context: true }) // 'Thursday' - * faker.date.weekday({ abbr: true, context: true }) // 'Fri' - * - * @since 3.0.1 - * - * @deprecated Use `faker.date.weekday({ abbreviated, ... })` instead. - */ - weekday(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; - /** - * Whether to return the day of the week in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random day of the week. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.abbreviated Whether to return an abbreviation. Defaults to `false`. - * @param options.context Whether to return the day of the week in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. Defaults to `false`. - * - * @example - * faker.date.weekday() // 'Monday' - * faker.date.weekday({ abbreviated: true }) // 'Thu' - * faker.date.weekday({ context: true }) // 'Thursday' - * faker.date.weekday({ abbreviated: true, context: true }) // 'Fri' - * - * @since 3.0.1 - */ - weekday(options?: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; - /** - * Whether to return an abbreviation. - * - * @default false - */ - abbreviated?: boolean; - /** - * Whether to return the day of the week in the context of a date. - * - * In the default `en` locale this has no effect, - * however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, - * for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. - * - * @default false - */ - context?: boolean; - }): string; - /** - * Returns a random day of the week. - * - * @param options The optional options to use. - * @param options.abbr Deprecated, use `abbreviated` instead. - * @param options.abbreviated Whether to return an abbreviation. Defaults to `false`. - * @param options.context Whether to return the day of the week in the context of a date. In the default `en` locale this has no effect, however, in other locales like `fr` or `ru`, this may affect grammar or capitalization, for example `'Lundi'` with `{ context: false }` and `'lundi'` with `{ context: true }` in `fr`. Defaults to `false`. - * - * @example - * faker.date.weekday() // 'Monday' - * faker.date.weekday({ abbreviated: true }) // 'Thu' - * faker.date.weekday({ context: true }) // 'Thursday' - * faker.date.weekday({ abbreviated: true, context: true }) // 'Fri' - * - * @since 3.0.1 - */ weekday( options: { - /** - * Whether to return an abbreviation. - * - * @default false - * - * @deprecated Use `abbreviated` instead. - */ - abbr?: boolean; /** * Whether to return an abbreviation. * @@ -1265,17 +556,7 @@ export class DateModule extends SimpleDateModule { context?: boolean; } = {} ): string { - // eslint-disable-next-line deprecation/deprecation - const { abbr, abbreviated = abbr ?? false, context = false } = options; - - if (abbr != null) { - deprecated({ - deprecated: 'faker.date.weekday({ abbr })', - proposed: 'faker.date.weekday({ abbreviated })', - since: '8.0', - until: '9.0', - }); - } + const { abbreviated = false, context = false } = options; const source = this.faker.definitions.date.weekday; let type: keyof DateEntryDefinition; diff --git a/test/all-functional.spec.ts b/test/all-functional.spec.ts index 5f7618ff81b..51540feb518 100644 --- a/test/all-functional.spec.ts +++ b/test/all-functional.spec.ts @@ -49,6 +49,10 @@ const BROKEN_LOCALE_METHODS = { suffixes: ['az'], companySuffix: ['az'], }, + date: { + between: '*', + betweens: '*', + }, location: { state: ['az', 'nb_NO', 'ro_MD', 'sk'], stateAbbr: ['cs_CZ', 'ro_MD', 'sk'], diff --git a/test/modules/__snapshots__/date.spec.ts.snap b/test/modules/__snapshots__/date.spec.ts.snap index 1b28f47bd47..9b3c3d7659b 100644 --- a/test/modules/__snapshots__/date.spec.ts.snap +++ b/test/modules/__snapshots__/date.spec.ts.snap @@ -380,219 +380,3 @@ exports[`date > 1337 > weekday > with abbreviated = true 1`] = `"Mon"`; exports[`date > 1337 > weekday > with abbreviated = true and context = true 1`] = `"Mon"`; exports[`date > 1337 > weekday > with context = true 1`] = `"Monday"`; - -exports[`date > deprecated > 42 > between > with Date dates 1`] = `2021-03-15T19:30:57.115Z`; - -exports[`date > deprecated > 42 > between > with string dates 1`] = `2021-03-15T19:30:57.115Z`; - -exports[`date > deprecated > 42 > betweens > with Date dates 1`] = ` -[ - 2021-03-15T19:30:57.115Z, - 2021-04-05T21:40:57.332Z, - 2021-04-18T19:23:52.947Z, -] -`; - -exports[`date > deprecated > 42 > betweens > with Date dates and count 1`] = ` -[ - 2021-03-02T22:04:55.366Z, - 2021-03-15T19:30:57.115Z, - 2021-03-29T00:52:30.236Z, - 2021-04-05T21:40:57.332Z, - 2021-04-18T19:23:52.947Z, -] -`; - -exports[`date > deprecated > 42 > betweens > with string dates 1`] = ` -[ - 2021-03-15T19:30:57.115Z, - 2021-04-05T21:40:57.332Z, - 2021-04-18T19:23:52.947Z, -] -`; - -exports[`date > deprecated > 42 > betweens > with string dates and count 1`] = ` -[ - 2021-03-02T22:04:55.366Z, - 2021-03-15T19:30:57.115Z, - 2021-03-29T00:52:30.236Z, - 2021-04-05T21:40:57.332Z, - 2021-04-18T19:23:52.947Z, -] -`; - -exports[`date > deprecated > 42 > future > with only Date refDate 1`] = `2021-07-08T10:07:33.524Z`; - -exports[`date > deprecated > 42 > future > with only number refDate 1`] = `2021-07-08T10:07:33.524Z`; - -exports[`date > deprecated > 42 > future > with only string refDate 1`] = `2021-07-08T10:07:33.524Z`; - -exports[`date > deprecated > 42 > future > with value 1`] = `2024-11-19T18:52:08.216Z`; - -exports[`date > deprecated > 42 > past > with only Date refDate 1`] = `2020-10-08T00:10:57.898Z`; - -exports[`date > deprecated > 42 > past > with only number refDate 1`] = `2020-10-08T00:10:57.898Z`; - -exports[`date > deprecated > 42 > past > with only string refDate 1`] = `2020-10-08T00:10:57.898Z`; - -exports[`date > deprecated > 42 > past > with value 1`] = `2017-05-26T15:26:23.206Z`; - -exports[`date > deprecated > 42 > recent > with only Date refDate 1`] = `2021-02-21T08:09:54.819Z`; - -exports[`date > deprecated > 42 > recent > with only number refDate 1`] = `2021-02-21T08:09:54.819Z`; - -exports[`date > deprecated > 42 > recent > with only string refDate 1`] = `2021-02-21T08:09:54.819Z`; - -exports[`date > deprecated > 42 > recent > with value 1`] = `2021-02-17T23:15:52.423Z`; - -exports[`date > deprecated > 42 > soon > with only Date refDate 1`] = `2021-02-22T02:08:36.603Z`; - -exports[`date > deprecated > 42 > soon > with only number refDate 1`] = `2021-02-22T02:08:36.603Z`; - -exports[`date > deprecated > 42 > soon > with only string refDate 1`] = `2021-02-22T02:08:36.603Z`; - -exports[`date > deprecated > 42 > soon > with value 1`] = `2021-02-25T11:02:38.999Z`; - -exports[`date > deprecated > 1211 > between > with Date dates 1`] = `2021-04-17T11:58:13.327Z`; - -exports[`date > deprecated > 1211 > between > with string dates 1`] = `2021-04-17T11:58:13.327Z`; - -exports[`date > deprecated > 1211 > betweens > with Date dates 1`] = ` -[ - 2021-03-07T00:34:12.745Z, - 2021-04-15T10:20:25.794Z, - 2021-04-17T11:58:13.327Z, -] -`; - -exports[`date > deprecated > 1211 > betweens > with Date dates and count 1`] = ` -[ - 2021-03-07T00:34:12.745Z, - 2021-04-02T08:42:57.721Z, - 2021-04-15T10:20:25.794Z, - 2021-04-17T11:58:13.327Z, - 2021-04-21T13:18:14.822Z, -] -`; - -exports[`date > deprecated > 1211 > betweens > with string dates 1`] = ` -[ - 2021-03-07T00:34:12.745Z, - 2021-04-15T10:20:25.794Z, - 2021-04-17T11:58:13.327Z, -] -`; - -exports[`date > deprecated > 1211 > betweens > with string dates and count 1`] = ` -[ - 2021-03-07T00:34:12.745Z, - 2021-04-02T08:42:57.721Z, - 2021-04-15T10:20:25.794Z, - 2021-04-17T11:58:13.327Z, - 2021-04-21T13:18:14.822Z, -] -`; - -exports[`date > deprecated > 1211 > future > with only Date refDate 1`] = `2022-01-26T14:59:27.356Z`; - -exports[`date > deprecated > 1211 > future > with only number refDate 1`] = `2022-01-26T14:59:27.356Z`; - -exports[`date > deprecated > 1211 > future > with only string refDate 1`] = `2022-01-26T14:59:27.356Z`; - -exports[`date > deprecated > 1211 > future > with value 1`] = `2030-06-03T19:31:11.518Z`; - -exports[`date > deprecated > 1211 > past > with only Date refDate 1`] = `2020-03-19T19:19:04.066Z`; - -exports[`date > deprecated > 1211 > past > with only number refDate 1`] = `2020-03-19T19:19:04.066Z`; - -exports[`date > deprecated > 1211 > past > with only string refDate 1`] = `2020-03-19T19:19:04.066Z`; - -exports[`date > deprecated > 1211 > past > with value 1`] = `2011-11-12T14:47:19.904Z`; - -exports[`date > deprecated > 1211 > recent > with only Date refDate 1`] = `2021-02-20T18:52:11.498Z`; - -exports[`date > deprecated > 1211 > recent > with only number refDate 1`] = `2021-02-20T18:52:11.498Z`; - -exports[`date > deprecated > 1211 > recent > with only string refDate 1`] = `2021-02-20T18:52:11.498Z`; - -exports[`date > deprecated > 1211 > recent > with value 1`] = `2021-02-12T10:18:34.226Z`; - -exports[`date > deprecated > 1211 > soon > with only Date refDate 1`] = `2021-02-22T15:26:19.924Z`; - -exports[`date > deprecated > 1211 > soon > with only number refDate 1`] = `2021-02-22T15:26:19.924Z`; - -exports[`date > deprecated > 1211 > soon > with only string refDate 1`] = `2021-02-22T15:26:19.924Z`; - -exports[`date > deprecated > 1211 > soon > with value 1`] = `2021-03-02T23:59:57.196Z`; - -exports[`date > deprecated > 1337 > between > with Date dates 1`] = `2021-03-09T04:11:24.661Z`; - -exports[`date > deprecated > 1337 > between > with string dates 1`] = `2021-03-09T04:11:24.661Z`; - -exports[`date > deprecated > 1337 > betweens > with Date dates 1`] = ` -[ - 2021-03-03T01:51:22.487Z, - 2021-03-09T04:11:24.661Z, - 2021-03-10T02:59:27.388Z, -] -`; - -exports[`date > deprecated > 1337 > betweens > with Date dates and count 1`] = ` -[ - 2021-03-03T01:51:22.487Z, - 2021-03-09T04:11:24.661Z, - 2021-03-10T02:59:27.388Z, - 2021-03-12T15:42:07.228Z, - 2021-03-20T19:33:45.512Z, -] -`; - -exports[`date > deprecated > 1337 > betweens > with string dates 1`] = ` -[ - 2021-03-03T01:51:22.487Z, - 2021-03-09T04:11:24.661Z, - 2021-03-10T02:59:27.388Z, -] -`; - -exports[`date > deprecated > 1337 > betweens > with string dates and count 1`] = ` -[ - 2021-03-03T01:51:22.487Z, - 2021-03-09T04:11:24.661Z, - 2021-03-10T02:59:27.388Z, - 2021-03-12T15:42:07.228Z, - 2021-03-20T19:33:45.512Z, -] -`; - -exports[`date > deprecated > 1337 > future > with only Date refDate 1`] = `2021-05-28T08:29:26.600Z`; - -exports[`date > deprecated > 1337 > future > with only number refDate 1`] = `2021-05-28T08:29:26.600Z`; - -exports[`date > deprecated > 1337 > future > with only string refDate 1`] = `2021-05-28T08:29:26.600Z`; - -exports[`date > deprecated > 1337 > future > with value 1`] = `2023-10-06T02:30:57.962Z`; - -exports[`date > deprecated > 1337 > past > with only Date refDate 1`] = `2020-11-18T01:49:04.822Z`; - -exports[`date > deprecated > 1337 > past > with only number refDate 1`] = `2020-11-18T01:49:04.822Z`; - -exports[`date > deprecated > 1337 > past > with only string refDate 1`] = `2020-11-18T01:49:04.822Z`; - -exports[`date > deprecated > 1337 > past > with value 1`] = `2018-07-11T07:47:33.460Z`; - -exports[`date > deprecated > 1337 > recent > with only Date refDate 1`] = `2021-02-21T10:51:56.041Z`; - -exports[`date > deprecated > 1337 > recent > with only number refDate 1`] = `2021-02-21T10:51:56.041Z`; - -exports[`date > deprecated > 1337 > recent > with only string refDate 1`] = `2021-02-21T10:51:56.041Z`; - -exports[`date > deprecated > 1337 > recent > with value 1`] = `2021-02-19T02:16:05.654Z`; - -exports[`date > deprecated > 1337 > soon > with only Date refDate 1`] = `2021-02-21T23:26:35.381Z`; - -exports[`date > deprecated > 1337 > soon > with only number refDate 1`] = `2021-02-21T23:26:35.381Z`; - -exports[`date > deprecated > 1337 > soon > with only string refDate 1`] = `2021-02-21T23:26:35.381Z`; - -exports[`date > deprecated > 1337 > soon > with value 1`] = `2021-02-24T08:02:25.768Z`; diff --git a/test/modules/date.spec.ts b/test/modules/date.spec.ts index d2e0833719c..303dc407524 100644 --- a/test/modules/date.spec.ts +++ b/test/modules/date.spec.ts @@ -141,66 +141,6 @@ describe('date', () => { }); }); - describe('deprecated', () => { - seededTests(faker, 'date', (t) => { - t.describeEach( - 'past', - 'recent', - 'soon', - 'future' - )((t) => { - t.it('with only string refDate', undefined, refDate) - .it('with only Date refDate', undefined, new Date(refDate)) - .it( - 'with only number refDate', - undefined, - new Date(refDate).getTime() - ) - .it('with value', 10, refDate); - }); - - t.describe('between', (t) => { - t.it( - 'with string dates', - '2021-02-21T17:09:15.711Z', - '2021-04-21T17:11:17.711Z' - ).it( - 'with Date dates', - new Date('2021-02-21T17:09:15.711Z'), - new Date('2021-04-21T17:11:17.711Z') - ); - }); - - t.describe('betweens', (t) => { - t.it( - 'with string dates', - '2021-02-21T17:09:15.711Z', - '2021-04-21T17:11:17.711Z' - ) - .it( - 'with Date dates', - new Date('2021-02-21T17:09:15.711Z'), - new Date('2021-04-21T17:11:17.711Z') - ) - .it( - 'with string dates and count', - '2021-02-21T17:09:15.711Z', - '2021-04-21T17:11:17.711Z', - 5 - ) - .it( - 'with Date dates and count', - new Date('2021-02-21T17:09:15.711Z'), - new Date('2021-04-21T17:11:17.711Z'), - 5 - ); - }); - - // No changes to these methods - t.skip('anytime').skip('birthdate').skip('month').skip('weekday'); - }); - }); - describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))( 'random seeded tests for seed %i', () => { @@ -325,11 +265,11 @@ describe('date', () => { const from = new Date(1990, 5, 7, 9, 11, 0, 0); const to = new Date(2000, 6, 8, 10, 12, 0, 0); - const dates = faker.date.betweens( - converter(from), - converter(to), - 2 - ); + const dates = faker.date.betweens({ + from: converter(from), + to: converter(to), + count: 2, + }); expect(dates).toHaveLength(2); @@ -458,22 +398,11 @@ describe('date', () => { expect(fakerAZ.definitions.date.month.wide_context).toContain(month); }); - it('should return random value from date.month.abbr array for abbr option', () => { - const month = faker.date.month({ abbr: true }); - expect(faker.definitions.date.month.abbr).toContain(month); - }); - it('should return random value from date.month.abbr array for abbreviated option', () => { const month = faker.date.month({ abbreviated: true }); expect(faker.definitions.date.month.abbr).toContain(month); }); - it('should return random value from date.month.abbr_context array for abbr and context option', () => { - // Use a locale (e.g. az) which has a wide_context array - const month = fakerAZ.date.month({ abbr: true, context: true }); - expect(fakerAZ.definitions.date.month.abbr_context).toContain(month); - }); - it('should return random value from date.month.abbr_context array for abbreviated and context option', () => { // Use a locale (e.g. az) which has a wide_context array const month = fakerAZ.date.month({ @@ -489,12 +418,6 @@ describe('date', () => { expect(faker.definitions.date.month.wide).toContain(month); }); - it('should return random value from date.month.abbr array for abbr and context option when date.month.abbr_context array is missing', () => { - // Use a locale (e.g. the default en) which has no abbr_context array - const month = faker.date.month({ abbr: true, context: true }); - expect(faker.definitions.date.month.abbr).toContain(month); - }); - it('should return random value from date.month.abbr array for abbreviated and context option when date.month.abbr_context array is missing', () => { // Use a locale (e.g. the default en) which has no abbr_context array const month = faker.date.month({ abbreviated: true, context: true }); @@ -516,24 +439,11 @@ describe('date', () => { ); }); - it('should return random value from date.weekday.abbr array for abbr option', () => { - const weekday = faker.date.weekday({ abbr: true }); - expect(faker.definitions.date.weekday.abbr).toContain(weekday); - }); - it('should return random value from date.weekday.abbr array for abbreviated option', () => { const weekday = faker.date.weekday({ abbreviated: true }); expect(faker.definitions.date.weekday.abbr).toContain(weekday); }); - it('should return random value from date.weekday.abbr_context array for abbr and context option', () => { - // Use a locale (e.g. az) which has a abbr_context array - const weekday = fakerAZ.date.weekday({ abbr: true, context: true }); - expect(fakerAZ.definitions.date.weekday.abbr_context).toContain( - weekday - ); - }); - it('should return random value from date.weekday.abbr_context array for abbreviated and context option', () => { // Use a locale (e.g. az) which has a abbr_context array const weekday = fakerAZ.date.weekday({ @@ -551,12 +461,6 @@ describe('date', () => { expect(faker.definitions.date.weekday.wide).toContain(weekday); }); - it('should return random value from date.weekday.abbr array for abbr and context option when date.weekday.abbr_context array is missing', () => { - // Use a locale (e.g. the default en) which has no abbr_context array - const weekday = faker.date.weekday({ abbr: true, context: true }); - expect(faker.definitions.date.weekday.abbr).toContain(weekday); - }); - it('should return random value from date.weekday.abbr array for abbreviated and context option when date.weekday.abbr_context array is missing', () => { // Use a locale (e.g. the default en) which has no abbr_context array const weekday = faker.date.weekday({ @@ -647,177 +551,6 @@ describe('date', () => { ); }); }); - - describe('deprecated', () => { - describe('past()', () => { - it('should return a date 5 years in the past', () => { - const today = new Date(); - const yearsAgo = new Date(today); - yearsAgo.setFullYear(yearsAgo.getFullYear() - 5); - - const date = faker.date.past(5); - - expect(date).lessThan(today); - expect(date).greaterThanOrEqual(yearsAgo); - }); - - it('should throw an error when years = 0', () => { - const refDate = new Date(); - expect(() => faker.date.past(0, refDate.toISOString())).toThrow( - new FakerError('Years must be greater than 0.') - ); - }); - - it.each(converterMap)( - 'should return a past date relative to given refDate', - (converter) => { - const refDate = new Date(); - refDate.setFullYear(refDate.getFullYear() + 5); - - const date = faker.date.past(5, converter(refDate)); - - expect(date).lessThan(refDate); - expect(date).greaterThan(new Date()); - } - ); - }); - - describe('future()', () => { - it('should return a date 75 years into the future', () => { - const date = faker.date.future(75); - - expect(date).greaterThan(new Date()); - }); - - it('should throw an error when years = 0', () => { - const refDate = new Date(); - expect(() => faker.date.future(0, refDate.toISOString())).toThrow( - new FakerError('Years must be greater than 0.') - ); - }); - - it.each(converterMap)( - 'should return a date 75 years after the date given', - (converter) => { - const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly) - - const date = faker.date.future(75, converter(refDate)); - - // date should be after the date given, but before the current time - expect(date).greaterThan(refDate); - expect(date).lessThan(new Date()); - } - ); - }); - - describe('between()', () => { - it.each(converterMap)( - 'should return a random date between the dates given', - (converter) => { - const from = new Date(1990, 5, 7, 9, 11, 0, 0); - const to = new Date(2000, 6, 8, 10, 12, 0, 0); - - const date = faker.date.between(converter(from), converter(to)); - - expect(date).greaterThan(from); - expect(date).lessThan(to); - } - ); - }); - - describe('betweens()', () => { - it.each(converterMap)( - 'should return an array of 3 dates ( by default ) of sorted randoms dates between the dates given', - (converter) => { - const from = new Date(1990, 5, 7, 9, 11, 0, 0); - const to = new Date(2000, 6, 8, 10, 12, 0, 0); - - const dates = faker.date.betweens(converter(from), converter(to)); - - expect(dates[0]).greaterThan(from); - expect(dates[0]).lessThan(to); - expect(dates[1]).greaterThan(dates[0]); - expect(dates[2]).greaterThan(dates[1]); - } - ); - }); - - describe('recent()', () => { - it('should return a date N days from the recent past', () => { - const date = faker.date.recent(30); - - expect(date).lessThanOrEqual(new Date()); - }); - - it('should throw an error when days = 0', () => { - const refDate = new Date(); - expect(() => faker.date.recent(0, refDate.toISOString())).toThrow( - new FakerError('Days must be greater than 0.') - ); - }); - - it.each(converterMap)( - 'should return a date N days from the recent past, starting from refDate', - (converter) => { - const days = 30; - const refDate = new Date(2120, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly) - - const lowerBound = new Date( - refDate.getTime() - days * 24 * 60 * 60 * 1000 - ); - - const date = faker.date.recent(days, converter(refDate)); - - expect( - lowerBound, - '`recent()` date should not be further back than `n` days ago' - ).lessThanOrEqual(date); - expect( - date, - '`recent()` date should not be ahead of the starting date reference' - ).lessThanOrEqual(refDate); - } - ); - }); - - describe('soon()', () => { - it('should return a date N days into the future', () => { - const date = faker.date.soon(30); - - expect(date).greaterThanOrEqual(new Date()); - }); - - it('should throw an error when days = 0', () => { - const refDate = new Date(); - expect(() => faker.date.soon(0, refDate.toISOString())).toThrow( - new FakerError('Days must be greater than 0.') - ); - }); - - it.each(converterMap)( - 'should return a date N days from the recent future, starting from refDate', - (converter) => { - const days = 30; - const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly) - - const upperBound = new Date( - refDate.getTime() + days * 24 * 60 * 60 * 1000 - ); - - const date = faker.date.soon(days, converter(refDate)); - - expect( - date, - '`soon()` date should not be further ahead than `n` days ago' - ).lessThanOrEqual(upperBound); - expect( - refDate, - '`soon()` date should not be behind the starting date reference' - ).lessThanOrEqual(date); - } - ); - }); - }); } ); From 660da4c401b36ebfe0c0f7975c265146d9224921 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Tue, 5 Mar 2024 15:49:25 +0100 Subject: [PATCH 4/5] refactor(phone)!: remove v8 deprecated phone format (#2712) --- docs/guide/upgrading_v9/2712.md | 7 +++ src/modules/phone/index.ts | 53 ++----------------- test/modules/__snapshots__/phone.spec.ts.snap | 6 --- test/modules/phone.spec.ts | 2 +- 4 files changed, 12 insertions(+), 56 deletions(-) create mode 100644 docs/guide/upgrading_v9/2712.md diff --git a/docs/guide/upgrading_v9/2712.md b/docs/guide/upgrading_v9/2712.md new file mode 100644 index 00000000000..660523f67f2 --- /dev/null +++ b/docs/guide/upgrading_v9/2712.md @@ -0,0 +1,7 @@ +### Remove deprecated phone methods + +Removed deprecated phone methods + +| old | replacement | +| ---------------------------- | -------------------------------------------------------------------------------- | +| `faker.phone.number(format)` | `faker.phone.number()`, `faker.string.numeric()` or `faker.helpers.fromRegExp()` | diff --git a/src/modules/phone/index.ts b/src/modules/phone/index.ts index 833938d71fc..44f2a111de8 100644 --- a/src/modules/phone/index.ts +++ b/src/modules/phone/index.ts @@ -1,4 +1,3 @@ -import { deprecated } from '../../internal/deprecated'; import { ModuleBase } from '../../internal/module-base'; import { legacyReplaceSymbolWithNumber } from '../helpers'; @@ -21,54 +20,10 @@ export class PhoneModule extends ModuleBase { * * @since 7.3.0 */ - number(): string; - /** - * Generates a random phone number. - * - * @param format Format of the phone number. - * - * @see faker.string.numeric(): For generating a random string of numbers. - * @see faker.helpers.fromRegExp(): For generating a phone number matching a regular expression. - * - * @example - * faker.phone.number('501-###-###') // '501-039-841' - * faker.phone.number('+48 91 ### ## ##') // '+48 91 463 61 70' - * - * @since 7.3.0 - * - * @deprecated Use `faker.phone.number()` without an argument, `faker.string.numeric()` or `faker.helpers.fromRegExp()` instead. - */ - number(format: string): string; - /** - * Generates a random phone number. - * - * @param format Format of the phone number. Defaults to a random phone number format. - * - * @see faker.string.numeric(): For generating a random string of numbers. - * @see faker.helpers.fromRegExp(): For generating a phone number matching a regular expression. - * - * @example - * faker.phone.number() // '961-770-7727' - * - * @since 7.3.0 - */ - number(format?: string): string; - number(format?: string): string { - if (format != null) { - deprecated({ - deprecated: 'faker.phone.number(format)', - proposed: - 'faker.phone.number(), faker.string.numeric() or faker.helpers.fromRegExp()', - since: '8.1', - until: '9.0', - }); - } - - format = - format ?? - this.faker.helpers.arrayElement( - this.faker.definitions.phone_number.formats - ); + number(): string { + const format = this.faker.helpers.arrayElement( + this.faker.definitions.phone_number.formats + ); return legacyReplaceSymbolWithNumber(this.faker, format); } diff --git a/test/modules/__snapshots__/phone.spec.ts.snap b/test/modules/__snapshots__/phone.spec.ts.snap index 2f60813caf7..20928c043e0 100644 --- a/test/modules/__snapshots__/phone.spec.ts.snap +++ b/test/modules/__snapshots__/phone.spec.ts.snap @@ -2,18 +2,12 @@ exports[`phone > 42 > imei 1`] = `"39-751108-670982-8"`; -exports[`phone > 42 > number > format 1`] = `"397-511-0867"`; - exports[`phone > 42 > number > noArgs 1`] = `"(975) 310-8670 x982"`; exports[`phone > 1211 > imei 1`] = `"98-296673-687684-2"`; -exports[`phone > 1211 > number > format 1`] = `"982-966-7368"`; - exports[`phone > 1211 > number > noArgs 1`] = `"1-929-767-3687 x68488"`; exports[`phone > 1337 > imei 1`] = `"21-243529-713619-6"`; -exports[`phone > 1337 > number > format 1`] = `"212-435-2971"`; - exports[`phone > 1337 > number > noArgs 1`] = `"324-452-9713 x619"`; diff --git a/test/modules/phone.spec.ts b/test/modules/phone.spec.ts index 4ee4241703d..4e1a76a353f 100644 --- a/test/modules/phone.spec.ts +++ b/test/modules/phone.spec.ts @@ -11,7 +11,7 @@ describe('phone', () => { t.it('imei'); t.describe('number', (t) => { - t.it('noArgs').it('format', '###-###-####'); + t.it('noArgs'); }); }); From 489bbc243f3094464888bdf7fb90835fcfa57691 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:54:14 +0700 Subject: [PATCH 5/5] test: verify locale code is format in metadata (#2713) --- test/locale-imports.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/locale-imports.spec.ts b/test/locale-imports.spec.ts index 4c1197c886f..229f782a818 100644 --- a/test/locale-imports.spec.ts +++ b/test/locale-imports.spec.ts @@ -35,6 +35,11 @@ describe.each(keys(allLocales))('locale imports', (locale) => { expect(metadata.code).toBeTypeOf('string'); expect(metadata.code).toEqual(locale); if (locale !== 'base') { + expect(metadata.code).toEqual( + [metadata.language, metadata.country, metadata.variant] + .filter((v) => v != null) + .join('_') + ); expect(metadata.language).toBeTypeOf('string'); expect(metadata.language).toMatch(/^[a-z]{2}$/); expect(metadata.script).toBeTypeOf('string');