1.0.1 • Published 8 years ago

esformatter-flow v1.0.1

Weekly downloads
14
License
MIT
Repository
github
Last release
8 years ago

esformatter-flow

esformatter plugin to format Flow type annotations

IMPORTANT: This plugin requires a parser that is able to handle Flow types (eg. Babylon); So it will only work with esformatter@0.9.0 and up.

usage

Install the plugin:

npm install esformatter-flow

Add to your esformatter config file:

{
  "plugins": [
    "esformatter-flow"
  ]
}

Or you can manually register the plugin if not using the esformatter command directly:

// register plugin
esformatter.register(require('esformatter-flow'));

Or even pass it as a command line argument:

esformatter --plugins=esformatter-flow,some-other-plugin 'foo.js'

example

Given this input program:

/* @flow */
function foo( a : string , b  : number)  : void {
  return a + b;
}
class Bar {
    y : string ;
  someMethod( a :number ): string {
  return a + foo('lorem', a);
  }
}

It will output:

/* @flow */
function foo(a: string, b: number): void {
  return a + b;
}
class Bar {
  y: string;
  someMethod(a: number): string {
    return a + foo('lorem', a);
  }
}

See files inside the test/compare folder for more examples of the supported features.

license

Released under the MIT License