faker
faker copied to clipboard
feat: extract sex generator from name.gender to name.sex
Fixes #353 Fixes #776
- extract sex generator from name.gender to name.sex
- deprecate
name.gender(true)
, which generated binary gender, what we would consider now assex
- rename locale definitions from
bianry_gender
tosex
- lowercase english values for
sex
- extend english locale with
non-binary
Codecov Report
Merging #1168 (ca21e20) into main (ca7cb41) will increase coverage by
0.00%
. The diff coverage is97.77%
.
@@ Coverage Diff @@
## main #1168 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 2158 2159 +1
Lines 240193 240217 +24
Branches 1003 1005 +2
=======================================
+ Hits 239294 239325 +31
+ Misses 878 871 -7
Partials 21 21
Impacted Files | Coverage Δ | |
---|---|---|
src/definitions/name.ts | 0.00% <0.00%> (ø) |
|
src/locales/fr/name/sex.ts | 100.00% <ø> (ø) |
|
src/locales/fr_CH/name/sex.ts | 100.00% <ø> (ø) |
|
src/locales/pt_BR/name/sex.ts | 100.00% <ø> (ø) |
|
src/locales/ur/name/sex.ts | 100.00% <ø> (ø) |
|
src/locales/de/name/index.ts | 100.00% <100.00%> (ø) |
|
src/locales/de/name/sex.ts | 100.00% <100.00%> (ø) |
|
src/locales/en/name/index.ts | 100.00% <100.00%> (ø) |
|
src/locales/en/name/sex.ts | 100.00% <100.00%> (ø) |
|
src/locales/fr/name/index.ts | 100.00% <100.00%> (ø) |
|
... and 7 more |
This is a breaking change as
binary_gender
could be used infaker.faker('{{binary_gender}}')
without that we know it or users know that it had changed I mark this as blocked for now and would like to first discuss if this PR is needed anyway
If we are killing gender
enum, it feels like this is a natural good step forward to make the differentiation between gender
and sex
.
In my opinion faker.fake
should be deprecated, as the same result can be achieved with string templates, which additionally allow user to provide options to method calls, instead of just using locales.
So yes, technically it could be a breaking change, but at the same time locale formats are not officially published, so I have doubts if anybody would hook up to the internals so deep to find it. And if he did, it's kind of not our fault...
@ST-DDT @xDivisionByZerox wdyt?
In my opinion faker.fake should be deprecated, as the same result can be achieved with string templates, which additionally allow user to provide options to method calls, instead of just using locales.
TBH, I'm with you on this one. Never understood the use of fake
at all. Gues its legacy from pre-v5.5.
So yes, technically it could be a breaking change, but at the same time locale formats are not officially published, so I have doubts if anybody would hook up to the internals so deep to find it. And if he did, it's kind of not our fault...
Not "technically". In this case, it is since the feature to use locale definition with fake
is documented AND promoted by using it in our own codebase. Have a look at these deprecation statements:
https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L103-L109
https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L126-L132
So for me, there is no question whether renaming binary_gender
is a breaking change. It clearly is.
TBH, I'm with you on this one. Never understood the use of fake at all. Gues its legacy from pre-v5.5.
See my (same) comment https://github.com/faker-js/faker/pull/1161#issuecomment-1195852602
Not "technically". In this case, it is since the feature to use locale definition with
fake
is documented AND promoted by using it in our own codebase. Have a look at these deprecation statements:https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L103-L109
https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L126-L132
So for me, there is no question whether renaming
binary_gender
is a breaking change. It clearly is.
These are two statements that do not mention binary_gender
, so it's unlikely someone would be using it. Especially this data is provided in 5 locales only, so very few... So yes, this is technically breaking, but the impact is low...
What are the next steps? Should I do anything about it?
Should we duplicate the binary_gender locale definition for now and remove it in v8? That way we could merge this PR now and don't need to wait because of the breaking change for the fake function 🤔
Should we duplicate the binary_gender locale definition for now and remove it in v8? That way we could merge this PR now and don't need to wait because of the breaking change for the fake function 🤔
We could if you think it's worth it. Hard to say if anybody was using it in fake
, but I kind of doubt it... We should deprecate faker.helpers.fake
as it does not allow us to do any kind of typings :(
Docs-Preview (Click to expand)
I believe I applied all of the feedback. Is there anything else I should do about it?
Ping @ST-DDT, you need to approve to stale your requested changes