Skip to content

Commit 35f1926

Browse files
authored
Add prettier (#222)
1 parent da2801a commit 35f1926

23 files changed

+622
-724
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"bracketSpacing": false,
5+
"jsxBracketSameLine": true
6+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"scripts": {
3030
"prepublish": "./resources/prepublish.sh",
31+
"prettier": "find src -name '*.js' | xargs prettier --write",
3132
"test": "npm run lint && npm run check && npm run testonly",
3233
"testonly": "babel-node ./node_modules/.bin/_mocha $npm_package_options_mocha",
3334
"lint": "eslint src",
@@ -75,6 +76,7 @@
7576
"graphql": "^14.0.2",
7677
"isparta": "4.1.0",
7778
"mocha": "^5.2.0",
79+
"prettier": "^1.16.0",
7880
"sane": "^2.5.2"
7981
}
8082
}

src/__tests__/starWarsConnectionTests.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* @flow
88
*/
99

10-
import { expect } from 'chai';
11-
import { describe, it } from 'mocha';
12-
import { StarWarsSchema } from './starWarsSchema.js';
13-
import { graphql } from 'graphql';
10+
import {expect} from 'chai';
11+
import {describe, it} from 'mocha';
12+
import {StarWarsSchema} from './starWarsSchema.js';
13+
import {graphql} from 'graphql';
1414

1515
// 80+ char lines are useful in describe/it, so ignore in this file.
1616
/* eslint-disable max-len */
@@ -38,15 +38,15 @@ describe('Star Wars connections', () => {
3838
edges: [
3939
{
4040
node: {
41-
name: 'X-Wing'
42-
}
43-
}
44-
]
45-
}
46-
}
41+
name: 'X-Wing',
42+
},
43+
},
44+
],
45+
},
46+
},
4747
};
4848
const result = await graphql(StarWarsSchema, query);
49-
expect(result).to.deep.equal({ data: expected });
49+
expect(result).to.deep.equal({data: expected});
5050
});
5151

5252
it('fetches the first two ships of the rebels with a cursor', async () => {
@@ -73,21 +73,21 @@ describe('Star Wars connections', () => {
7373
{
7474
cursor: 'YXJyYXljb25uZWN0aW9uOjA=',
7575
node: {
76-
name: 'X-Wing'
77-
}
76+
name: 'X-Wing',
77+
},
7878
},
7979
{
8080
cursor: 'YXJyYXljb25uZWN0aW9uOjE=',
8181
node: {
82-
name: 'Y-Wing'
83-
}
84-
}
85-
]
86-
}
87-
}
82+
name: 'Y-Wing',
83+
},
84+
},
85+
],
86+
},
87+
},
8888
};
8989
const result = await graphql(StarWarsSchema, query);
90-
expect(result).to.deep.equal({ data: expected });
90+
expect(result).to.deep.equal({data: expected});
9191
});
9292

9393
it('fetches the next three ships of the rebels with a cursor', async () => {
@@ -114,27 +114,27 @@ describe('Star Wars connections', () => {
114114
{
115115
cursor: 'YXJyYXljb25uZWN0aW9uOjI=',
116116
node: {
117-
name: 'A-Wing'
118-
}
117+
name: 'A-Wing',
118+
},
119119
},
120120
{
121121
cursor: 'YXJyYXljb25uZWN0aW9uOjM=',
122122
node: {
123-
name: 'Millenium Falcon'
124-
}
123+
name: 'Millenium Falcon',
124+
},
125125
},
126126
{
127127
cursor: 'YXJyYXljb25uZWN0aW9uOjQ=',
128128
node: {
129-
name: 'Home One'
130-
}
131-
}
132-
]
133-
}
134-
}
129+
name: 'Home One',
130+
},
131+
},
132+
],
133+
},
134+
},
135135
};
136136
const result = await graphql(StarWarsSchema, query);
137-
expect(result).to.deep.equal({ data: expected });
137+
expect(result).to.deep.equal({data: expected});
138138
});
139139

