Skip to content

Commit

Permalink
Merge branch 'next' into infra/unicorn/numeric-separators-style
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Jun 2, 2024
2 parents 37e1d1c + a082ed2 commit f3738a5
Show file tree
Hide file tree
Showing 61 changed files with 958 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "FakerJs",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20@sha256:173debabac3a927225aac3fa451dfd1baa780d5fb8f8e513b1efc615e3221225",
"image": "mcr.microsoft.com/devcontainers/typescript-node:22@sha256:52f2401bd5937985be000f34bb33bb3a3a47bd20249d91bc787d8f00eba220e9",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
18 changes: 7 additions & 11 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = defineConfig({
'prefer-exponentiation-operator': 'error',
'prefer-template': 'error',

'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-null': 'off', // incompatible with TypeScript
Expand All @@ -50,7 +51,6 @@ module.exports = defineConfig({
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently.
'unicorn/better-regex': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/import-style': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/prefer-string-slice': 'off',
Expand Down Expand Up @@ -79,6 +79,12 @@ module.exports = defineConfig({
trailingUnderscore: 'forbid',
},
],
'@typescript-eslint/no-confusing-void-expression': [
'error',
{
ignoreArrowShorthand: true,
},
],
'@typescript-eslint/no-inferrable-types': [
'error',
{ ignoreParameters: true },
Expand Down Expand Up @@ -113,10 +119,6 @@ module.exports = defineConfig({
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation

// TODO @ST-DDT 2023-10-10: 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.
'@typescript-eslint/no-confusing-void-expression': 'off',

'jsdoc/require-jsdoc': 'off', // Enabled only for src/**/*.ts
'jsdoc/require-returns': 'off',
'jsdoc/sort-tags': [
Expand Down Expand Up @@ -163,12 +165,6 @@ module.exports = defineConfig({
'error',
{
case: 'snakeCase',
// TODO @ST-DDT 2023-10-21: rename the definitions in v9
ignore: [
/chemicalElement\.ts$/,
/directoryPaths\.ts$/,
/mimeTypes\.ts$/,
],
},
],
'unicorn/text-encoding-identifier-case': 'off',
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node_version: [18, 20]
node_version: [18, 20, 22]
fail-fast: false
timeout-minutes: 10

name: 'Build & Unit Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
# Required for docs/versions tests
fetch-depth: 0
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
run: date

- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
# Required for docs/versions tests
fetch-depth: 0
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
name: 'E2E Doc Test: node-20, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
Expand All @@ -122,20 +122,20 @@ jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
name: 'Lint: node-20, ubuntu-latest'
name: 'Lint: node-22, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
node-version: 22
cache: 'pnpm'

- name: Install deps
Expand All @@ -152,20 +152,20 @@ jobs:
ts-check:
runs-on: ubuntu-latest
timeout-minutes: 10
name: 'TS-Check: node-20, ubuntu-latest'
name: 'TS-Check: node-22, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
node-version: 22
cache: 'pnpm'

- name: Install deps
Expand All @@ -182,20 +182,20 @@ jobs:
codecov:
runs-on: ubuntu-latest
timeout-minutes: 10
name: 'Codecov: node-20, ubuntu-latest'
name: 'Codecov: node-22, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
node-version: 22
cache: 'pnpm'

- name: Install deps
Expand All @@ -210,7 +210,7 @@ jobs:
run: pnpm vitest run --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
8 changes: 4 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ jobs:
check-code-generation:
runs-on: ubuntu-latest
timeout-minutes: 10
name: 'Check Code Generation: node-20, ubuntu-latest'
name: 'Check Code Generation: node-22, ubuntu-latest'
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
node-version: 22
cache: 'pnpm'

- name: Install deps
Expand Down
22 changes: 22 additions & 0 deletions docs/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,28 @@ Renamed deprecated locale aliases `cz`, `en_IND`, `ge` and removed `global`.
| `import { faker } from '@faker-js/faker/locale/ge'` | `import { faker } from '@faker-js/faker/locale/ka_GE'` |
| `import { faker } from '@faker-js/faker/locale/global'` | `import { faker } from '@faker-js/faker/locale/base'` |

### Renamed Locale Definitions

The following locale definitions have been renamed

| old | replacement |
| ------------------------------------------- | -------------------------------------------- |
| `faker.definitions.science.chemicalElement` | `faker.definitions.science.chemical_element` |
| `faker.definitions.system.directoryPaths` | `faker.definitions.system.directory_paths` |
| `faker.definitions.system.mimeTypes` | `faker.definitions.system.mime_types` |

With that now all our locale data use the following naming scheme:

```txt
faker.definitions.category_name.entry_name
```

Please keep in mind that property keys of complex objects remain in camel-case.

```txt
faker.definitions.science.chemical_element.atomicNumber
```

### Type Aliases

Removed deprecated type aliases
Expand Down
24 changes: 21 additions & 3 deletions docs/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ const randomEmail = faker.internet.email(); // [email protected]

:::

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

## Browser

If you want to try it yourself, you can open your browser console via `Ctrl + Shift + J` / `F12`.

```js
const { faker } = await import('https://esm.sh/@faker-js/faker');

const randomName = faker.person.fullName(); // Amber Keebler
const randomEmail = faker.internet.email(); // [email protected]
```

Some websites may have protections against downloading external code, dev servers usually work fine.
As an alternative, you can create a simple html file and open it with your browser:

```html
<script type="module">
import { faker } from 'https://esm.sh/@faker-js/faker';
Expand All @@ -39,11 +51,17 @@ For more information about changing and customizing the locales, please refer to
// [email protected]
const randomEmail = faker.internet.email();
document.getElementById('name').value = randomName;
document.getElementById('email').value = randomEmail;
</script>

<input id="name" />
<input id="email" />
```

::: info Note
Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's `> 5 MiB` minified. **Please avoid deploying the full Faker in your web app.**
Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's `> 5 MiB` minified. **Please avoid deploying the full Faker package in your web app.**
:::

## CDN/Deno
Expand All @@ -56,7 +74,7 @@ const randomEmail = faker.internet.email(); // [email protected]
```

::: 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/[email protected].0"`.
It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://esm.sh/@faker-js/[email protected].1"`.
:::

### Alternative CDN links
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@eslint-types/prettier": "5.1.3",
"@eslint-types/typescript-eslint": "7.5.0",
"@eslint-types/unicorn": "52.0.0",
"@types/node": "20.12.11",
"@types/node": "20.12.12",
"@types/sanitize-html": "2.11.0",
"@types/semver": "7.5.8",
"@types/validator": "13.11.10",
Expand All @@ -106,7 +106,7 @@
"@vitest/coverage-v8": "1.6.0",
"@vitest/ui": "1.6.0",
"@vueuse/core": "10.9.0",
"cypress": "13.9.0",
"cypress": "13.10.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-define-config": "2.1.0",
Expand All @@ -116,7 +116,7 @@
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-unicorn": "52.0.0",
"eslint-plugin-vitest": "0.4.1",
"npm-run-all2": "6.1.2",
"npm-run-all2": "6.2.0",
"prettier": "3.2.5",
"prettier-plugin-organize-imports": "3.2.4",
"rimraf": "5.0.7",
Expand All @@ -125,15 +125,15 @@
"commit-and-tag-version": "12.4.1",
"ts-morph": "22.0.0",
"tsup": "8.0.2",
"tsx": "4.10.1",
"tsx": "4.11.0",
"typescript": "5.4.5",
"validator": "13.12.0",
"vite": "5.2.11",
"vitepress": "1.2.0",
"vitepress": "1.2.2",
"vitest": "1.6.0",
"vue": "3.4.27"
},
"packageManager": "[email protected].1",
"packageManager": "[email protected].2",
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
Expand Down
Loading

0 comments on commit f3738a5

Please sign in to comment.