kentcdodds / webpack-validator-DEPRECATED

Use this to save yourself some time when working on a webpack configuration.
MIT License
93 stars 8 forks source link

Experiment with refactoring stats #58

Closed jonathanglasmeyer closed 8 years ago

jonathanglasmeyer commented 8 years ago

So i got an itch to play around with the @kentcdodds stats implementation from yesterday. Although I agree that reducing can lead to elegant code, something with the pattern of returning string constants bugs me, it seems such a "non-standard" way of doing things. So, without having any serious intention of wanting to change this, i had to try out if there is a different way to express the inherent logic. I found that using lodash find is pretty nice for the case of multiple validators. Just have a look. We can totally throw this branch away if we don't like this, but maybe it's an inspiration or whatever. ;)

I personally think that the cognitive load is decreased writing it like this, it feels more declarative whereas the CONTINUE / BREAK implementation feels a little imperative to me. I particulary like using the undefined return value of passing validators instead of explicitly returning CONTINUE every time.

Have a nice saturday!

codecov-io commented 8 years ago

Current coverage is 100.00%

Merging #58 into master will not affect coverage as of f6e166e

@@            master     #58   diff @@
======================================
  Files           34      34       
  Stmts          285     264    -21
  Branches         0       0       
  Methods          0       0       
======================================
- Hit            285     264    -21
  Partial          0       0       
  Missed           0       0       

Review entire Coverage Diff as of f6e166e

Powered by Codecov. Updated on successful CI builds.