140140
it('fetches no ships of the rebels at the end of connection', async () => {
@@ -157,12 +157,12 @@ describe('Star Wars connections', () => {
157157
rebels: {
158158
name: 'Alliance to Restore the Republic',
159159
ships: {
160-
edges: []
161-
}
162-
}
160+
edges: [],
161+
},
162+
},
163163
};
164164
const result = await graphql(StarWarsSchema, query);
165-
expect(result).to.deep.equal({ data: expected });
165+
expect(result).to.deep.equal({data: expected});
166166
});
167167

168168
it('identifies the end of the list', async () => {
@@ -200,44 +200,44 @@ describe('Star Wars connections', () => {
200200
edges: [
201201
{
202202
node: {
203-
name: 'X-Wing'
204-
}
203+
name: 'X-Wing',
204+
},
205205
},
206206
{
207207
node: {
208-
name: 'Y-Wing'
209-
}
210-
}
208+
name: 'Y-Wing',
209+
},
210+
},
211211
],
212212
pageInfo: {
213-
hasNextPage: true
214-
}
213+
hasNextPage: true,
214+
},
215215
},
216216
moreShips: {
217217
edges: [
218218
{
219219
node: {
220-
name: 'A-Wing'
221-
}
220+
name: 'A-Wing',
221+
},
222222
},
223223
{
224224
node: {
225-
name: 'Millenium Falcon'
226-
}
225+
name: 'Millenium Falcon',
226+
},
227227
},
228228
{
229229
node: {
230-
name: 'Home One'
231-
}
232-
}
230+
name: 'Home One',
231+
},
232+
},
233233
],
234234
pageInfo: {
235-
hasNextPage: false
236-
}
237-
}
238-
}
235+
hasNextPage: false,
236+
},
237+
},
238+
},
239239
};
240240
const result = await graphql(StarWarsSchema, query);
241-
expect(result).to.deep.equal({ data: expected });
241+
expect(result).to.deep.equal({data: expected});
242242
});
243243
});

src/__tests__/starWarsData.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@ const executor = {
5858
const rebels = {
5959
id: '1',
6060
name: 'Alliance to Restore the Republic',
61-
ships: [ '1', '2', '3', '4', '5' ]
61+
ships: ['1', '2', '3', '4', '5'],
6262
};
6363

6464
const empire = {
6565
id: '2',
6666
name: 'Galactic Empire',
67-
ships: [ '6', '7', '8' ]
67+
ships: ['6', '7', '8'],
6868
};
6969

7070
const data = {
7171
Faction: {
7272
'1': rebels,
73-
'2': empire
73+
'2': empire,
7474
},
7575
Ship: {
7676
'1': xwing,
@@ -80,15 +80,15 @@ const data = {
8080
'5': homeOne,
8181
'6': tieFighter,
8282
'7': tieInterceptor,
83-
'8': executor
84-
}
83+
'8': executor,
84+
},
8585
};
8686

8787
let nextShip = 9;
8888
export function createShip(shipName, factionId) {
8989
const newShip = {
9090
id: String(nextShip++),
91-
name: shipName
91+
name: shipName,
9292
};
9393
data.Ship[newShip.id] = newShip;
9494
data.Faction[factionId].ships.push(newShip.id);

src/__tests__/starWarsMutationTests.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* @flow
88
*/
99

10-
import { expect } from 'chai';
11-
import { describe, it } from 'mocha';
12-
import { StarWarsSchema } from './starWarsSchema.js';
13-
import { graphql } from 'graphql';
10+
import {expect} from 'chai';
11+
import {describe, it} from 'mocha';
12+
import {StarWarsSchema} from './starWarsSchema.js';
13+
import {graphql} from 'graphql';
1414

1515
// 80+ char lines are useful in describe/it, so ignore in this file.
1616
/* eslint-disable max-len */
@@ -36,21 +36,21 @@ describe('Star Wars mutations', () => {
3636
shipName: 'B-Wing',
3737
factionId: '1',
3838
clientMutationId: 'abcde',
39-
}
39+
},
4040
};
4141
const expected = {
4242
introduceShip: {
4343
ship: {
4444
id: 'U2hpcDo5',
45-
name: 'B-Wing'
45+
name: 'B-Wing',
4646
},
4747
faction: {
48-
name: 'Alliance to Restore the Republic'
48+
name: 'Alliance to Restore the Republic',
4949
},
5050
clientMutationId: 'abcde',
51-
}
51+
},
5252
};
5353
const result = await graphql(StarWarsSchema, mutation, null, null, params);
54-
expect(result).to.deep.equal({ data: expected });
54+
expect(result).to.deep.equal({data: expected});
5555
});
5656
});

