Skip to content

Commit

Permalink
Remove prettier formatting (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
shYkiSto authored Aug 2, 2023
1 parent 7db6c89 commit 567a5aa
Show file tree
Hide file tree
Showing 17 changed files with 544 additions and 417 deletions.
7 changes: 0 additions & 7 deletions flow-typed/npm/prettier_vx.x.x.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thrift2flow",
"version": "0.11.5",
"version": "0.12.0",
"description": "Convert Thrift definitions to Flowtype declarations",
"homepage": "https://github.com/uber-node/thrift2flow",
"bugs": {
Expand Down Expand Up @@ -43,7 +43,6 @@
"babel-polyfill": "^6.23.0",
"common-path-prefix": "^1.0.0",
"mkdirp": "^0.5.1",
"prettier": "^1.14.2",
"source-map-support": "^0.4.15",
"thriftrw": "^3.11.0",
"uuid": "^3.3.2",
Expand All @@ -68,6 +67,7 @@
"flow-bin": "^0.94.0",
"fs-extra": "^4.0.3",
"jest": "^24.1.0",
"prettier": "^1.14.2",
"tmp": "^0.0.33"
}
}
24 changes: 12 additions & 12 deletions src/__tests__/__snapshots__/enums.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ exports[`enum to JS 1`] = `
"// @flow
export const MyEnum: $ReadOnly<{|
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
|}> = Object.freeze({
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
});
"
`;
Expand All @@ -17,19 +17,19 @@ exports[`enums work with typedefs 1`] = `
"// @flow
export const MyEnum: $ReadOnly<{|
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
|}> = Object.freeze({
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
});
export const MyOtherEnum: $ReadOnly<{|
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
|}> = Object.freeze({
OK: \\"OK\\",
ERROR: \\"ERROR\\"
'OK': 'OK',
'ERROR': 'ERROR',
});
"
`;
28 changes: 15 additions & 13 deletions src/__tests__/buffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ test('See how thriftrw decodes js.type i64', () => {
expect(thrift.MY_BUFF).toEqual(10);
const converter = new ThriftFileConverter(fixturePath, false);
expect(converter.generateFlowFile()).toMatchInlineSnapshot(`
"// @flow
"// @flow
export const MY_BUFF: 10 = 10;
"
`);
export const MY_BUFF: 10 = 10;
"
`);
});

test('Try using the toBufferResult fromBufferResult when parsing a struct with an i64 value', () => {
Expand All @@ -56,11 +56,13 @@ test('Try using the toBufferResult fromBufferResult when parsing a struct with a
expect(Buffer.isBuffer(structAgain.value.myProp)).toBeTruthy();
const converter = new ThriftFileConverter(fixturePath, false);
expect(converter.generateFlowFile()).toMatchInlineSnapshot(`
"// @flow
"// @flow
export type MyStruct = {| myProp: number | Buffer |};
"
`);
export type MyStruct = {|
myProp: (number | Buffer),
|};
"
`);
});

test('Ensure flow uses number not buffer for i64', () => {
Expand All @@ -72,11 +74,11 @@ test('Ensure flow uses number not buffer for i64', () => {
expect(thrift.NULL_ID).toEqual(0);
const converter = new ThriftFileConverter(fixturePath, false);
expect(converter.generateFlowFile()).toMatchInlineSnapshot(`
"// @flow
"// @flow
export type MY_ID = number | Buffer;
export type MY_ID = (number | Buffer);
export const NULL_ID: MY_ID = 0;
"
`);
export const NULL_ID: MY_ID = 0;
"
`);
});
44 changes: 22 additions & 22 deletions src/__tests__/consts/const-lists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ test('const map values are numbers', () => {
);
const jsContent = converter.generateFlowFile();
expect(jsContent).toMatchInlineSnapshot(`
"// @flow
"// @flow
export const Direction: $ReadOnly<{|
LEFT: \\"LEFT\\",
RIGHT: \\"RIGHT\\"
|}> = Object.freeze({
LEFT: \\"LEFT\\",
RIGHT: \\"RIGHT\\"
});
export const Direction: $ReadOnly<{|
'LEFT': 'LEFT',
'RIGHT': 'RIGHT',
|}> = Object.freeze({
'LEFT': 'LEFT',
'RIGHT': 'RIGHT',
});
export const DIRECTIONS: $Values<typeof Direction>[] = [
Direction.LEFT,
Direction.RIGHT,
Direction.LEFT,
Direction.RIGHT
];
export const DIRECTIONS: $Values<typeof Direction>[] = [
Direction.LEFT,
Direction.RIGHT,
Direction.LEFT,
Direction.RIGHT,
];
export const DIRECTIONS_LIST: $Values<typeof Direction>[] = [
Direction.LEFT,
Direction.RIGHT,
Direction.LEFT,
Direction.RIGHT
];
"
`);
export const DIRECTIONS_LIST: $Values<typeof Direction>[] = [
Direction.LEFT,
Direction.RIGHT,
Direction.LEFT,
Direction.RIGHT,
];
"
`);
});
21 changes: 12 additions & 9 deletions src/__tests__/consts/const-map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ test('convert const map witth enums', () => {
expect(thrift.USER_TYPES.user).toEqual(true);
const jsContent = converter.generateFlowFile();
expect(jsContent).toMatchInlineSnapshot(`
"// @flow
"// @flow
export const ADMIN_FOOO: \\"admin\\" = \\"admin\\";
export const ADMIN_FOOO: 'admin' = 'admin';
export const USER_BAAAR: \\"user\\" = \\"user\\";
export const USER_BAAAR: 'user' = 'user';
export const USER_TYPES: $ReadOnly<{| admin: boolean, user: boolean |}> = {
[ADMIN_FOOO]: true,
[USER_BAAAR]: true
};
"
`);
export const USER_TYPES: $ReadOnly<{|
'admin': boolean,
'user': boolean,
|}> = {
[ADMIN_FOOO]: true,
[USER_BAAAR]: true,
};
"
`);
});
153 changes: 86 additions & 67 deletions src/__tests__/consts/consts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ test('const string literals', () => {
);
const jsContent = converter.generateFlowFile();
expect(jsContent).toMatchInlineSnapshot(`
"// @flow
"// @flow
export const A_STRING_LITERAL: \\"my-string-literal-value\\" =
\\"my-string-literal-value\\";
"
`);
export const A_STRING_LITERAL: 'my-string-literal-value' = 'my-string-literal-value';
"
`);
});

