Skip to content

Commit a0fb9a1

Browse files
committed
refactor: remove deprecations
1 parent 660871e commit a0fb9a1

File tree

13 files changed

+6
-569
lines changed

13 files changed

+6
-569
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const { faker } = require('@faker-js/faker');
6565
export function createRandomUser() {
6666
return {
6767
userId: faker.string.uuid(),
68-
username: faker.internet.username(), // before version 9.1.0, use userName()
68+
username: faker.internet.username(),
6969
email: faker.internet.email(),
7070
avatar: faker.image.avatar(),
7171
password: faker.internet.password(),

docs/guide/frameworks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { faker } from '@faker-js/faker/locale/en';
7171

7272
describe('Testing the application', () => {
7373
it('should create an account with username and password', () => {
74-
let username = faker.internet.username(); // before version 9.1.0, use userName()
74+
let username = faker.internet.username();
7575
let password = faker.internet.password();
7676
let email = faker.internet.exampleEmail();
7777

@@ -111,7 +111,7 @@ test.describe('Testing the application', () => {
111111
test('should create an account with username and password', async ({
112112
page,
113113
}) => {
114-
const username = faker.internet.username(); // before version 9.1.0, use userName()
114+
const username = faker.internet.username();
115115
const password = faker.internet.password();
116116
const email = faker.internet.exampleEmail();
117117

src/faker.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { LocaleDefinition, MetadataDefinition } from './definitions';
22
import { FakerError } from './errors/faker-error';
3-
import { deprecated } from './internal/deprecated';
43
import type { LocaleProxy } from './internal/locale-proxy';
54
import { createLocaleProxy } from './internal/locale-proxy';
65
import { AirlineModule } from './modules/airline';
@@ -18,11 +17,9 @@ import { HackerModule } from './modules/hacker';
1817
import { HelpersModule } from './modules/helpers';
1918
import { ImageModule } from './modules/image';
2019
import { InternetModule } from './modules/internet';
21-
import type { LocationModule as AddressModule } from './modules/location';
2220
import { LocationModule } from './modules/location';
2321
import { LoremModule } from './modules/lorem';
2422
import { MusicModule } from './modules/music';
25-
import type { PersonModule as NameModule } from './modules/person';
2623
import { PersonModule } from './modules/person';
2724
import { PhoneModule } from './modules/phone';
2825
import { ScienceModule } from './modules/science';
@@ -87,29 +84,6 @@ export class Faker extends SimpleFaker {
8784
readonly vehicle: VehicleModule = new VehicleModule(this);
8885
readonly word: WordModule = new WordModule(this);
8986

90-
// Aliases
91-
/** @deprecated Use {@link Faker#location} instead */
92-
get address(): AddressModule {
93-
deprecated({
94-
deprecated: 'faker.address',
95-
proposed: 'faker.location',
96-
since: '8.0',
97-
until: '10.0',
98-
});
99-
return this.location;
100-
}
101-
102-
/** @deprecated Use {@link Faker#person} instead */
103-
get name(): NameModule {
104-
deprecated({
105-
deprecated: 'faker.name',
106-
proposed: 'faker.person',
107-
since: '8.0',
108-
until: '10.0',
109-
});
110-
return this.person;
111-
}
112-
11387
/**
11488
* Creates a new instance of Faker.
11589
*

src/modules/finance/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export class FinanceModule extends ModuleBase {
349349
proposed:
350350
"faker.finance.iban().replace(/(?<=.{4})\\w(?=.{2})/g, '*') or a similar approach",
351351
since: '9.3.0',
352-
until: '10.0.0',
352+
until: '11.0.0',
353353
});
354354

355355
if (typeof options === 'number') {

src/modules/image/index.ts

Lines changed: 2 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { SexType } from '../person';
1010
*
1111
* For a random image, use [`url()`](https://fakerjs.dev/api/image.html#url). This will not return the image directly but a URL pointing to an image from one of two demo image providers "Picsum" and "LoremFlickr". You can request an image specifically from one of two providers using [`urlLoremFlickr()`](https://fakerjs.dev/api/image.html#urlloremflickr) or [`urlPicsumPhotos()`](https://fakerjs.dev/api/image.html#urlpicsumphotos).
1212
*
13-
* For a random placeholder image containing only solid color and text, use [`urlPlaceholder()`](https://fakerjs.dev/api/image.html#urlplaceholder) (uses a third-party service) or [`dataUri()`](https://fakerjs.dev/api/image.html#datauri) (returns a SVG string).
13+
* For a random placeholder image containing only solid color and text, use [`dataUri()`](https://fakerjs.dev/api/image.html#datauri) (returns a SVG string).
1414
*
1515
* For a random user avatar image, use [`avatar()`](https://fakerjs.dev/api/image.html#avatar), or [`personPortrait()`](https://fakerjs.dev/api/image.html#personportrait) which has more control over the size and sex of the person.
1616
*
@@ -111,7 +111,7 @@ export class ImageModule extends ModuleBase {
111111
deprecated: 'faker.image.avatarLegacy()',
112112
proposed: 'faker.image.avatar() or faker.image.personPortrait()',
113113
since: '9.0.2',
114-
until: '10.0.0',
114+
until: '11.0.0',
115115
});
116116

117117
return `https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/${this.faker.number.int(
@@ -293,110 +293,6 @@ export class ImageModule extends ModuleBase {
293293
return url;
294294
}
295295

296-
/**
297-
* Generates a random image url provided via https://via.placeholder.com/.
298-
*
299-
* @remark This method generates a random string representing an URL from via.placeholder. Faker is not responsible for the content of the image or the service providing it.
300-
*
301-
* @param options Options for generating a URL for an image.
302-
* @param options.width The width of the image. Defaults to a random number between 1 and 3500.
303-
* @param options.height The height of the image. Defaults to a random number between 1 and 3500.
304-
* @param options.backgroundColor The background color of the image. Defaults to a random hex color.
305-
* @param options.textColor The text color of the image. Defaults to a random hex color.
306-
* @param options.format The format of the image. Defaults to a random format.
307-
* @param options.text The text to display on the image. Defaults to a random string.
308-
*
309-
* @example
310-
* faker.image.urlPlaceholder() // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.webp?text=lorem'
311-
* faker.image.urlPlaceholder({ width: 128 }) // 'https://via.placeholder.com/128x180/FF0000/FFFFFF.webp?text=lorem'
312-
* faker.image.urlPlaceholder({ height: 128 }) // 'https://via.placeholder.com/150x128/FF0000/FFFFFF.webp?text=lorem'
313-
* faker.image.urlPlaceholder({ backgroundColor: '000000' }) // 'https://via.placeholder.com/150x180/000000/FFFFFF.webp?text=lorem'
314-
* faker.image.urlPlaceholder({ textColor: '000000' }) // 'https://via.placeholder.com/150x180/FF0000/000000.webp?text=lorem'
315-
* faker.image.urlPlaceholder({ format: 'png' }) // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.png?text=lorem'
316-
* faker.image.urlPlaceholder({ text: 'lorem ipsum' }) // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.webp?text=lorem+ipsum'
317-
* faker.image.urlPlaceholder({ width: 128, height: 128, backgroundColor: '000000', textColor: 'FF0000', format: 'png', text: 'lorem ipsum' }) // 'https://via.placeholder.com/128x128/000000/FF0000.png?text=lorem+ipsum'
318-
*
319-
* @since 8.0.0
320-
*
321-
* @deprecated The service has bad uptime. Use `faker.image.url()` or `faker.image.dataUri()` instead.
322-
*/
323-
urlPlaceholder(
324-
options: {
325-
/**
326-
* The width of the image.
327-
*
328-
* @default faker.number.int({ min: 1, max: 3500 })
329-
*/
330-
width?: number;
331-
/**
332-
* The height of the image.
333-
*
334-
* @default faker.number.int({ min: 1, max: 3500 })
335-
*/
336-
height?: number;
337-
/**
338-
* The background color of the image.
339-
*
340-
* @default faker.color.rgb({ format: 'hex', prefix: '' })
341-
*/
342-
backgroundColor?: string;
343-
/**
344-
* The text color of the image.
345-
*
346-
* @default faker.color.rgb({ format: 'hex', prefix: '' })
347-
*/
348-
textColor?: string;
349-
/**
350-
* The format of the image.
351-
*
352-
* @default faker.helpers.arrayElement(['gif', 'jpeg', 'jpg', 'png', 'webp'])
353-
*/
354-
format?: 'gif' | 'jpeg' | 'jpg' | 'png' | 'webp';
355-
/**
356-
* The text to display on the image.
357-
*
358-
* @default faker.lorem.words()
359-
*/
360-
text?: string;
361-
} = {}
362-
): string {
363-
deprecated({
364-
deprecated: 'faker.image.urlPlaceholder()',
365-
proposed: 'faker.image.url() or faker.image.dataUri()',
366-
since: '9.4.0',
367-
until: '10.0.0',
368-
});
369-
370-
const {
371-
width = this.faker.number.int({ min: 1, max: 3500 }),
372-
height = this.faker.number.int({ min: 1, max: 3500 }),
373-
backgroundColor = this.faker.color.rgb({ format: 'hex', prefix: '' }),
374-
textColor = this.faker.color.rgb({ format: 'hex', prefix: '' }),
375-
format = this.faker.helpers.arrayElement([
376-
'gif',
377-
'jpeg',
378-
'jpg',
379-
'png',
380-
'webp',
381-
]),
382-
text = this.faker.lorem.words(),
383-
} = options;
384-
385-
let url = `https://via.placeholder.com`;
386-
387-
url += `/${width}`;
388-
url += `x${height}`;
389-
390-
url += `/${backgroundColor}`;
391-
url += `/${textColor}`;
392-
393-
url += `.${format}`;
394-
395-
url += `?text=${encodeURIComponent(text)}`;
396-
397-
return url;
398-
}
399-
400296
/**
401297
* Generates a random data uri containing an URL-encoded SVG image or a Base64-encoded SVG image.
402298
*

src/modules/internet/index.ts

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { FakerError } from '../../errors/faker-error';
22
import type { Faker } from '../../faker';
33
import { toBase64Url } from '../../internal/base64';
4-
import { deprecated } from '../../internal/deprecated';
54
import { ModuleBase } from '../../internal/module-base';
65
import { charMapping } from './char-mappings';
76

@@ -134,18 +133,6 @@ function makeValidDomainWordSlug(faker: Faker, word: string): string {
134133
});
135134
}
136135

137-
/**
138-
* Generates a random color in hex format with the given base color.
139-
*
140-
* @param faker The faker instance to use.
141-
* @param base The base color to use.
142-
*/
143-
function colorFromBase(faker: Faker, base: number): string {
144-
return Math.floor((faker.number.int(256) + base) / 2)
145-
.toString(16)
146-
.padStart(2, '0');
147-
}
148-
149136
/**
150137
* Module to generate internet related entries.
151138
*
@@ -296,58 +283,6 @@ export class InternetModule extends ModuleBase {
296283
});
297284
}
298285

299-
/**
300-
* Generates a username using the given person's name as base.
301-
* The resulting username may use neither, one or both of the names provided.
302-
* This will always return a plain ASCII string.
303-
* Some basic stripping of accents and transliteration of characters will be done.
304-
*
305-
* @param options An options object.
306-
* @param options.firstName The optional first name to use. If not specified, a random one will be chosen.
307-
* @param options.lastName The optional last name to use. If not specified, a random one will be chosen.
308-
*
309-
* @see faker.internet.displayName(): For generating an Unicode display name.
310-
*
311-
* @example
312-
* faker.internet.userName() // 'Nettie_Zboncak40'
313-
* faker.internet.userName({ firstName: 'Jeanne' }) // 'Jeanne98'
314-
* faker.internet.userName({ firstName: 'Jeanne' }) // 'Jeanne.Smith98'
315-
* faker.internet.userName({ firstName: 'Jeanne', lastName: 'Doe'}) // 'Jeanne_Doe98'
316-
* faker.internet.userName({ firstName: 'John', lastName: 'Doe' }) // 'John.Doe'
317-
* faker.internet.userName({ firstName: 'Hélene', lastName: 'Müller' }) // 'Helene_Muller11'
318-
* faker.internet.userName({ firstName: 'Фёдор', lastName: 'Достоевский' }) // 'Fedor.Dostoevskii50'
319-
* faker.internet.userName({ firstName: '大羽', lastName: '陳' }) // 'hlzp8d.tpv45' - note neither name is used
320-
*
321-
* @since 2.0.1
322-
*
323-
* @deprecated Use `faker.internet.username()` instead.
324-
*/
325-
userName(
326-
options: {
327-
/**
328-
* The optional first name to use.
329-
*
330-
* @default faker.person.firstName()
331-
*/
332-
firstName?: string;
333-
/**
334-
* The optional last name to use.
335-
*
336-
* @default faker.person.lastName()
337-
*/
338-
lastName?: string;
339-
} = {}
340-
): string {
341-
deprecated({
342-
deprecated: 'faker.internet.userName()',
343-
proposed: 'faker.internet.username()',
344-
since: '9.1.0',
345-
until: '10.0.0',
346-
});
347-
348-
return this.username(options);
349-
}
350-
351286
/**
352287
* Generates a username using the given person's name as base.
353288
* The resulting username may use neither, one or both of the names provided.
@@ -806,65 +741,6 @@ export class InternetModule extends ModuleBase {
806741
);
807742
}
808743

809-
/**
810-
* Generates a random css hex color code in aesthetically pleasing color palette.
811-
*
812-
* Based on
813-
* http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette
814-
*
815-
* @param options An options object.
816-
* @param options.redBase The optional base red in range between `0` and `255`. Defaults to `0`.
817-
* @param options.greenBase The optional base green in range between `0` and `255`. Defaults to `0`.
818-
* @param options.blueBase The optional base blue in range between `0` and `255`. Defaults to `0`.
819-
*
820-
* @see faker.color.rgb(): For generating a random RGB color.
821-
*
822-
* @example
823-
* faker.internet.color() // '#30686e'
824-
* faker.internet.color({ redBase: 100, greenBase: 100, blueBase: 100 }) // '#4e5f8b'
825-
*
826-
* @since 2.0.1
827-
*
828-
* @deprecated Please use faker.color.rgb() or any of the other color methods instead.
829-
*/
830-
color(
831-
options: {
832-
/**
833-
* The optional base red in range between `0` and `255`.
834-
*
835-
* @default 0
836-
*/
837-
redBase?: number;
838-
/**
839-
* The optional base green in range between `0` and `255`.
840-
*
841-
* @default 0
842-
*/
843-
greenBase?: number;
844-
/**
845-
* The optional base blue in range between `0` and `255`.
846-
*
847-
* @default 0
848-
*/
849-
blueBase?: number;
850-
} = {}
851-
): string {
852-
deprecated({
853-
deprecated: 'faker.internet.color()',
854-
proposed: 'faker.color.rgb()',
855-
since: '9.6.0',
856-
until: '10.0.0',
857-
});
858-
859-
const { redBase = 0, greenBase = 0, blueBase = 0 } = options;
860-
861-
const red = colorFromBase(this.faker, redBase);
862-
const green = colorFromBase(this.faker, greenBase);
863-
const blue = colorFromBase(this.faker, blueBase);
864-
865-
return `#${red}${green}${blue}`;
866-
}
867-
868744
/**
869745
* Generates a random mac address.
870746
*

0 commit comments

Comments
 (0)