faker
faker copied to clipboard
infra(unicorn): no-useless-switch-case
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
25f2a03) 99.55% compared to head (5be7f09) 99.55%.
Additional details and impacted files
@@ Coverage Diff @@
## next #2508 +/- ##
==========================================
- Coverage 99.55% 99.55% -0.01%
==========================================
Files 2817 2817
Lines 251208 251188 -20
Branches 725 718 -7
==========================================
- Hits 250101 250075 -26
- Misses 1078 1113 +35
+ Partials 29 0 -29
| Files | Coverage Δ | |
|---|---|---|
| src/modules/color/index.ts | 99.79% <ø> (-0.01%) |
:arrow_down: |
| src/modules/internet/index.ts | 100.00% <100.00%> (ø) |
|
| src/modules/location/index.ts | 99.05% <ø> (-0.16%) |
:arrow_down: |
| src/modules/string/index.ts | 100.00% <ø> (ø) |
Team Decision
- We want to enable https://typescript-eslint.io/rules/switch-exhaustiveness-check/
- After that is merged, we no longer need the default and can remove it.
- Consideration, if a non typescript user inputs a bad value, currently it would go into the default case. We could throw an error but we don't do that for other bad values either, so non typescript users don't get special support for enums either.
- @ST-DDT: Will create an issue for
switch-exhaustiveness-checks to require default cases for non union type switch cases
EDIT:
- https://github.com/typescript-eslint/typescript-eslint/pull/7880
Blocked by #2519
- #2519
Per #2521 suggest adding the following to docs/guide/upgrading_v9/2508.md:
Some methods now return undefined in Javascript when unknown enumeration values are passed
Some methods would previously fallback to a default value for an option when an unknown value was passed for a enum parameter. Now, these methods will return undefined instead. This only affects usage in Javascript, as in Typescript this usage would already throw a compile-time error.
For example:
faker.color.rgb({format: "unexpectedvalue"})
// in Faker v8, is [ 110, 82, 190 ] like {format: "decimal"}
// in Faker v9, is undefined
This affects:
- The
formatproperty offaker.color.rgb()must be one of'binary' | 'css' | 'decimal' | 'hex'if provided - The
formatproperty offaker.color.cmyk(),faker.color.hsl(),faker.color.hwb(),faker.color.lab(),faker.color.lch()must be one of'binary' | 'css' | 'decimal'if provided - The
variantproperty offaker.location.countryCode()must be one ofalpha-2,alpha-3,numericif provided - The
casingproperty offaker.string.alpha()andfaker.string.alphanumeric()must be one of'upper' | 'lower' | 'mixed'if provided
Per #2521 suggest adding the following to docs/guide/upgrading_v9/2508.md:
Added. Thanks for the suggestion.
Ready for review.
Switched to strategy pattern. Ready to review.