From 1da929049c9c924e6688820550300ada110e911f Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sat, 2 Nov 2024 23:22:39 +0100 Subject: [PATCH 1/8] test: patch and filter seeded run stacktraces (#3229) --- test/support/seeded-runs.ts | 74 +++++++++++++++++++++++++++++++++++-- vitest.config.ts | 10 +++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/test/support/seeded-runs.ts b/test/support/seeded-runs.ts index dee0051c11b..66d6df3c4dd 100644 --- a/test/support/seeded-runs.ts +++ b/test/support/seeded-runs.ts @@ -134,11 +134,13 @@ class TestGenerator< * * @param method The method name to call. * @param args The arguments to call it with. + * @param extraStackFrames Additional stack frames to add into the stacktrace. * @param repetitions The number of times to call it. */ private callAndVerify>( method: TMethodName, args: Parameters, + extraStackFrames: () => string[], repetitions: number = 1 ): void { this.setup(); @@ -148,8 +150,12 @@ class TestGenerator< } for (let i = 0; i < repetitions; i++) { - const value = callable(...args); - expect(value).toMatchSnapshot(); + try { + const value = callable(...args); + expect(value).toMatchSnapshot(); + } catch (error: unknown) { + throw patchExtraStackFrames(error, extraStackFrames); + } } } @@ -182,10 +188,12 @@ class TestGenerator< */ itRepeated(method: NoArgsMethodOf, repetitions: number): this { this.expectNotTested(method); + const extraStackFrames = collectExtraStackFrames(); vi_it(method, () => this.callAndVerify( method, [] as unknown as Parameters]>, + extraStackFrames, repetitions ) ); @@ -233,7 +241,10 @@ class TestGenerator< const tester: MethodTester = { it(name: string, ...args: Parameters) { expectVariantNotTested(name); - vi_it(name, () => callAndVerify(method, args)); + const extraStackFrames = collectExtraStackFrames( + /* t. */ `it('${name}', `.length // ...args) + ); + vi_it(name, () => callAndVerify(method, args, extraStackFrames)); return tester; }, itRepeated( @@ -242,7 +253,12 @@ class TestGenerator< ...args: Parameters ) { expectVariantNotTested(name); - vi_it(name, () => callAndVerify(method, args, repetitions)); + const extraStackFrames = collectExtraStackFrames( + /* t. */ `itRepeated('${name}', ${repetitions}, `.length // ...args) + ); + vi_it(name, () => + callAndVerify(method, args, extraStackFrames, repetitions) + ); return tester; }, }; @@ -288,6 +304,56 @@ class TestGenerator< } } +/** + * Lazily collects the current call stack with an additional offset. + * + * Vitest's stacktraces only contain the stacktrace from inside `it(name, () => { here })`. + * This method collects the location where the `it` block is created instead of executed. + * The stack frames can then later be added to the error stack to provide a more accurate location. + * + * @param extraOffset The additional offset to add to the column numbers to account for the name of the test. + */ +function collectExtraStackFrames(extraOffset: number = 0): () => string[] { + const stack = new Error('collect').stack; + if (stack == null) { + return () => []; + } + + return () => + stack + .split('\n') + .map((e) => e.replaceAll('\\', '/')) // Windows to Linux paths + .filter((e) => e.includes('/test/')) // exclude node_modules + .filter((e) => !e.includes('/test/support/')) // exclude this file + .map((e) => + e.replace(/:(\d+)$/, (_, column: string) => `:${+column + extraOffset}`) + ); +} + +/** + * Modifies the error stack to include the given additional stack frames after the last occurrence of this file. + * + * @param error The error to modify. + * @param extraStackFrames The additional stack frames to add. + */ +function patchExtraStackFrames( + error: unknown, + extraStackFrames: () => string[] +): unknown { + if (error instanceof Error && error.stack != null) { + const stack = error.stack.split('\n'); + const index = stack.findLastIndex((e) => + e + .replaceAll('\\', '/') // Windows to Linux paths + .includes('/test/support/') + ); + stack.splice(index + 1, 0, ...extraStackFrames()); + error.stack = stack.join('\n'); + } + + return error; +} + /** * Simple interface for a test generator for a given method. */ diff --git a/vitest.config.ts b/vitest.config.ts index ad95ef967cf..94991a6f777 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -20,6 +20,16 @@ export default defineConfig({ seed: VITEST_SEQUENCE_SEED, shuffle: true, }, + onStackTrace(_, { file }) { + if ( + file.includes('/src/internal/locale-proxy') || + file.includes('/test/support/') + ) { + return false; + } + + return true; + }, typecheck: { enabled: true, include: ['test/**/*.spec-d.ts'], From 99d81bed28b36ab525340e32a7349799cbe88eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=2E=20Le=C3=B3n?= Date: Sat, 2 Nov 2024 23:27:21 +0100 Subject: [PATCH 2/8] refactor(locale): improve Spanish color names (#3230) --- src/locales/es/color/human.ts | 46 ++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/locales/es/color/human.ts b/src/locales/es/color/human.ts index 06c58f80969..18312da977b 100644 --- a/src/locales/es/color/human.ts +++ b/src/locales/es/color/human.ts @@ -1,11 +1,39 @@ export default [ - 'Amarillo', - 'Azul', - 'Blanco', - 'Gris', - 'Morado', - 'Negro', - 'Rojo', - 'Verde', - 'Violeta', + 'amarillo', + 'azul', + 'azul marino', + 'beige', + 'blanco', + 'carmesí', + 'celeste', + 'cian', + 'crema', + 'dorado', + 'esmeralda', + 'fucsia', + 'granate', + 'gris', + 'gualda', + 'lavanda', + 'lila', + 'magenta', + 'marfil', + 'marrón', + 'morado', + 'naranja', + 'negro', + 'ocre', + 'plateado', + 'púrpura', + 'rojo', + 'rosa', + 'salmón', + 'terracota', + 'turquesa', + 'verde', + 'verde lima', + 'verde menta', + 'verde oliva', + 'violeta', + 'índigo', ]; From 290e7c9660ff059920a2bff922f06d7bd7cf53e8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 3 Nov 2024 08:55:58 +0100 Subject: [PATCH 3/8] chore(deps): update eslint (#3238) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: ST-DDT --- eslint.config.ts | 5 +- package.json | 10 +- pnpm-lock.yaml | 258 +++++++++++++++++++++++++---------------------- 3 files changed, 149 insertions(+), 124 deletions(-) diff --git a/eslint.config.ts b/eslint.config.ts index e4dc76bb14a..6ec1f0db74d 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -115,7 +115,10 @@ const config: ReturnType = tseslint.config( ], '@typescript-eslint/switch-exhaustiveness-check': [ 'error', - { requireDefaultForNonUnion: true }, + { + considerDefaultExhaustiveForUnions: true, // we consider default cases for unions valid + requireDefaultForNonUnion: true, + }, ], '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation diff --git a/package.json b/package.json index 820c45dd018..67f99c80e0c 100644 --- a/package.json +++ b/package.json @@ -104,9 +104,9 @@ ], "devDependencies": { "@actions/github": "6.0.0", - "@eslint/compat": "1.2.1", - "@eslint/js": "9.13.0", - "@stylistic/eslint-plugin": "2.9.0", + "@eslint/compat": "1.2.2", + "@eslint/js": "9.14.0", + "@stylistic/eslint-plugin": "2.10.1", "@types/eslint__js": "8.42.3", "@types/node": "22.8.6", "@types/sanitize-html": "2.13.0", @@ -118,7 +118,7 @@ "@vueuse/core": "11.2.0", "commit-and-tag-version": "12.5.0", "cypress": "13.15.1", - "eslint": "9.13.0", + "eslint": "9.14.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-jsdoc": "50.4.3", "eslint-plugin-prettier": "5.2.1", @@ -135,7 +135,7 @@ "tsup": "8.3.5", "tsx": "4.19.2", "typescript": "5.6.3", - "typescript-eslint": "8.11.0", + "typescript-eslint": "8.12.2", "validator": "13.12.0", "vitepress": "1.4.3", "vitest": "2.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5bb1a97986a..b52f86eb2b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,14 +12,14 @@ importers: specifier: 6.0.0 version: 6.0.0 '@eslint/compat': - specifier: 1.2.1 - version: 1.2.1(eslint@9.13.0(jiti@2.3.3)) + specifier: 1.2.2 + version: 1.2.2(eslint@9.14.0(jiti@2.3.3)) '@eslint/js': - specifier: 9.13.0 - version: 9.13.0 + specifier: 9.14.0 + version: 9.14.0 '@stylistic/eslint-plugin': - specifier: 2.9.0 - version: 2.9.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) + specifier: 2.10.1 + version: 2.10.1(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) '@types/eslint__js': specifier: 8.42.3 version: 8.42.3 @@ -40,7 +40,7 @@ importers: version: 2.1.4(vitest@2.1.4) '@vitest/eslint-plugin': specifier: 1.1.7 - version: 1.1.7(@typescript-eslint/utils@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)(vitest@2.1.4) + version: 1.1.7(@typescript-eslint/utils@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)(vitest@2.1.4) '@vitest/ui': specifier: 2.1.4 version: 2.1.4(vitest@2.1.4) @@ -54,20 +54,20 @@ importers: specifier: 13.15.1 version: 13.15.1 eslint: - specifier: 9.13.0 - version: 9.13.0(jiti@2.3.3) + specifier: 9.14.0 + version: 9.14.0(jiti@2.3.3) eslint-config-prettier: specifier: 9.1.0 - version: 9.1.0(eslint@9.13.0(jiti@2.3.3)) + version: 9.1.0(eslint@9.14.0(jiti@2.3.3)) eslint-plugin-jsdoc: specifier: 50.4.3 - version: 50.4.3(eslint@9.13.0(jiti@2.3.3)) + version: 50.4.3(eslint@9.14.0(jiti@2.3.3)) eslint-plugin-prettier: specifier: 5.2.1 - version: 5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.13.0(jiti@2.3.3)))(eslint@9.13.0(jiti@2.3.3))(prettier@3.3.3) + version: 5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.14.0(jiti@2.3.3)))(eslint@9.14.0(jiti@2.3.3))(prettier@3.3.3) eslint-plugin-unicorn: specifier: 56.0.0 - version: 56.0.0(eslint@9.13.0(jiti@2.3.3)) + version: 56.0.0(eslint@9.14.0(jiti@2.3.3)) jiti: specifier: 2.3.3 version: 2.3.3 @@ -105,8 +105,8 @@ importers: specifier: 5.6.3 version: 5.6.3 typescript-eslint: - specifier: 8.11.0 - version: 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) + specifier: 8.12.2 + version: 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) validator: specifier: 13.12.0 version: 13.12.0 @@ -698,8 +698,8 @@ packages: resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/compat@1.2.1': - resolution: {integrity: sha512-JbHG2TWuCeNzh87fXo+/46Z1LEo9DBA9T188d0fZgGxAD+cNyS6sx9fdiyxjGPBMyQVRlCutTByZ6a5+YMkF7g==} + '@eslint/compat@1.2.2': + resolution: {integrity: sha512-jhgiIrsw+tRfcBQ4BFl2C3vCrIUw2trCY0cnDvGZpwTtKCEDmZhAtMfrEUP/KpnwM6PrO0T+Ltm+ccW74olG3Q==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^9.10.0 @@ -719,8 +719,8 @@ packages: resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.13.0': - resolution: {integrity: sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==} + '@eslint/js@9.14.0': + resolution: {integrity: sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.4': @@ -735,12 +735,12 @@ packages: resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} - '@humanfs/core@0.19.0': - resolution: {integrity: sha512-2cbWIHbZVEweE853g8jymffCA+NCMiuqeECeBBLm8dg2oFdjuGJhgN4UAbI+6v0CKbbhvtXA4qV8YR5Ji86nmw==} + '@humanfs/core@0.19.1': + resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} - '@humanfs/node@0.16.5': - resolution: {integrity: sha512-KSPA4umqSG4LHYRodq31VDwKAvaTF4xmVlzM8Aeh4PlU1JQ3IG0wiA8C25d3RQ9nJyM3mBHyI53K06VVL/oFFg==} + '@humanfs/node@0.16.6': + resolution: {integrity: sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==} engines: {node: '>=18.18.0'} '@humanwhocodes/module-importer@1.0.1': @@ -751,6 +751,10 @@ packages: resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==} engines: {node: '>=18.18'} + '@humanwhocodes/retry@0.4.0': + resolution: {integrity: sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==} + engines: {node: '>=18.18'} + '@hutson/parse-repository-url@3.0.2': resolution: {integrity: sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==} engines: {node: '>=6.9.0'} @@ -960,8 +964,8 @@ packages: '@shikijs/vscode-textmate@9.3.0': resolution: {integrity: sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==} - '@stylistic/eslint-plugin@2.9.0': - resolution: {integrity: sha512-OrDyFAYjBT61122MIY1a3SfEgy3YCMgt2vL4eoPmvTwDBwyQhAXurxNQznlRD/jESNfYWfID8Ej+31LljvF7Xg==} + '@stylistic/eslint-plugin@2.10.1': + resolution: {integrity: sha512-U+4yzNXElTf9q0kEfnloI9XbOyD4cnEQCxjUI94q0+W++0GAEQvJ/slwEj9lwjDHfGADRSr+Tco/z0XJvmDfCQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: '>=8.40.0' @@ -1029,8 +1033,8 @@ packages: '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} - '@typescript-eslint/eslint-plugin@8.11.0': - resolution: {integrity: sha512-KhGn2LjW1PJT2A/GfDpiyOfS4a8xHQv2myUagTM5+zsormOmBlYsnQ6pobJ8XxJmh6hnHwa2Mbe3fPrDJoDhbA==} + '@typescript-eslint/eslint-plugin@8.12.2': + resolution: {integrity: sha512-gQxbxM8mcxBwaEmWdtLCIGLfixBMHhQjBqR8sVWNTPpcj45WlYL2IObS/DNMLH1DBP0n8qz+aiiLTGfopPEebw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 @@ -1040,8 +1044,8 @@ packages: typescript: optional: true - '@typescript-eslint/parser@8.11.0': - resolution: {integrity: sha512-lmt73NeHdy1Q/2ul295Qy3uninSqi6wQI18XwSpm8w0ZbQXUpjCAWP1Vlv/obudoBiIjJVjlztjQ+d/Md98Yxg==} + '@typescript-eslint/parser@8.12.2': + resolution: {integrity: sha512-MrvlXNfGPLH3Z+r7Tk+Z5moZAc0dzdVjTgUgwsdGweH7lydysQsnSww3nAmsq8blFuRD5VRlAr9YdEFw3e6PBw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -1050,12 +1054,12 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@8.11.0': - resolution: {integrity: sha512-Uholz7tWhXmA4r6epo+vaeV7yjdKy5QFCERMjs1kMVsLRKIrSdM6o21W2He9ftp5PP6aWOVpD5zvrvuHZC0bMQ==} + '@typescript-eslint/scope-manager@8.12.2': + resolution: {integrity: sha512-gPLpLtrj9aMHOvxJkSbDBmbRuYdtiEbnvO25bCMza3DhMjTQw0u7Y1M+YR5JPbMsXXnSPuCf5hfq0nEkQDL/JQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.11.0': - resolution: {integrity: sha512-ItiMfJS6pQU0NIKAaybBKkuVzo6IdnAhPFZA/2Mba/uBjuPQPet/8+zh5GtLHwmuFRShZx+8lhIs7/QeDHflOg==} + '@typescript-eslint/type-utils@8.12.2': + resolution: {integrity: sha512-bwuU4TAogPI+1q/IJSKuD4shBLc/d2vGcRT588q+jzayQyjVK2X6v/fbR4InY2U2sgf8MEvVCqEWUzYzgBNcGQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1063,12 +1067,12 @@ packages: typescript: optional: true - '@typescript-eslint/types@8.11.0': - resolution: {integrity: sha512-tn6sNMHf6EBAYMvmPUaKaVeYvhUsrE6x+bXQTxjQRp360h1giATU0WvgeEys1spbvb5R+VpNOZ+XJmjD8wOUHw==} + '@typescript-eslint/types@8.12.2': + resolution: {integrity: sha512-VwDwMF1SZ7wPBUZwmMdnDJ6sIFk4K4s+ALKLP6aIQsISkPv8jhiw65sAK6SuWODN/ix+m+HgbYDkH+zLjrzvOA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.11.0': - resolution: {integrity: sha512-yHC3s1z1RCHoCz5t06gf7jH24rr3vns08XXhfEqzYpd6Hll3z/3g23JRi0jM8A47UFKNc3u/y5KIMx8Ynbjohg==} + '@typescript-eslint/typescript-estree@8.12.2': + resolution: {integrity: sha512-mME5MDwGe30Pq9zKPvyduyU86PH7aixwqYR2grTglAdB+AN8xXQ1vFGpYaUSJ5o5P/5znsSBeNcs5g5/2aQwow==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1076,14 +1080,14 @@ packages: typescript: optional: true - '@typescript-eslint/utils@8.11.0': - resolution: {integrity: sha512-CYiX6WZcbXNJV7UNB4PLDIBtSdRmRI/nb0FMyqHPTQD1rMjA0foPLaPUV39C/MxkTd/QKSeX+Gb34PPsDVC35g==} + '@typescript-eslint/utils@8.12.2': + resolution: {integrity: sha512-UTTuDIX3fkfAz6iSVa5rTuSfWIYZ6ATtEocQ/umkRSyC9O919lbZ8dcH7mysshrCdrAM03skJOEYaBugxN+M6A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/visitor-keys@8.11.0': - resolution: {integrity: sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==} + '@typescript-eslint/visitor-keys@8.12.2': + resolution: {integrity: sha512-PChz8UaKQAVNHghsHcPyx1OMHoFRUEA7rJSK/mDhdq85bk+PLsUHUBqTQTFt18VJZbmxBovM65fezlheQRsSDA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@ungap/structured-clone@1.2.0': @@ -1913,8 +1917,8 @@ packages: peerDependencies: eslint: '>=8.56.0' - eslint-scope@8.1.0: - resolution: {integrity: sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw==} + eslint-scope@8.2.0: + resolution: {integrity: sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} eslint-visitor-keys@3.4.3: @@ -1925,8 +1929,12 @@ packages: resolution: {integrity: sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.13.0: - resolution: {integrity: sha512-EYZK6SX6zjFHST/HRytOdA/zE72Cq/bfw45LSyuwrdvcclb/gqV8RRQxywOBEWO2+WDpva6UZa4CcDeJKzUCFA==} + eslint-visitor-keys@4.2.0: + resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + eslint@9.14.0: + resolution: {integrity: sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -1939,6 +1947,10 @@ packages: resolution: {integrity: sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + espree@10.3.0: + resolution: {integrity: sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + esquery@1.6.0: resolution: {integrity: sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==} engines: {node: '>=0.10'} @@ -3452,8 +3464,8 @@ packages: typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typescript-eslint@8.11.0: - resolution: {integrity: sha512-cBRGnW3FSlxaYwU8KfAewxFK5uzeOAp0l2KebIlPDOT5olVi65KDG/yjBooPBG0kGW/HLkoz1c/iuBFehcS3IA==} + typescript-eslint@8.12.2: + resolution: {integrity: sha512-UbuVUWSrHVR03q9CWx+JDHeO6B/Hr9p4U5lRH++5tq/EbFq1faYZe50ZSBePptgfIKLEti0aPQ3hFgnPVcd8ZQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -4187,16 +4199,16 @@ snapshots: '@esbuild/win32-x64@0.24.0': optional: true - '@eslint-community/eslint-utils@4.4.1(eslint@9.13.0(jiti@2.3.3))': + '@eslint-community/eslint-utils@4.4.1(eslint@9.14.0(jiti@2.3.3))': dependencies: - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} - '@eslint/compat@1.2.1(eslint@9.13.0(jiti@2.3.3))': + '@eslint/compat@1.2.2(eslint@9.14.0(jiti@2.3.3))': optionalDependencies: - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) '@eslint/config-array@0.18.0': dependencies: @@ -4212,7 +4224,7 @@ snapshots: dependencies: ajv: 6.12.6 debug: 4.3.7(supports-color@8.1.1) - espree: 10.2.0 + espree: 10.3.0 globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.0 @@ -4222,7 +4234,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@9.13.0': {} + '@eslint/js@9.14.0': {} '@eslint/object-schema@2.1.4': {} @@ -4232,17 +4244,19 @@ snapshots: '@fastify/busboy@2.1.1': {} - '@humanfs/core@0.19.0': {} + '@humanfs/core@0.19.1': {} - '@humanfs/node@0.16.5': + '@humanfs/node@0.16.6': dependencies: - '@humanfs/core': 0.19.0 + '@humanfs/core': 0.19.1 '@humanwhocodes/retry': 0.3.1 '@humanwhocodes/module-importer@1.0.1': {} '@humanwhocodes/retry@0.3.1': {} + '@humanwhocodes/retry@0.4.0': {} + '@hutson/parse-repository-url@3.0.2': {} '@isaacs/cliui@8.0.2': @@ -4435,12 +4449,12 @@ snapshots: '@shikijs/vscode-textmate@9.3.0': {} - '@stylistic/eslint-plugin@2.9.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)': + '@stylistic/eslint-plugin@2.10.1(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)': dependencies: - '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - eslint: 9.13.0(jiti@2.3.3) - eslint-visitor-keys: 4.1.0 - espree: 10.2.0 + '@typescript-eslint/utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + eslint: 9.14.0(jiti@2.3.3) + eslint-visitor-keys: 4.2.0 + espree: 10.3.0 estraverse: 5.3.0 picomatch: 4.0.2 transitivePeerDependencies: @@ -4512,15 +4526,15 @@ snapshots: '@types/node': 22.8.6 optional: true - '@typescript-eslint/eslint-plugin@8.11.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.12.2(@typescript-eslint/parser@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - '@typescript-eslint/scope-manager': 8.11.0 - '@typescript-eslint/type-utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.11.0 - eslint: 9.13.0(jiti@2.3.3) + '@typescript-eslint/parser': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.12.2 + '@typescript-eslint/type-utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.12.2 + eslint: 9.14.0(jiti@2.3.3) graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -4530,28 +4544,28 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)': + '@typescript-eslint/parser@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)': dependencies: - '@typescript-eslint/scope-manager': 8.11.0 - '@typescript-eslint/types': 8.11.0 - '@typescript-eslint/typescript-estree': 8.11.0(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.11.0 + '@typescript-eslint/scope-manager': 8.12.2 + '@typescript-eslint/types': 8.12.2 + '@typescript-eslint/typescript-estree': 8.12.2(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.12.2 debug: 4.3.7(supports-color@8.1.1) - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.11.0': + '@typescript-eslint/scope-manager@8.12.2': dependencies: - '@typescript-eslint/types': 8.11.0 - '@typescript-eslint/visitor-keys': 8.11.0 + '@typescript-eslint/types': 8.12.2 + '@typescript-eslint/visitor-keys': 8.12.2 - '@typescript-eslint/type-utils@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.11.0(typescript@5.6.3) - '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.12.2(typescript@5.6.3) + '@typescript-eslint/utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) debug: 4.3.7(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.6.3) optionalDependencies: @@ -4560,12 +4574,12 @@ snapshots: - eslint - supports-color - '@typescript-eslint/types@8.11.0': {} + '@typescript-eslint/types@8.12.2': {} - '@typescript-eslint/typescript-estree@8.11.0(typescript@5.6.3)': + '@typescript-eslint/typescript-estree@8.12.2(typescript@5.6.3)': dependencies: - '@typescript-eslint/types': 8.11.0 - '@typescript-eslint/visitor-keys': 8.11.0 + '@typescript-eslint/types': 8.12.2 + '@typescript-eslint/visitor-keys': 8.12.2 debug: 4.3.7(supports-color@8.1.1) fast-glob: 3.3.2 is-glob: 4.0.3 @@ -4577,20 +4591,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)': + '@typescript-eslint/utils@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)': dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.13.0(jiti@2.3.3)) - '@typescript-eslint/scope-manager': 8.11.0 - '@typescript-eslint/types': 8.11.0 - '@typescript-eslint/typescript-estree': 8.11.0(typescript@5.6.3) - eslint: 9.13.0(jiti@2.3.3) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.14.0(jiti@2.3.3)) + '@typescript-eslint/scope-manager': 8.12.2 + '@typescript-eslint/types': 8.12.2 + '@typescript-eslint/typescript-estree': 8.12.2(typescript@5.6.3) + eslint: 9.14.0(jiti@2.3.3) transitivePeerDependencies: - supports-color - typescript - '@typescript-eslint/visitor-keys@8.11.0': + '@typescript-eslint/visitor-keys@8.12.2': dependencies: - '@typescript-eslint/types': 8.11.0 + '@typescript-eslint/types': 8.12.2 eslint-visitor-keys: 3.4.3 '@ungap/structured-clone@1.2.0': {} @@ -4618,10 +4632,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitest/eslint-plugin@1.1.7(@typescript-eslint/utils@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3)(vitest@2.1.4)': + '@vitest/eslint-plugin@1.1.7(@typescript-eslint/utils@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3)(vitest@2.1.4)': dependencies: - '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - eslint: 9.13.0(jiti@2.3.3) + '@typescript-eslint/utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + eslint: 9.14.0(jiti@2.3.3) optionalDependencies: typescript: 5.6.3 vitest: 2.1.4(@types/node@22.8.6)(@vitest/ui@2.1.4)(jsdom@25.0.1) @@ -5528,18 +5542,18 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-prettier@9.1.0(eslint@9.13.0(jiti@2.3.3)): + eslint-config-prettier@9.1.0(eslint@9.14.0(jiti@2.3.3)): dependencies: - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) - eslint-plugin-jsdoc@50.4.3(eslint@9.13.0(jiti@2.3.3)): + eslint-plugin-jsdoc@50.4.3(eslint@9.14.0(jiti@2.3.3)): dependencies: '@es-joy/jsdoccomment': 0.49.0 are-docs-informative: 0.0.2 comment-parser: 1.4.1 debug: 4.3.7(supports-color@8.1.1) escape-string-regexp: 4.0.0 - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) espree: 10.2.0 esquery: 1.6.0 parse-imports: 2.2.1 @@ -5549,24 +5563,24 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-prettier@5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.13.0(jiti@2.3.3)))(eslint@9.13.0(jiti@2.3.3))(prettier@3.3.3): + eslint-plugin-prettier@5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.14.0(jiti@2.3.3)))(eslint@9.14.0(jiti@2.3.3))(prettier@3.3.3): dependencies: - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) prettier: 3.3.3 prettier-linter-helpers: 1.0.0 synckit: 0.9.2 optionalDependencies: '@types/eslint': 9.6.1 - eslint-config-prettier: 9.1.0(eslint@9.13.0(jiti@2.3.3)) + eslint-config-prettier: 9.1.0(eslint@9.14.0(jiti@2.3.3)) - eslint-plugin-unicorn@56.0.0(eslint@9.13.0(jiti@2.3.3)): + eslint-plugin-unicorn@56.0.0(eslint@9.14.0(jiti@2.3.3)): dependencies: '@babel/helper-validator-identifier': 7.25.9 - '@eslint-community/eslint-utils': 4.4.1(eslint@9.13.0(jiti@2.3.3)) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.14.0(jiti@2.3.3)) ci-info: 4.0.0 clean-regexp: 1.0.0 core-js-compat: 3.38.1 - eslint: 9.13.0(jiti@2.3.3) + eslint: 9.14.0(jiti@2.3.3) esquery: 1.6.0 globals: 15.11.0 indent-string: 4.0.0 @@ -5579,7 +5593,7 @@ snapshots: semver: 7.6.3 strip-indent: 3.0.0 - eslint-scope@8.1.0: + eslint-scope@8.2.0: dependencies: esrecurse: 4.3.0 estraverse: 5.3.0 @@ -5588,18 +5602,20 @@ snapshots: eslint-visitor-keys@4.1.0: {} - eslint@9.13.0(jiti@2.3.3): + eslint-visitor-keys@4.2.0: {} + + eslint@9.14.0(jiti@2.3.3): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.13.0(jiti@2.3.3)) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.14.0(jiti@2.3.3)) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.18.0 '@eslint/core': 0.7.0 '@eslint/eslintrc': 3.1.0 - '@eslint/js': 9.13.0 + '@eslint/js': 9.14.0 '@eslint/plugin-kit': 0.2.1 - '@humanfs/node': 0.16.5 + '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 - '@humanwhocodes/retry': 0.3.1 + '@humanwhocodes/retry': 0.4.0 '@types/estree': 1.0.6 '@types/json-schema': 7.0.15 ajv: 6.12.6 @@ -5607,9 +5623,9 @@ snapshots: cross-spawn: 7.0.3 debug: 4.3.7(supports-color@8.1.1) escape-string-regexp: 4.0.0 - eslint-scope: 8.1.0 - eslint-visitor-keys: 4.1.0 - espree: 10.2.0 + eslint-scope: 8.2.0 + eslint-visitor-keys: 4.2.0 + espree: 10.3.0 esquery: 1.6.0 esutils: 2.0.3 fast-deep-equal: 3.1.3 @@ -5636,6 +5652,12 @@ snapshots: acorn-jsx: 5.3.2(acorn@8.14.0) eslint-visitor-keys: 4.1.0 + espree@10.3.0: + dependencies: + acorn: 8.14.0 + acorn-jsx: 5.3.2(acorn@8.14.0) + eslint-visitor-keys: 4.2.0 + esquery@1.6.0: dependencies: estraverse: 5.3.0 @@ -7128,11 +7150,11 @@ snapshots: typedarray@0.0.6: {} - typescript-eslint@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3): + typescript-eslint@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.11.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) - '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/eslint-plugin': 8.12.2(@typescript-eslint/parser@8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3))(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/parser': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) + '@typescript-eslint/utils': 8.12.2(eslint@9.14.0(jiti@2.3.3))(typescript@5.6.3) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: From cb976821fbfe5cde675b835e40d37ace37647bd3 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 3 Nov 2024 09:01:39 +0100 Subject: [PATCH 4/8] docs: add required twitter meta tags (#3232) --- docs/.vitepress/config.ts | 56 ++++++++------------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 2cb9301428b..746803ad594 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -109,53 +109,19 @@ const config: UserConfig = { head: [ ['link', { rel: 'icon', href: '/logo.svg' }], ['meta', { name: 'theme-color', content: '#40af7c' }], - [ - 'meta', - { - name: 'og:description', - content: description, - }, - ], - [ - 'meta', - { - name: 'twitter:description', - content: description, - }, - ], - [ - 'meta', - { - name: 'og:image', - content: image, - }, - ], - [ - 'meta', - { - name: 'twitter:image', - content: image, - }, - ], - [ - 'meta', - { - name: 'twitter:card', - content: 'summary_large_image', - }, - ], - [ - 'link', - { - rel: 'me', - href: 'https://fosstodon.org/@faker_js', - }, - ], + ['meta', { name: 'og:title', content: 'FakerJS' }], + ['meta', { name: 'og:description', content: description }], + ['meta', { name: 'og:image', content: image }], + ['meta', { name: 'twitter:card', content: 'summary_large_image' }], + ['meta', { name: 'twitter:title', content: 'FakerJS' }], + ['meta', { name: 'twitter:description', content: description }], + ['meta', { name: 'twitter:site', content: '@faker_js' }], + ['meta', { name: 'twitter:image', content: image }], + ['meta', { name: 'twitter:image:alt', content: 'The FakerJS logo' }], + ['link', { rel: 'me', href: 'https://fosstodon.org/@faker_js' }], [ 'script', - { - id: 'browser-console-faker', - }, + { id: 'browser-console-faker' }, ` const logStyle = 'background: rgba(16, 183, 127, 0.14); color: rgba(255, 255, 245, 0.86); padding: 0.5rem; display: inline-block;'; console.log(\`%cIf you would like to test Faker in the browser console, you can do so using 'await enableFaker()'. From c0a7e2381e1baf0ad480d8bd4442d7acd5f5b3d6 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 3 Nov 2024 09:08:44 +0100 Subject: [PATCH 5/8] docs: expose documentation for randomizers (#3221) --- scripts/apidocs/processing/class.ts | 7 ++++++- src/utils/mersenne.ts | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/apidocs/processing/class.ts b/scripts/apidocs/processing/class.ts index 5af5e87430f..a2c465b8ece 100644 --- a/scripts/apidocs/processing/class.ts +++ b/scripts/apidocs/processing/class.ts @@ -192,7 +192,12 @@ export function processProjectUtilities(project: Project): RawApiDocsPage { deprecated: undefined, description: 'A list of all the utilities available in Faker.js.', examples: [], - methods: processProjectFunctions(project, 'mergeLocales'), + methods: processProjectFunctions( + project, + 'mergeLocales', + 'generateMersenne32Randomizer', + 'generateMersenne53Randomizer' + ), }; } diff --git a/src/utils/mersenne.ts b/src/utils/mersenne.ts index de415f9166e..315335abfcc 100644 --- a/src/utils/mersenne.ts +++ b/src/utils/mersenne.ts @@ -4,6 +4,17 @@ import type { Randomizer } from '../randomizer'; /** * Generates a MersenneTwister19937 randomizer with 32 bits of precision. * This is the default randomizer used by faker prior to v9.0. + * + * @example + * import { de, en, generateMersenne32Randomizer, Faker } from '@faker-js/faker'; + * + * const randomizer = generateMersenne32Randomizer(); + * randomizer.seed(42); + * // Share the same randomizer between multiple instances + * const customFaker1 = new Faker({ locale: de, randomizer }); + * const customFaker2 = new Faker({ locale: en, randomizer }); + * + * @since 8.2.0 */ export function generateMersenne32Randomizer(): Randomizer { const twister = new MersenneTwister19937(); @@ -27,6 +38,17 @@ export function generateMersenne32Randomizer(): Randomizer { /** * Generates a MersenneTwister19937 randomizer with 53 bits of precision. * This is the default randomizer used by faker starting with v9.0. + * + * @example + * import { de, en, generateMersenne53Randomizer, Faker } from '@faker-js/faker'; + * + * const randomizer = generateMersenne53Randomizer(); + * randomizer.seed(42); + * // Share the same randomizer between multiple instances + * const customFaker1 = new Faker({ locale: de, randomizer }); + * const customFaker2 = new Faker({ locale: en, randomizer }); + * + * @since 9.0.0 */ export function generateMersenne53Randomizer(): Randomizer { const twister = new MersenneTwister19937(); From 18f14c8eb362e2d08d17a3746962c991f1d2815c Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 3 Nov 2024 11:41:19 +0100 Subject: [PATCH 6/8] docs(string): improve documentation for length parameters (#3216) --- src/modules/string/index.ts | 79 +++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts index 67073242134..ac41238c47e 100644 --- a/src/modules/string/index.ts +++ b/src/modules/string/index.ts @@ -103,7 +103,7 @@ export class StringModule extends SimpleModuleBase { * * @param characters The characters to use for the string. Can be a string or an array of characters. * If it is an array, then each element is treated as a single character even if it is a string with multiple characters. - * @param length The length of the string to generate. Defaults to `1`. + * @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`. * @param length.min The minimum length of the string to generate. * @param length.max The maximum length of the string to generate. * @@ -155,8 +155,8 @@ export class StringModule extends SimpleModuleBase { /** * Generating a string consisting of letters in the English alphabet. * - * @param options Either the number of characters or an options instance. - * @param options.length The number or range of characters to generate. Defaults to `1`. + * @param options Either the length of the string to generate or the optional options object. + * @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.casing The casing of the characters. Defaults to `'mixed'`. * @param options.exclude An array with characters which should be excluded in the generated string. Defaults to `[]`. * @@ -175,7 +175,7 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The number or range of characters to generate. + * The length of the string to generate either as a fixed length or as a length range. * * @default 1 */ @@ -183,11 +183,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters to generate. + * The minimum length of the string to generate. */ min: number; /** - * The maximum number of characters to generate. + * The maximum length of the string to generate. */ max: number; }; @@ -249,8 +249,8 @@ export class StringModule extends SimpleModuleBase { /** * Generating a string consisting of alpha characters and digits. * - * @param options Either the number of characters or an options instance. - * @param options.length The number or range of characters and digits to generate. Defaults to `1`. + * @param options Either the length of the string to generate or the optional options object. + * @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.casing The casing of the characters. Defaults to `'mixed'`. * @param options.exclude An array of characters and digits which should be excluded in the generated string. Defaults to `[]`. * @@ -269,7 +269,7 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The number or range of characters and digits to generate. + * The length of the string to generate either as a fixed length or as a length range. * * @default 1 */ @@ -277,11 +277,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters and digits to generate. + * The minimum length of the string to generate. */ min: number; /** - * The maximum number of characters and digits to generate. + * The maximum length of the string to generate. */ max: number; }; @@ -345,7 +345,7 @@ export class StringModule extends SimpleModuleBase { * Returns a [binary](https://en.wikipedia.org/wiki/Binary_number) string. * * @param options The optional options object. - * @param options.length The number or range of characters to generate after the prefix. Defaults to `1`. + * @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.prefix Prefix for the generated number. Defaults to `'0b'`. * * @see faker.number.binary(): For generating a binary number (within a range). @@ -362,7 +362,7 @@ export class StringModule extends SimpleModuleBase { binary( options: { /** - * The number or range of characters to generate after the prefix. + * The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. * * @default 1 */ @@ -370,11 +370,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters to generate. + * The minimum length of the string (excluding the prefix) to generate. */ min: number; /** - * The maximum number of characters to generate. + * The maximum length of the string (excluding the prefix) to generate. */ max: number; }; @@ -397,7 +397,7 @@ export class StringModule extends SimpleModuleBase { * Returns an [octal](https://en.wikipedia.org/wiki/Octal) string. * * @param options The optional options object. - * @param options.length The number or range of characters to generate after the prefix. Defaults to `1`. + * @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.prefix Prefix for the generated number. Defaults to `'0o'`. * * @see faker.number.octal(): For generating an octal number (within a range). @@ -414,7 +414,7 @@ export class StringModule extends SimpleModuleBase { octal( options: { /** - * The number or range of characters to generate after the prefix. + * The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. * * @default 1 */ @@ -422,11 +422,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters to generate. + * The minimum length of the string (excluding the prefix) to generate. */ min: number; /** - * The maximum number of characters to generate. + * The maximum length of the string (excluding the prefix) to generate. */ max: number; }; @@ -452,7 +452,7 @@ export class StringModule extends SimpleModuleBase { * Returns a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) string. * * @param options The optional options object. - * @param options.length The number or range of characters to generate after the prefix. Defaults to `1`. + * @param options.length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.casing Casing of the generated number. Defaults to `'mixed'`. * @param options.prefix Prefix for the generated number. Defaults to `'0x'`. * @@ -472,7 +472,7 @@ export class StringModule extends SimpleModuleBase { hexadecimal( options: { /** - * The number or range of characters to generate after the prefix. + * The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. * * @default 1 */ @@ -480,11 +480,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters to generate after the prefix. + * The minimum length of the string (excluding the prefix) to generate. */ min: number; /** - * The maximum number of characters to generate after the prefix. + * The maximum length of the string (excluding the prefix) to generate. */ max: number; }; @@ -548,8 +548,8 @@ export class StringModule extends SimpleModuleBase { /** * Generates a given length string of digits. * - * @param options Either the number of characters or the options to use. - * @param options.length The number or range of digits to generate. Defaults to `1`. + * @param options Either the length of the string to generate or the optional options object. + * @param options.length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`. * @param options.allowLeadingZeros Whether leading zeros are allowed or not. Defaults to `true`. * @param options.exclude An array of digits which should be excluded in the generated string. Defaults to `[]`. * @@ -570,7 +570,7 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The number or range of digits to generate. + * The length of the string to generate either as a fixed length or as a length range. * * @default 1 */ @@ -578,11 +578,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of digits to generate. + * The minimum length of the string to generate. */ min: number; /** - * The maximum number of digits to generate. + * The maximum length of the string to generate. */ max: number; }; @@ -649,9 +649,9 @@ export class StringModule extends SimpleModuleBase { /** * Returns a string containing UTF-16 chars between 33 and 125 (`!` to `}`). * - * @param length Length of the generated string. Defaults to `10`. - * @param length.min The minimum number of characters to generate. - * @param length.max The maximum number of characters to generate. + * @param length The length of the string (excluding the prefix) to generate either as a fixed length or as a length range. Defaults to `10`. + * @param length.min The minimum length of the string to generate. + * @param length.max The maximum length of the string to generate. * * @example * faker.string.sample() // 'Zo!.:*e>wR' @@ -665,11 +665,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of characters to generate. + * The minimum length of the string to generate. */ min: number; /** - * The maximum number of characters to generate. + * The maximum length of the string to generate. */ max: number; } = 10 @@ -740,7 +740,7 @@ export class StringModule extends SimpleModuleBase { /** * Generates a [Nano ID](https://github.com/ai/nanoid). * - * @param length Length of the generated string. Defaults to `21`. + * @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `21`. * @param length.min The minimum length of the Nano ID to generate. * @param length.max The maximum length of the Nano ID to generate. * @@ -794,13 +794,14 @@ export class StringModule extends SimpleModuleBase { /** * Returns a string containing only special characters from the following list: + * * ```txt * ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ * ``` * - * @param length Length of the generated string. Defaults to `1`. - * @param length.min The minimum number of special characters to generate. - * @param length.max The maximum number of special characters to generate. + * @param length The length of the string to generate either as a fixed length or as a length range. Defaults to `1`. + * @param length.min The minimum length of the string to generate. + * @param length.max The maximum length of the string to generate. * * @example * faker.string.symbol() // '$' @@ -814,11 +815,11 @@ export class StringModule extends SimpleModuleBase { | number | { /** - * The minimum number of special characters to generate. + * The minimum length of the string to generate. */ min: number; /** - * The maximum number of special characters to generate. + * The maximum length of the string to generate. */ max: number; } = 1 From 2d34798d309473f23bdab1698ae9abf6b653d4b8 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 3 Nov 2024 11:48:13 +0100 Subject: [PATCH 7/8] infra(unicorn): permanently disable no-object-as-default-parameter (#3203) --- eslint.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.ts b/eslint.config.ts index 6ec1f0db74d..1d729fe1f2c 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -147,6 +147,7 @@ const config: ReturnType = tseslint.config( 'unicorn/import-style': 'off', // subjective & doesn't do anything for us 'unicorn/no-array-callback-reference': 'off', // reduces readability 'unicorn/no-nested-ternary': 'off', // incompatible with prettier + 'unicorn/no-object-as-default-parameter': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2199 'unicorn/no-null': 'off', // incompatible with TypeScript 'unicorn/no-zero-fractions': 'off', // deactivated to raise awareness of floating operations 'unicorn/number-literal-case': 'off', // incompatible with prettier @@ -157,7 +158,6 @@ const config: ReturnType = tseslint.config( // TODO @Shinigami92 2023-09-23: The following rules currently conflict with our code. // Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. 'unicorn/consistent-function-scoping': 'off', - 'unicorn/no-object-as-default-parameter': 'off', 'unicorn/prefer-export-from': 'off', 'unicorn/prefer-string-slice': 'off', 'unicorn/prevent-abbreviations': 'off', From d31579b2593de48ea01015ad1cd2c46207a67a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FakerJS=20=F0=9F=A4=96?= Date: Sun, 3 Nov 2024 21:40:37 +0100 Subject: [PATCH 8/8] chore(release): 9.2.0 (#3243) Co-authored-by: ST-DDT --- CHANGELOG.md | 13 +++++++++++++ docs/guide/usage.md | 2 +- package.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1337c125f7..542c2135216 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [9.2.0](https://github.com/faker-js/faker/compare/v9.1.0...v9.2.0) (2024-11-03) + + +### Features + +* **animal:** add petName method ([#3196](https://github.com/faker-js/faker/issues/3196)) ([c02beea](https://github.com/faker-js/faker/commit/c02beeadd49e48656a0307451517e9751e3118c3)) +* **number:** add romanNumeral method ([#3070](https://github.com/faker-js/faker/issues/3070)) ([72937de](https://github.com/faker-js/faker/commit/72937de55c892c011846bc2b67dc0df61fbdf5a2)) + + +### Changed Locales + +* **locale:** improve Spanish color names ([#3230](https://github.com/faker-js/faker/issues/3230)) ([99d81be](https://github.com/faker-js/faker/commit/99d81bed28b36ab525340e32a7349799cbe88eca)) + ## [9.1.0](https://github.com/faker-js/faker/compare/v9.0.3...v9.1.0) (2024-10-26) diff --git a/docs/guide/usage.md b/docs/guide/usage.md index fe18b753de8..dff2f2ff1a6 100644 --- a/docs/guide/usage.md +++ b/docs/guide/usage.md @@ -79,7 +79,7 @@ const randomEmail = faker.internet.email(); // Tomasa_Ferry14@hotmail.com ``` ::: info Note -It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://esm.sh/@faker-js/faker@v9.1.0"`. +It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://esm.sh/@faker-js/faker@v9.2.0"`. ::: ### Alternative CDN links diff --git a/package.json b/package.json index 67f99c80e0c..27f792044af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@faker-js/faker", - "version": "9.1.0", + "version": "9.2.0", "description": "Generate massive amounts of fake contextual data", "scripts": { "clean": "rimraf coverage .eslintcache dist docs/.vitepress/cache docs/.vitepress/dist node_modules",