Skip to content

Commit

Permalink
Merge branch 'next' into drop-node-v14-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored May 9, 2023
2 parents 64d123b + aab69c9 commit 861cdc4
Show file tree
Hide file tree
Showing 21 changed files with 527 additions and 406 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ module.exports = defineConfig({
rules: {
// We may want to use this in the future
'no-useless-escape': 'off',
'deprecation/deprecation': 'error',
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-else-return': 'error',
'prefer-template': 'error',

'deprecation/deprecation': 'error',

'@typescript-eslint/array-type': [
'error',
{ default: 'array-simple', readonly: 'generic' },
Expand Down Expand Up @@ -112,8 +114,10 @@ module.exports = defineConfig({
},
{
files: ['test/*.spec.ts'],
extends: ['plugin:vitest/recommended'],
rules: {
'deprecation/deprecation': 'off',

'@typescript-eslint/restrict-template-expressions': [
'error',
{
Expand All @@ -122,6 +126,9 @@ module.exports = defineConfig({
allowAny: true,
},
],

'vitest/expect-expect': 'off',
'vitest/valid-expect': ['error', { maxArgs: 2 }],
},
},
],
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [8.0.0-beta.1](https://github.com/faker-js/faker/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2023-05-06)


### Features

* **helpers:** new method `objectEntry` ([#2123](https://github.com/faker-js/faker/issues/2123)) ([c092aa1](https://github.com/faker-js/faker/commit/c092aa1276a5c249de1ada47e807f12dd6de36f7))


### Bug Fixes

* **locale:** el county should be city_name ([#2106](https://github.com/faker-js/faker/issues/2106)) ([1cadfb9](https://github.com/faker-js/faker/commit/1cadfb97856da17047fcb5dcb504c3418eeed145))
* **locale:** remove incorrect and unused city_prefix/suffix for sk ([#2117](https://github.com/faker-js/faker/issues/2117)) ([e094a5a](https://github.com/faker-js/faker/commit/e094a5a7b00bed7da3610bdbb949cc00320d5094))
* **locale:** remove unrealistic fictional patterns in ne, ro, tr ([#2120](https://github.com/faker-js/faker/issues/2120)) ([d9ec87e](https://github.com/faker-js/faker/commit/d9ec87e6697ac3c814932c7e3ff6fa2e21d62f3a))
* **locale:** rename city_prefix to city_name for en_NG, en_ZA, en_AU_ocker ([#2111](https://github.com/faker-js/faker/issues/2111)) ([a0fb69d](https://github.com/faker-js/faker/commit/a0fb69d666c85c40b1f8620dbfa0516e9872397f))
* **location:** no leading zero on building number or secondary address ([#2032](https://github.com/faker-js/faker/issues/2032)) ([a8dc7e0](https://github.com/faker-js/faker/commit/a8dc7e07f6d5ee2ae38724ba5d503d7b88bd7147))
* **test:** fix failing latitude test ([#2116](https://github.com/faker-js/faker/issues/2116)) ([7f9e9df](https://github.com/faker-js/faker/commit/7f9e9df4221d27b0b41a8ca04ea2cf69e7065613))


### Changed Locales

* **locale:** add city_name to city_patterns ([#2104](https://github.com/faker-js/faker/issues/2104)) ([b72d52e](https://github.com/faker-js/faker/commit/b72d52e5d5501579f6b98629d020292ceaa78c60))


### New Locales

* **locale:** add ro_MD locale ([#2084](https://github.com/faker-js/faker/issues/2084)) ([08cf1d8](https://github.com/faker-js/faker/commit/08cf1d85c8ba29991e47dc4b764172abb2cc0705))

## [8.0.0-beta.0](https://github.com/faker-js/faker/compare/v8.0.0-alpha.2...v8.0.0-beta.0) (2023-04-29)


Expand Down
16 changes: 8 additions & 8 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ You can run Faker in the Browser, within Node, or the many other languages suppo

Install it as a Dev Dependency using your favorite package manager.

```shell
::: code-group

```shell [npm]
npm install @faker-js/faker --save-dev
```

or
```shell [pnpm]
pnpm add @faker-js/faker --save-dev
```

```shell
```shell [yarn]
yarn add @faker-js/faker --dev
```

or

```shell
pnpm add @faker-js/faker --save-dev
```
:::

## Community

Expand Down
4 changes: 3 additions & 1 deletion docs/guide/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { faker } from '@faker-js/faker/locale/de';

This will then just load the German locales with additional English locales as fallback. The fallback is required due to not all locales containing data for all features. If you encounter a missing locale entry in your selected language, feel free to open a Pull Request fixing that issue.

::: info
::: info Info
The English locales are around 600 KB in size.
All locales together are around 5 MB in size.
:::
Expand Down Expand Up @@ -159,6 +159,7 @@ The recommended way to access Faker instances is by using one of the individual

```ts
import { allFakers, allLocales } from '@faker-js/faker';

console.dir(allFakers['de_AT']); // the prebuilt Faker instance for de_AT
console.dir(allLocales['de_AT']); // the raw locale definitions for de_AT
```
Expand All @@ -167,6 +168,7 @@ This could be useful if you want to enumerate all locales, for example:

```ts
import { allFakers } from '@faker-js/faker';

for (let key of Object.keys(allFakers)) {
try {
console.log(
Expand Down
58 changes: 28 additions & 30 deletions docs/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This is the migration guide for upgrading from v7 to v8.

Since v8 has not yet been released, this is a work in progress list of any major and breaking changes in v8.

::: info Not the version you are looking for?

- [Upgrading to v7](https://v7.fakerjs.dev/guide/upgrading.html)
Expand All @@ -30,7 +28,7 @@ import { faker } from '@faker-js/faker';
faker.setLocale('de_CH');
// or
faker.locale = 'de_CH';
faker.fallbackLocale = 'en';
faker.localeFallback = 'en';
```

**New**
Expand All @@ -44,11 +42,12 @@ This also fixes issues where more than two locales are required:
**Old**

```ts
import { faker } from '@faker-js/faker';
import { faker, Faker } from '@faker-js/faker';

const { de_CH, de, en } = faker.locales;
const customFaker = new Faker({
locale: 'de_CH', // the expected locale
fallbackLocale: 'de', // ensure we have a German fallbacks for addresses
localeFallback: 'de', // ensure we have a German fallback for addresses
locales: { de_CH, de, en },
});
const a = customFaker.internet.email();
Expand Down Expand Up @@ -99,7 +98,7 @@ For more information refer to our [Localization Guide](localization).

### For missing locale data, Faker will now throw instead of returning `undefined` or `a`-`c`

::: note Note
::: info Note
The following section mostly applies to custom-built Faker instances.
:::

Expand Down Expand Up @@ -185,21 +184,21 @@ try {

### Other deprecated methods removed/replaced

| Old method | New method |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `faker.unique` | `faker.helpers.unique` (:warning: please have a look at [#1785](https://github.com/faker-js/faker/issues/1785)) |
| `faker.fake` | `faker.helpers.fake` |
| `faker.commerce.color` | `faker.color.human` |
| `faker.company.companyName` | `faker.company.name` |
| `faker.phone.phoneNumber` | `faker.phone.number` |
| `faker.phone.phoneNumberFormat` | No direct replacement, see documentation for `faker.phone.number` |
| `faker.phone.phoneFormats` | No direct replacement, see documentation for `faker.phone.number` |
| `faker.name.findName` | _Removed, replace with `faker.person.fullName`_ |
| `faker.address.cityPrefix` | _Removed_ |
| `faker.address.citySuffix` | _Removed_ |
| `faker.address.streetPrefix` | _Removed_ |
| `faker.address.streetSuffix` | _Removed_ |
| `faker.image.lorempixel` | _Removed, as the LoremPixel service is no longer available_ |
| Old method | New method |
| ------------------------------- | ------------------------------------------------------------------------------------------------------ |
| `faker.unique` | `faker.helpers.unique` (:warning: please check [#1785](https://github.com/faker-js/faker/issues/1785)) |
| `faker.fake` | `faker.helpers.fake` |
| `faker.commerce.color` | `faker.color.human` |
| `faker.company.companyName` | `faker.company.name` |
| `faker.phone.phoneNumber` | `faker.phone.number` |
| `faker.phone.phoneNumberFormat` | No direct replacement, see documentation for `faker.phone.number` |
| `faker.phone.phoneFormats` | No direct replacement, see documentation for `faker.phone.number` |
| `faker.name.findName` | _Removed, replace with `faker.person.fullName`_ |
| `faker.address.cityPrefix` | _Removed_ |
| `faker.address.citySuffix` | _Removed_ |
| `faker.address.streetPrefix` | _Removed_ |
| `faker.address.streetSuffix` | _Removed_ |
| `faker.image.lorempixel` | _Removed, as the LoremPixel service is no longer available_ |

### Definitions removed

Expand All @@ -213,6 +212,13 @@ Some data definitions, which were only available via the `faker.helpers.fake` me

## Deprecations and other changes

This is not an exhaustive list of all deprecations in v8.0.0. Many methods and parameters have been renamed in this release. You can:

- use the warnings which are shown at runtime to guide you to the new names
- use a [suitable plugin](https://www.npmjs.com/package/eslint-plugin-deprecation) to find usages of deprecated code
- Review the full list of deprecations [here](https://github.com/faker-js/faker/issues?q=label%3Adeprecation+is%3Amerged+milestone%3A%22v8.0+-+Module+Re-Shuffling%22) and [here](https://github.com/faker-js/faker/issues?q=label%3Adeprecation+is%3Amerged+milestone%3A%22v8+-+None+milestone+specific+tasks%22)
- Ignore the deprecations for now: the old names will continue to work for v8.x.x, however you will need to make changes before upgrading to v9.x.x.

### `faker.name` changed to `faker.person`

The whole `faker.name` module is now located at `faker.person`, as it contains more information than just names.
Expand Down Expand Up @@ -269,14 +275,6 @@ The `faker.address.*` methods will continue to work as an alias in v8 and v9, bu
| `faker.address.streetPrefix` | _Removed_ |
| `faker.address.streetSuffix` | _Removed_ |

### `faker.finance.account` changed to `faker.finance.accountNumber`

The `faker.finance.account` method has been renamed to `faker.finance.accountNumber` to better reflect the data it returns and not to get confused with a user "Account".

### `faker.finance.mask` changed to `faker.finance.maskedNumber`

The `faker.finance.mask` method has been renamed to `faker.finance.maskedNumber` to better reflect its purpose.

### Number methods of `faker.datatype` moved to new `faker.number` module

The number-related methods previously found in `faker.datatype` have been moved to a new `faker.number` module.
Expand Down Expand Up @@ -323,7 +321,7 @@ The functions `faker.system.mimeType`, `faker.system.fileType` and `faker.system
### `faker.helpers.unique` is planned to be outsourced

The `faker.helpers.unique` method is planned to be outsourced to a separate package.
Please have a look at issue [#1785](https://github.com/faker-js/faker/issues/1785) for more details.
Please check issue [#1785](https://github.com/faker-js/faker/issues/1785) for more details.

### Locales renamed

Expand Down
19 changes: 12 additions & 7 deletions docs/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@

Using Faker is as easy as importing it from `@faker-js/faker`.

```js
::: code-group

```js [esm]
import { faker } from '@faker-js/faker';
// or, if desiring a different locale
// import { fakerDE as faker } from '@faker-js/faker'
// import { fakerDE as faker } from '@faker-js/faker';

const randomName = faker.person.fullName(); // Rowan Nikolaus
const randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
```

Or if you're using CommonJS:

```js
```js [cjs]
const { faker } = require('@faker-js/faker');
// or, if desiring a different locale
// const { fakerDE: faker } = require('@faker-js/faker');

const randomName = faker.person.fullName(); // Rowan Nikolaus
const randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
```

:::

For more information about changing and customizing the locales, please refer to our [Localization Guide](localization).

## Browser
Expand Down Expand Up @@ -119,7 +124,7 @@ or alternatively you can set a default reference date for all these methods:

```ts
// affects all future faker.date.* calls
faker.defaultRefDate = '2023-01-01T00:00:00.000Z';
faker.setDefaultRefDate('2023-01-01T00:00:00.000Z');
```

## Create complex objects
Expand Down Expand Up @@ -220,7 +225,7 @@ But, in most use-cases, this would be desirable.

Faker has your back, with another helper method:

```ts {7-9}
```ts {7-10}
import { faker } from '@faker-js/faker';

function createRandomUser(): User {
Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@faker-js/faker",
"version": "8.0.0-beta.0",
"version": "8.0.0-beta.1",
"description": "Generate massive amounts of fake contextual data",
"keywords": [
"faker",
Expand Down Expand Up @@ -96,28 +96,29 @@
"@algolia/client-search": "~4.17.0",
"@types/glob": "~8.1.0",
"@types/markdown-it": "~12.2.3",
"@types/node": "~18.16.3",
"@types/node": "~18.16.5",
"@types/prettier": "~2.7.2",
"@types/react": "~18.2.0",
"@types/react": "~18.2.6",
"@types/sanitize-html": "~2.9.0",
"@types/semver": "~7.3.13",
"@types/validator": "~13.7.15",
"@typescript-eslint/eslint-plugin": "~5.59.1",
"@typescript-eslint/parser": "~5.59.1",
"@vitest/coverage-c8": "~0.30.1",
"@vitest/ui": "~0.30.1",
"@vueuse/core": "~10.1.0",
"@types/validator": "~13.7.16",
"@typescript-eslint/eslint-plugin": "~5.59.2",
"@typescript-eslint/parser": "~5.59.2",
"@vitest/coverage-c8": "~0.31.0",
"@vitest/ui": "~0.31.0",
"@vueuse/core": "~10.1.2",
"c8": "~7.13.0",
"conventional-changelog-cli": "~2.2.2",
"cypress": "~12.11.0",
"esbuild": "~0.17.18",
"eslint": "~8.39.0",
"eslint": "~8.40.0",
"eslint-config-prettier": "~8.8.0",
"eslint-define-config": "~1.20.0",
"eslint-gitignore": "~0.1.0",
"eslint-plugin-deprecation": "~1.4.1",
"eslint-plugin-jsdoc": "~43.1.1",
"eslint-plugin-jsdoc": "~44.0.0",
"eslint-plugin-prettier": "~4.2.1",
"eslint-plugin-vitest": "~0.2.2",
"glob": "~10.2.2",
"npm-run-all": "~4.1.5",
"picocolors": "~1.0.0",
Expand All @@ -130,15 +131,15 @@
"semver": "~7.5.0",
"standard-version": "~9.5.0",
"tsx": "~3.12.7",
"typedoc": "~0.24.6",
"typedoc": "~0.24.7",
"typescript": "~4.9.5",
"validator": "~13.9.0",
"vite": "~4.3.3",
"vite": "~4.3.5",
"vitepress": "1.0.0-alpha.75",
"vitest": "~0.30.1",
"vitest": "~0.31.0",
"vue": "~3.2.47"
},
"packageManager": "pnpm@8.3.1",
"packageManager": "pnpm@8.4.0",
"engines": {
"node": "^16.13.0 || >=18.0.0",
"npm": ">=7.10.0"
Expand Down
Loading

0 comments on commit 861cdc4

Please sign in to comment.