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.
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'
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.
Released under the MIT License