Skip to content

Commit 9161a06

Browse files
refactor(location): deprecate cityName (#2070)
1 parent 2a6f578 commit 9161a06

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

docs/guide/upgrading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ The `faker.address.*` methods will continue to work as an alias in v8 and v9, bu
167167
| `faker.address.buildingNumber` | `faker.location.buildingNumber` |
168168
| `faker.address.cardinalDirection` | `faker.location.cardinalDirection` |
169169
| `faker.address.city` | `faker.location.city` |
170-
| `faker.address.cityName` | `faker.location.cityName` |
170+
| `faker.address.cityName` | `faker.location.city` |
171171
| `faker.address.country` | `faker.location.country` |
172172
| `faker.address.countryCode` | `faker.location.countryCode` |
173173
| `faker.address.county` | `faker.location.county` |

src/modules/location/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,23 @@ export class LocationModule {
156156
/**
157157
* Returns a random city name from a list of real cities for the locale.
158158
*
159+
* @see faker.location.city()
160+
*
159161
* @example
160162
* faker.location.cityName() // 'San Rafael'
161163
* fakerDE.location.cityName() // 'Nürnberg'
162164
*
163165
* @since 8.0.0
166+
*
167+
* @deprecated Use `faker.location.city()` instead.
164168
*/
165169
cityName(): string {
170+
deprecated({
171+
deprecated: 'faker.location.cityName',
172+
proposed: 'faker.location.city',
173+
since: '8.0',
174+
until: '9.0',
175+
});
166176
return this.faker.helpers.arrayElement(
167177
this.faker.definitions.location.city_name
168178
);

src/modules/random/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class RandomModule {
5353

5454
const wordMethods = [
5555
() => this.faker.location.cardinalDirection(),
56-
this.faker.location.cityName,
5756
this.faker.location.country,
5857
this.faker.location.county,
5958
() => this.faker.location.direction(),

test/__snapshots__/random.spec.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ exports[`random > 42 > numeric > noArgs 1`] = `"3"`;
1212

1313
exports[`random > 42 > numeric > with length 1`] = `"37917"`;
1414

15-
exports[`random > 42 > word 1`] = `"responsive"`;
15+
exports[`random > 42 > word 1`] = `"project"`;
1616

17-
exports[`random > 42 > words > noArgs 1`] = `"lavender Shoes"`;
17+
exports[`random > 42 > words > noArgs 1`] = `"Hybrid Shoes"`;
1818

19-
exports[`random > 42 > words > with length 1`] = `"responsive comics Neptunium Hip deposit"`;
19+
exports[`random > 42 > words > with length 1`] = `"project comics Neptunium Multigender violet"`;
2020

21-
exports[`random > 42 > words > with length range 1`] = `"lavender Shoes"`;
21+
exports[`random > 42 > words > with length range 1`] = `"Hybrid Shoes"`;
2222

2323
exports[`random > 1211 > alpha > noArgs 1`] = `"W"`;
2424

@@ -34,11 +34,11 @@ exports[`random > 1211 > numeric > with length 1`] = `"94872"`;
3434

3535
exports[`random > 1211 > word 1`] = `"gah"`;
3636

37-
exports[`random > 1211 > words > noArgs 1`] = `"invoice Cyclocross assail"`;
37+
exports[`random > 1211 > words > noArgs 1`] = `"USB teal Batz"`;
3838

39-
exports[`random > 1211 > words > with length 1`] = `"gah strictly Rustic assail Manager"`;
39+
exports[`random > 1211 > words > with length 1`] = `"gah strictly Bronze assail Manager"`;
4040

41-
exports[`random > 1211 > words > with length range 1`] = `"invoice Cyclocross assail Manager Gourde"`;
41+
exports[`random > 1211 > words > with length range 1`] = `"USB teal Batz Manager male"`;
4242

4343
exports[`random > 1337 > alpha > noArgs 1`] = `"n"`;
4444

@@ -56,6 +56,6 @@ exports[`random > 1337 > word 1`] = `"Bespoke"`;
5656

5757
exports[`random > 1337 > words > noArgs 1`] = `"quia"`;
5858

59-
exports[`random > 1337 > words > with length 1`] = `"Bespoke connect Fort generating Ball"`;
59+
exports[`random > 1337 > words > with length 1`] = `"Bespoke connect French pixel Ball"`;
6060

61-
exports[`random > 1337 > words > with length range 1`] = `"quia Ball"`;
61+
exports[`random > 1337 > words > with length range 1`] = `"quia Incredible"`;

0 commit comments

Comments
 (0)