typescript implement of thrift-fmt
https://github.com/thrift-labs/thrift-fmt
typescript parser thrift-parser-ts
https://github.com/thrift-labs/thrift-parser/tree/master/typescript
import { ThriftData } from 'thrift-parser-ts';
import { ThriftFormatter, newOption } from 'thrift-fmt-ts'
const thrift = ThriftData.fromString(`const string name="hello"//hello`);
const fmt = new ThriftFormatter(thrift);
fmt.option(newOption({keepComment: true, alignByAssign: true}));
const content = fmt.format();
// const string name = "hello" // hello
console.log(content);
- keep and align all comments
- patch list separator
- patch missed field's
required
flag - align by the field's assign (like go)
- align by each field's part
- format only part of the parsed thrift
used by https://github.com/thrift-labs/thrift-fmt-vscode
some thrift files in fixtures thrift was copy from https://github.com/apache/thrift/blob/master/tutorial/ , The Apache LICENSE
the Thrift.g4 in thrift-parser package was copy from https://github.com/antlr/grammars-v4