/depercolator

Tool for converting coffeescript to idiomatic javascript and JSX

Primary LanguageJavaScript

Depercolator CircleCI

This tool is a swiss army knife for converting coffeescript files to javascript. It relies on several other tools to ease the conversion process and create idiomatic javascript and JSX.

Learn more from our blog on converting our React codebase from CoffeeScript to ES6.

Installation

npm i -g depercolator

or

yarn global add depercolator

Usage

depercolate <file> [options]

Options

  • -o, --output [filepath]: Change path of resulting file (defaults to same path as original with a different extension)
  • --skip-prettier: Do not reformat the file with prettier (default is false)

Decaffeinate options

Most options from decaffeinate can be passed through to the underlying command

  • --keep-commonjs: Do not convert require and module.exports to import and export
  • --prefer-const: Use const when possible in output code
  • --loose-default-params: Convert CS default params to JS default params.
  • --loose-for-expressions: Do not wrap expression loop targets in Array.from
  • --loose-for-of: Do not wrap JS for...of loop targets in Array.from
  • --loose-includes: Do not wrap in Array.from when converting in to includes
  • --allow-invalid-constructors: Don't error when constructors use this before super or omit the super call in a subclass.
  • --enable-babel-constructor-workaround: Use a hacky babel-specific workaround to allow this before super in constructors.

Prettier options

Most options from prettier can be passed through to the underlying command

  • --print-width <int>: Specify the length of line that the formatter will wrap on. Defaults to 80.
  • --tab-width <int>: Specify the number of spaces per indentation-level. Defaults to 2.
  • --use-tabs: Indent lines with tabs instead of spaces. Defaults to false.
  • --single-quote: Use single quotes instead of double.
  • --trailing-comma: Print trailing commas wherever possible.
  • --bracket-spacing: Put spaces between brackets. Defaults to true.
  • --jsx-bracket-same-line: Put > on the last line. Defaults to false.
  • --parser <flow|babylon>: Specify which parse to use. Defaults to babylon.