Skip to content

Commit

Permalink
Merge branch 'next' into extend-locale
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Mar 13, 2024
2 parents a0f5e20 + 5ef8ef1 commit 3191474
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
e2e-test:
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.6.1-chrome-116.0.5845.187-1-ff-117.0-edge-116.0.1938.76-1
image: cypress/browsers:node-20.6.1-chrome-116.0.5845.187-1-ff-117.0-edge-116.0.1938.76-1@sha256:cd909915e1a0aa24dbd3eaf95feb2a7be6cf9961fa425ffa06cd5a44d211451c
options: --user 1001
timeout-minutes: 10
name: 'E2E Doc Test: node-20, ubuntu-latest'
Expand Down
48 changes: 48 additions & 0 deletions docs/guide/upgrading_v9/2729.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### Remove deprecated helpers methods

Removed deprecated helpers methods

| old | replacement |
| --------------------------------------- | -------------------------------------------------------------- |
| `faker.helpers.replaceSymbolWithNumber` | `string.replace(/#+/g, (m) => faker.string.numeric(m.length))` |
| `faker.helpers.regexpStyleStringParse` | `faker.helpers.fromRegExp` |

Note these are not exact replacements:

#### `faker.helpers.replaceSymbolWithNumber`

The `replaceSymbolWithNumber` method was deprecated in Faker 8.4 and removed in 9.0. The method parsed the given string symbol by symbol and replaces the `#` symbol with digits (`0` - `9`) and the `!` symbol with digits >=2 (`2` - `9`). This was primarily used internally by Faker for generating phone numbers. If needed, you can use a simple string replace combined with `faker.string.numeric` to replace this

```js
// old
faker.helpers.replaceSymbolWithNumber('#####-##'); // '04812-67'

// new
'#####-##'.replace(/#+/g, (m) => faker.string.numeric(m.length));

// old
faker.helpers.replaceSymbolWithNumber('!#####'); // '123152'

// new
'!#####'
.replace(/#+/g, (m) => faker.string.numeric(m.length))
.replace(/!+/g, (m) =>
faker.string.numeric({ length: m.length, exclude: ['0', '1'] })
);
```

#### `faker.helpers.regexpStyleStringParse`

The `regexpStyleStringParse` method in `faker.helpers` was deprecated in Faker 8.1 and removed in 9.0. A likely replacement is the more powerful `faker.helpers.fromRegExp`.

```js
faker.helpers.regexpStyleStringParse('a{3,6}'); // aaaaa
faker.helpers.fromRegExp('a{3,6}'); // aaaaa
```

However, please note that `faker.helpers.fromRegExp` is not an exact replacement for `faker.helpers.regexpStyleStringParse` as `fromRegExp` cannot handle numeric ranges. This will now need to be handled separately.

```js
faker.helpers.regexpStyleStringParse('a{3,6}[1-100]'); // "aaaa53", etc.
faker.helpers.fromRegExp('a{3,6}') + faker.number.int({ min: 1, max: 100 });
```
60 changes: 30 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@
"preflight": "pnpm install && run-s generate format lint build test:update-snapshots ts-check"
},
"devDependencies": {
"@actions/github": "~6.0.0",
"@algolia/client-search": "~4.22.1",
"@actions/github": "6.0.0",
"@algolia/client-search": "4.22.1",
"@eslint-types/deprecation": "2.0.0-1",
"@eslint-types/jsdoc": "48.2.0",
"@eslint-types/prettier": "5.1.3",
"@eslint-types/typescript-eslint": "7.0.2",
"@eslint-types/unicorn": "51.0.1",
"@types/markdown-it": "~13.0.7",
"@types/node": "~20.11.25",
"@types/sanitize-html": "~2.11.0",
"@types/semver": "~7.5.8",
"@types/validator": "~13.11.9",
"@typescript-eslint/eslint-plugin": "7.1.1",
"@typescript-eslint/parser": "7.1.1",
"@vitest/coverage-v8": "~1.3.1",
"@vitest/ui": "~1.3.1",
"@vueuse/core": "~10.9.0",
"conventional-changelog-cli": "~4.1.0",
"cypress": "~13.6.6",
"@types/markdown-it": "13.0.7",
"@types/node": "20.11.25",
"@types/sanitize-html": "2.11.0",
"@types/semver": "7.5.8",
"@types/validator": "13.11.9",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"@vitest/coverage-v8": "1.3.1",
"@vitest/ui": "1.3.1",
"@vueuse/core": "10.9.0",
"conventional-changelog-cli": "4.1.0",
"cypress": "13.6.6",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-define-config": "2.1.0",
Expand All @@ -110,24 +110,24 @@
"eslint-plugin-jsdoc": "48.2.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-unicorn": "51.0.1",
"eslint-plugin-vitest": "0.3.25",
"glob": "~10.3.10",
"npm-run-all2": "~6.1.2",
"eslint-plugin-vitest": "0.3.26",
"glob": "10.3.10",
"npm-run-all2": "6.1.2",
"prettier": "3.2.5",
"prettier-plugin-organize-imports": "~3.2.4",
"rimraf": "~5.0.5",
"sanitize-html": "~2.12.1",
"semver": "~7.6.0",
"standard-version": "~9.5.0",
"tsup": "~8.0.2",
"tsx": "~4.7.1",
"typedoc": "~0.25.12",
"typescript": "~5.4.2",
"validator": "~13.11.0",
"vite": "~5.1.5",
"prettier-plugin-organize-imports": "3.2.4",
"rimraf": "5.0.5",
"sanitize-html": "2.12.1",
"semver": "7.6.0",
"standard-version": "9.5.0",
"tsup": "8.0.2",
"tsx": "4.7.1",
"typedoc": "0.25.12",
"typescript": "5.4.2",
"validator": "13.11.0",
"vite": "5.1.5",
"vitepress": "1.0.0-rc.45",
"vitest": "~1.3.1",
"vue": "~3.4.21"
"vitest": "1.3.1",
"vue": "3.4.21"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading

0 comments on commit 3191474

Please sign in to comment.