Skip to content

refactor(locale): updates county patterns for en, en_US#1988

Closed
matthewmayer wants to merge 2 commits into
faker-js:nextfrom
matthewmayer:chore/en-counties
Closed

refactor(locale): updates county patterns for en, en_US#1988
matthewmayer wants to merge 2 commits into
faker-js:nextfrom
matthewmayer:chore/en-counties

Conversation

@matthewmayer

Copy link
Copy Markdown
Contributor

part of #1944

Currently the en faker.location.county data is a truncated list of 6 English counties.

Improve this by

  1. Allowing faker.location.county to use faker.fake patterns
  2. Changing the default en pattern to be {{person.last_name}} County
  3. Changing the en_US data to use the most common US county names from https://en.wikipedia.org/wiki/List_of_the_most_common_U.S._county_names
@matthewmayer matthewmayer requested a review from a team as a code owner March 29, 2023 06:56
@matthewmayer matthewmayer self-assigned this Mar 29, 2023
@matthewmayer matthewmayer added m: location Something is referring to the location module c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs c: locale Permutes locale definitions p: 1-normal Nothing urgent labels Mar 29, 2023
@ST-DDT ST-DDT added the s: needs decision Needs team/maintainer decision label Mar 29, 2023
@ST-DDT

ST-DDT commented Mar 29, 2023

Copy link
Copy Markdown
Member

I'm not sure whether we should start faking county names.

@Shinigami92 Shinigami92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you need to run vitest snapshots

'Buckinghamshire',
'Cambridgeshire',
];
export default ['{{person.last_name}} County'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I would expect to have County names with famous/memorial names
This now results just in a random name with not so much value as manually calling faker.person.lastName() + ' County' myself.
Theoretically this could also result in even stuff like Виноградов County when mixing ru on top of en 👀
So maybe in this case (for county) we maybe should just remove county from en and lead users to use the specific en_GB/en_US variants.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, though

  • Виноградов County seems better than Cambridgeshire, which is what you would get at the moment for ru. Eventually all locales could have 1st and 2nd level administrative areas added.
  • Faking counties potentially avoids the problem where people say "but there's not a Marion County, California, that's in Mississippi" ie the 1st and 2nd level admin areas don't match up.
  • If we remove the county definitions from en completely won't you get 'a', 'b', 'c' in the default locale due to the issue with arrayElement?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove the county definitions from en completely won't you get 'a', 'b', 'c' in the default locale due to the issue with arrayElement?

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe last_name+" County" is not the best approach, but its similar to how faker.location.city() and faker.location.street() works in en. Second level admin areas in most countries are numerous enough that people would not be expected to know all their names (whereas generating completely fake states might seem weirder).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO there are very few counties (and very few usecases for them).
If you ask for one, thrn you probably need one explicitly.
For city and street we have a method that generates them and one that returns existing ones.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3,006 counties in the US.

@ST-DDT ST-DDT Mar 29, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going for generated county names, we should have a separate method for that.
(Similar to city and street names)

The question is, do we need that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No (I find the city/cityNane and street/streetName confusing enough)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just make the county definitions for en []

Then you get undefined for now which is less confusing than "b" or "Cambridgeshire" and we can note in the docs that this only works in select locales.

@codecov

codecov Bot commented Mar 29, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1988 (5cd5727) into next (8516bfb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff            @@
##             next    #1988    +/-   ##
========================================
  Coverage   99.62%   99.62%            
========================================
  Files        2450     2459     +9     
  Lines      239748   239936   +188     
  Branches     1272     1280     +8     
========================================
+ Hits       238853   239041   +188     
+ Misses        873      872     -1     
- Partials       22       23     +1     
Impacted Files Coverage Δ
src/locales/en/location/county.ts 100.00% <100.00%> (ø)
src/locales/en_US/location/county.ts 100.00% <100.00%> (ø)
src/locales/en_US/location/index.ts 100.00% <100.00%> (ø)
src/modules/location/index.ts 98.91% <100.00%> (+0.21%) ⬆️

... and 101 files with indirect coverage changes

@ST-DDT

ST-DDT commented Mar 29, 2023

Copy link
Copy Markdown
Member

Also we should probably add the US county names in a separate PR, than the rewrite/refactor.

@matthewmayer matthewmayer added the do NOT merge yet Do not merge this PR into the target branch yet label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: locale Permutes locale definitions c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs do NOT merge yet Do not merge this PR into the target branch yet m: location Something is referring to the location module p: 1-normal Nothing urgent s: needs decision Needs team/maintainer decision

3 participants