Skip to content

Commit

Permalink
Migrate from faker to @faker-js/faker (opensearch-project#594) (opens…
Browse files Browse the repository at this point in the history
…earch-project#655)

Signed-off-by: Andrey Myssak <[email protected]>
Co-authored-by: Sergey Myssak <[email protected]>
  • Loading branch information
andreymyssak and SergeyMyssak authored Apr 12, 2023
1 parent 7e12fbe commit ff45ae5
Show file tree
Hide file tree
Showing 27 changed files with 222 additions and 178 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"vfile": "^4.2.0"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@axe-core/puppeteer": "^4.1.1",
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
Expand Down Expand Up @@ -188,7 +189,6 @@
"eslint-plugin-react": "^7.21.3",
"eslint-plugin-react-hooks": "^4.1.2",
"expose-gc": "^1.0.0",
"faker": "^4.1.0",
"file-loader": "^6.1.0",
"findup": "^0.1.5",
"fork-ts-checker-webpack-plugin": "^5.1.0",
Expand Down
16 changes: 10 additions & 6 deletions src-docs/src/views/datagrid/additional_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useState, useCallback, Fragment } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import {
OuiDataGrid,
Expand Down Expand Up @@ -40,13 +40,17 @@ const data = [];

for (let i = 1; i < 20; i++) {
data.push({
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: (
<OuiLink href="http://google.com">{fake('{{address.city}}')}</OuiLink>
<OuiLink href="http://google.com">
{faker.helpers.fake('{{address.city}}')}
</OuiLink>
),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
16 changes: 9 additions & 7 deletions src-docs/src/views/datagrid/column_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useState, useCallback } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import { OuiDataGrid, OuiAvatar } from '../../../../src/components/';

Expand Down Expand Up @@ -68,14 +68,16 @@ for (let i = 1; i < 5; i++) {
avatar: (
<OuiAvatar
size="s"
name={fake('{{name.lastName}}, {{name.firstName}}')}
name={faker.helpers.fake('{{name.lastName}}, {{name.firstName}}')}
/>
),
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
city: fake('{{address.city}}'),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: faker.helpers.fake('{{address.city}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
16 changes: 9 additions & 7 deletions src-docs/src/views/datagrid/column_cell_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useState, useCallback } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import { OuiDataGrid, OuiAvatar } from '../../../../src/components/';

Expand Down Expand Up @@ -115,14 +115,16 @@ for (let i = 1; i < 5; i++) {
avatar: (
<OuiAvatar
size="s"
name={fake('{{name.lastName}}, {{name.firstName}}')}
name={faker.helpers.fake('{{name.lastName}}, {{name.firstName}}')}
/>
),
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
city: fake('{{address.city}}'),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: faker.helpers.fake('{{address.city}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
16 changes: 9 additions & 7 deletions src-docs/src/views/datagrid/column_widths.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useState, useCallback } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import { OuiDataGrid, OuiAvatar } from '../../../../src/components/';

Expand Down Expand Up @@ -45,14 +45,16 @@ for (let i = 1; i < 5; i++) {
avatar: (
<OuiAvatar
size="s"
name={fake('{{name.lastName}}, {{name.firstName}}')}
name={faker.helpers.fake('{{name.lastName}}, {{name.firstName}}')}
/>
),
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
city: fake('{{address.city}}'),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: faker.helpers.fake('{{address.city}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
16 changes: 10 additions & 6 deletions src-docs/src/views/datagrid/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useState, useCallback } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import { OuiDataGrid, OuiPanel, OuiLink } from '../../../../src/components/';

Expand All @@ -36,13 +36,17 @@ const data = [];

for (let i = 1; i < 20; i++) {
data.push({
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: (
<OuiLink href="http://google.com">{fake('{{address.city}}')}</OuiLink>
<OuiLink href="http://google.com">
{faker.helpers.fake('{{address.city}}')}
</OuiLink>
),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
16 changes: 9 additions & 7 deletions src-docs/src/views/datagrid/control_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import React, {
useState,
Fragment,
} from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import {
OuiDataGrid,
Expand Down Expand Up @@ -72,14 +72,16 @@ for (let i = 1; i < 500; i++) {
avatar: (
<OuiAvatar
size="s"
name={fake('{{name.lastName}}, {{name.firstName}}')}
name={faker.helpers.fake('{{name.lastName}}, {{name.firstName}}')}
/>
),
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: fake('{{internet.email}}'),
city: fake('{{address.city}}'),
country: fake('{{address.country}}'),
account: fake('{{finance.account}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: faker.helpers.fake('{{internet.email}}'),
city: faker.helpers.fake('{{address.city}}'),
country: faker.helpers.fake('{{address.country}}'),
account: faker.helpers.fake('{{finance.account}}'),
});
}

Expand Down
26 changes: 14 additions & 12 deletions src-docs/src/views/datagrid/datagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React, {
useContext,
useRef,
} from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import {
OuiDataGrid,
Expand All @@ -36,31 +36,33 @@ const DataContext = createContext();
const raw_data = [];

for (let i = 1; i < 100; i++) {
const email = fake('{{internet.email}}');
const name = fake('{{name.lastName}}, {{name.firstName}}');
const suffix = fake('{{name.suffix}}');
const email = faker.helpers.fake('{{internet.email}}');
const name = faker.helpers.fake('{{name.lastName}}, {{name.firstName}}');
const suffix = faker.helpers.fake('{{name.suffix}}');
raw_data.push({
name: {
formatted: `${name} ${suffix}`,
raw: name,
},
email: {
formatted: <OuiLink href="">{fake('{{internet.email}}')}</OuiLink>,
formatted: (
<OuiLink href="">{faker.helpers.fake('{{internet.email}}')}</OuiLink>
),
raw: email,
},
location: (
<Fragment>
{`${fake('{{address.city}}')}, `}
{`${faker.helpers.fake('{{address.city}}')}, `}
<OuiLink href="https://google.com">
{fake('{{address.country}}')}
{faker.helpers.fake('{{address.country}}')}
</OuiLink>
</Fragment>
),
date: fake('{{date.past}}'),
account: fake('{{finance.account}}'),
amount: fake('${{commerce.price}}'),
phone: fake('{{phone.phoneNumber}}'),
version: fake('{{system.semver}}'),
date: faker.helpers.fake('{{date.past}}'),
account: faker.helpers.fake('{{finance.account}}'),
amount: faker.helpers.fake('${{commerce.price}}'),
phone: faker.helpers.fake('{{phone.number}}'),
version: faker.helpers.fake('{{system.semver}}'),
});
}

Expand Down
10 changes: 5 additions & 5 deletions src-docs/src/views/datagrid/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* eslint-disable jsx-a11y/accessible-emoji */
import React, { useState, useCallback, useMemo } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import {
OuiDataGrid,
Expand All @@ -30,17 +30,17 @@ const data = [];

for (let i = 0; i < 10; i++) {
data.push([
<span>{fake('{{name.firstName}}')}</span>,
<span>{fake('{{name.firstName}}')}</span>,
<span>{faker.helpers.fake('{{name.firstName}}')}</span>,
<span>{faker.helpers.fake('{{name.firstName}}')}</span>,

<span>
<OuiLink href="#/tabular-content/data-grid-focus">
{fake('{{internet.email}}')}
{faker.helpers.fake('{{internet.email}}')}
</OuiLink>
</span>,
<span>
<OuiLink href="#/tabular-content/data-grid-focus">
{fake('{{internet.email}}')}
{faker.helpers.fake('{{internet.email}}')}
</OuiLink>
</span>,

Expand Down
14 changes: 8 additions & 6 deletions src-docs/src/views/datagrid/footer_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import {
OuiDataGrid,
Expand All @@ -23,11 +23,13 @@ const raw_data = [];

for (let i = 1; i < 20; i++) {
raw_data.push({
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
date: fake('{{date.past}}'),
amount: fake('${{commerce.price}}'),
phone: fake('{{phone.phoneNumber}}'),
version: fake('{{system.semver}}'),
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
date: faker.helpers.fake('{{date.past}}'),
amount: faker.helpers.fake('${{commerce.price}}'),
phone: faker.helpers.fake('{{phone.number}}'),
version: faker.helpers.fake('{{system.semver}}'),
});
}

Expand Down
24 changes: 14 additions & 10 deletions src-docs/src/views/datagrid/in_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import React, { Fragment, useCallback, useMemo, useState } from 'react';
import { fake } from 'faker';
import { faker } from '@faker-js/faker';

import { OuiDataGrid, OuiLink } from '../../../../src/components/';

Expand Down Expand Up @@ -46,21 +46,25 @@ const raw_data = [];

for (let i = 1; i < 100; i++) {
raw_data.push({
name: fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
email: <OuiLink href="">{fake('{{internet.email}}')}</OuiLink>,
name: faker.helpers.fake(
'{{name.lastName}}, {{name.firstName}} {{name.suffix}}'
),
email: (
<OuiLink href="">{faker.helpers.fake('{{internet.email}}')}</OuiLink>
),
location: (
<Fragment>
{`${fake('{{address.city}}')}, `}
{`${faker.helpers.fake('{{address.city}}')}, `}
<OuiLink href="https://google.com">
{fake('{{address.country}}')}
{faker.helpers.fake('{{address.country}}')}
</OuiLink>
</Fragment>
),
date: fake('{{date.past}}'),
account: fake('{{finance.account}}'),
amount: fake('${{commerce.price}}'),
phone: fake('{{phone.phoneNumber}}'),
version: fake('{{system.semver}}'),
date: faker.helpers.fake('{{date.past}}'),
account: faker.helpers.fake('{{finance.account}}'),
amount: faker.helpers.fake('${{commerce.price}}'),
phone: faker.helpers.fake('{{phone.number}}'),
version: faker.helpers.fake('{{system.semver}}'),
});
}

Expand Down
Loading

0 comments on commit ff45ae5

Please sign in to comment.