src/__tests__/starWarsObjectIdentificationTests.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* @flow
88
*/
99

10-
import { expect } from 'chai';
11-
import { describe, it } from 'mocha';
12-
import { StarWarsSchema } from './starWarsSchema.js';
13-
import { graphql } from 'graphql';
10+
import {expect} from 'chai';
11+
import {describe, it} from 'mocha';
12+
import {StarWarsSchema} from './starWarsSchema.js';
13+
import {graphql} from 'graphql';
1414

1515
// 80+ char lines are useful in describe/it, so ignore in this file.
1616
/* eslint-disable max-len */
@@ -28,11 +28,11 @@ describe('Star Wars object identification', () => {
2828
const expected = {
2929
rebels: {
3030
id: 'RmFjdGlvbjox',
31-
name: 'Alliance to Restore the Republic'
32-
}
31+
name: 'Alliance to Restore the Republic',
32+
},
3333
};
3434
const result = await graphql(StarWarsSchema, query);
35-
expect(result).to.deep.equal({ data: expected });
35+
expect(result).to.deep.equal({data: expected});
3636
});
3737

3838
it('refetches the rebels', async () => {
@@ -49,11 +49,11 @@ describe('Star Wars object identification', () => {
4949
const expected = {
5050
node: {
5151
id: 'RmFjdGlvbjox',
52-
name: 'Alliance to Restore the Republic'
53-
}
52+
name: 'Alliance to Restore the Republic',
53+
},
5454
};
5555
const result = await graphql(StarWarsSchema, query);
56-
expect(result).to.deep.equal({ data: expected });
56+
expect(result).to.deep.equal({data: expected});
5757
});
5858

5959
it('fetches the ID and name of the empire', async () => {
@@ -68,11 +68,11 @@ describe('Star Wars object identification', () => {
6868
const expected = {
6969
empire: {
7070
id: 'RmFjdGlvbjoy',
71-
name: 'Galactic Empire'
72-
}
71+
name: 'Galactic Empire',
72+
},
7373
};
7474
const result = await graphql(StarWarsSchema, query);
75-
expect(result).to.deep.equal({ data: expected });
75+
expect(result).to.deep.equal({data: expected});
7676
});
7777

7878
it('refetches the empire', async () => {
@@ -89,11 +89,11 @@ describe('Star Wars object identification', () => {
8989
const expected = {
9090
node: {
9191
id: 'RmFjdGlvbjoy',
92-
name: 'Galactic Empire'
93-
}
92+
name: 'Galactic Empire',
93+
},
9494
};
9595
const result = await graphql(StarWarsSchema, query);
96-
expect(result).to.deep.equal({ data: expected });
96+
expect(result).to.deep.equal({data: expected});
9797
});
9898

9999
it('refetches the X-Wing', async () => {
@@ -110,10 +110,10 @@ describe('Star Wars object identification', () => {
110110
const expected = {
111111
node: {
112112
id: 'U2hpcDox',
113-
name: 'X-Wing'
114-
}
113+
name: 'X-Wing',
114+
},
115115
};
116116
const result = await graphql(StarWarsSchema, query);
117-
expect(result).to.deep.equal({ data: expected });
117+
expect(result).to.deep.equal({data: expected});
118118
});
119119
});

0 commit comments

Comments
 (0)