esformatter-flow
v1.0.1
Published
esformatter plugin to format Flow type annotations
Downloads
43
Maintainers
Readme
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 [email protected]
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