Shopify / javascript

The home for all things JavaScript at Shopify.
MIT License
251 stars 38 forks source link

Fix missing switch/case returns in `channel-dashboard` #101

Closed GoodForOneFare closed 8 years ago

GoodForOneFare commented 8 years ago

channel-dashboard.coffee contains this switch statement:

  _dateFieldForDays: (days) ->
    switch
      when days == 0 then 'hour'
      when days < 90 then 'day'
      when days < 365 then 'week'
      else 'month'

This is translated to JS that's missing returns:

  _dateFieldForDays(days) {
    return (() => {
      switch (false) {
      case !(days === 0):
        'hour';
        break;
      case !(days < 90):
        'day';
        break;
      case !(days < 365):
        'week';
        break;
      default:
        'month';
      }
    })();
GoodForOneFare commented 8 years ago

Quick decaf runthrough suggests it's the source of the problem.

GoodForOneFare commented 8 years ago

Other likely sources of broken switch transforms:

show-report.js
engagement-feature.js
change-theme-language-modal.js
file-selector.js
GoodForOneFare commented 8 years ago

Fixed by mainline decaf merge. Raised #156 to improve the output of some switches.