Refactoring a library in ES6

Some technical notes while refactoring a library in ES6.

I recently worked on a refactoring of Tracery and corresponding NPM package into this NPM package and browser library.

Initial build issues

The library had two repositories to maintain the same code.

I unified the build starting from the Node.js library and then build the browser library using Webpack.

Proper linting can solves lots of issues, xo is a nice tool that does most of the job. It has an atom plugin and can implement eslint rules as well. Lots of improvements to the language have been made since ES6.

Unit tests are important, I used ava and atom plugin to write basic typing verification tests first then gradually added more functional tests.

Packaging for NPM

Keys to success are:

  • Writing a clean README file
  • Use logo and badges to communicate to users that the library is actively maintained

Refactoring for good

Once this security net is set up, all the refactoring tasks are easy:

  • Splitting up the files into classes.
  • Cleaning bad smells (for loops, linting errors)
  • Functional style programming make the code easier to read and maintainable in the future.

Now the library can evolve and use ES6 sugar syntax, spread operators and generators are interesting for the matter. If you want to contribute please go to the GitHub repo

Some walking variations

Two videos from Fabian Salas and his partner Cecilia Gonzalez.

The first one is from the Tango Fundamentals course: no ocho, no molinete, just pure elegant walk. The song name is El pollito by Carlos di Sarli.

A public performance on the song Gallo Ciego by Osvaldo Pugliese.

I really liked the clearness of their moves and their sense of musicality.

Maximum efficiency with minimum effort.