test('const map values are numbers', () => {
Expand All @@ -67,49 +66,69 @@ test('const map values are numbers', () => {
);
const jsContent = converter.generateFlowFile();
expect(jsContent).toMatchInlineSnapshot(`
"// @flow
export const ShieldType: $ReadOnly<{|
O: \\"O\\",
U: \\"U\\"
|}> = Object.freeze({
O: \\"O\\",
U: \\"U\\"
});
export const o: \\"ooooooo\\" = \\"ooooooo\\";
export const PRIORITIES: $ReadOnly<{| O: number, U: number |}> = {
[ShieldType.O]: 2,
[ShieldType.U]: 10
};
export const LABELS: $ReadOnly<{| O: string, U: string |}> = {
[ShieldType.O]: o,
[ShieldType.U]: \\"uuuuuuu\\"
};
export const THINGS: $ReadOnly<{| O: string[], U: string[] |}> = {
[ShieldType.O]: [o, \\"abcd\\"],
[ShieldType.U]: [\\"uuuuuuu\\"]
};
export const ITEMS: $Values<typeof ShieldType>[] = [ShieldType.O, ShieldType.U];
export const MAP_CONST_LIST: $ReadOnly<{|
O: $Values<typeof ShieldType>[],
U: $Values<typeof ShieldType>[]
|}> = {
[ShieldType.O]: ITEMS,
[ShieldType.U]: []
};
export const NUMS: $ReadOnly<{| \\"0\\": string, \\"1\\": string |}> = {
\\"0\\": \\"aaa\\",
\\"1\\": \\"bbb\\"
};
"
`);
"// @flow
export const ShieldType: $ReadOnly<{|
'O': 'O',
'U': 'U',
|}> = Object.freeze({
'O': 'O',
'U': 'U',
});
export const o: 'ooooooo' = 'ooooooo';
export const PRIORITIES: $ReadOnly<{|
'O': number,
'U': number,
|}> = {
[ShieldType.O]: 2,
[ShieldType.U]: 10,
};
export const LABELS: $ReadOnly<{|
'O': string,
'U': string,
|}> = {
[ShieldType.O]: o,
[ShieldType.U]: 'uuuuuuu',
};
export const THINGS: $ReadOnly<{|
'O': string[],
'U': string[],
|}> = {
[ShieldType.O]: [
o,
\\"abcd\\",
],
[ShieldType.U]: [
\\"uuuuuuu\\",
],
};
export const ITEMS: $Values<typeof ShieldType>[] = [
ShieldType.O,
ShieldType.U,
];
export const MAP_CONST_LIST: $ReadOnly<{|
'O': $Values<typeof ShieldType>[],
'U': $Values<typeof ShieldType>[],
|}> = {
[ShieldType.O]: ITEMS,
[ShieldType.U]: [],
};
export const NUMS: $ReadOnly<{|
'0': string,
'1': string,
|}> = {
'0': 'aaa',
'1': 'bbb',
};
"
`);
});

test('constant enum values', () => {
Expand All @@ -119,23 +138,23 @@ test('constant enum values', () => {
);
const jsContent = converter.generateFlowFile();
expect(jsContent).toMatchInlineSnapshot(`
"// @flow
export const PlaceType: $ReadOnly<{|
A: \\"A\\",
B: \\"B\\"
|}> = Object.freeze({
A: \\"A\\",
B: \\"B\\"
});
export const UUID_TO_PLACE_TYPE: $ReadOnly<{|
\\"123\\": $Values<typeof PlaceType>,
\\"456\\": $Values<typeof PlaceType>
|}> = {
\\"123\\": PlaceType.A,
\\"456\\": PlaceType.B
};
"
`);
"// @flow
export const PlaceType: $ReadOnly<{|
'A': 'A',
'B': 'B',
|}> = Object.freeze({
'A': 'A',
'B': 'B',
});
export const UUID_TO_PLACE_TYPE: $ReadOnly<{|
'123': $Values<typeof PlaceType>,
'456': $Values<typeof PlaceType>,
|}> = {
'123': PlaceType.A,
'456': PlaceType.B,
};
"
`);
});
Loading

0 comments on commit 567a5aa

Please sign in to comment.