faker icon indicating copy to clipboard operation
faker copied to clipboard

infra(unicorn): no-useless-switch-case

Open ST-DDT opened this issue 2 years ago • 6 comments

Ref: #2439

  • #2439

Permanently disables the unicorn/no-useless-switch-case lint rule.

ST-DDT avatar Oct 27 '23 20:10 ST-DDT

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% <ø> (ø)

... and 30 files with indirect coverage changes

codecov[bot] avatar Oct 27 '23 20:10 codecov[bot]

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

ST-DDT avatar Oct 31 '23 18:10 ST-DDT

Blocked by #2519

  • #2519

ST-DDT avatar Nov 01 '23 09:11 ST-DDT

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 format property of faker.color.rgb() must be one of 'binary' | 'css' | 'decimal' | 'hex' if provided
  • The format property of faker.color.cmyk(), faker.color.hsl(), faker.color.hwb(), faker.color.lab(), faker.color.lch() must be one of 'binary' | 'css' | 'decimal' if provided
  • The variant property of faker.location.countryCode() must be one of alpha-2, alpha-3, numeric if provided
  • The casing property of faker.string.alpha() and faker.string.alphanumeric() must be one of 'upper' | 'lower' | 'mixed' if provided

matthewmayer avatar Jan 06 '24 16:01 matthewmayer

Per #2521 suggest adding the following to docs/guide/upgrading_v9/2508.md:

Added. Thanks for the suggestion.

ST-DDT avatar Feb 08 '24 19:02 ST-DDT

Ready for review.

ST-DDT avatar Feb 08 '24 19:02 ST-DDT

Switched to strategy pattern. Ready to review.

ST-DDT avatar Feb 19 '24 20:02 ST-DDT