It is quite easy to migrate from CoffeeScript to ES6. You can use decaffeinate Show archive.org snapshot to convert your CoffeeScript source to modern JavaScript.
Install decaffeinate globally:
npm install -g decaffeinate
Call decaffeinate
on each .coffee
file, relaxing some options to get the most modern (and concise) JS:
decaffeinate file.coffee --use-cs2 --loose --optional-chaining --logical-assignment
Tip
If you use Babel Show archive.org snapshot and see errors while decaffeinating, try deleting your
babel.config.js
, rundecaffeinate
, then restore the babel config file.
If your project uses eslint, have it fix style issues (like semicolons):
npx eslint --fix file.js
Decaffeinate will add some
suggestions
Show archive.org snapshot
to your newly generated JS file with advises that makes you JS cleaner. This action need to be done manually and carefully checked. In particular you will need to clean up a lot of unnecessary return
statements.