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 building the browser library with Webpack.

Proper linting solves a lot of issues, and xo is a nice tool that does most of the work. It has an Atom plugin and can enforce eslint rules as well. Plenty of improvements have been made to the language since ES6.

Unit tests matter just as much. I used ava and its Atom plugin to write basic type-checking tests first, then gradually added more functional ones.

Packaging for NPM

The keys to success are:

  • Writing a clean README file
  • Using a logo and badges to signal that the library is actively maintained

Refactoring for good

Once this safety net is in place, the refactoring itself is easy:

  • Splitting the files into classes
  • Cleaning up code smells (for loops, linting errors)
  • Moving to a functional style, which makes the code easier to read and to maintain

Now the library can evolve and use ES6 syntactic sugar; spread operators and generators are particularly useful here. 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 is from the Tango Fundamentals course: no ocho, no molinete, just a pure, elegant walk. The song 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.