Skip to content

Commit 5eeb021

Browse files
committed
Update prettier and sync up its config with graphql-js
1 parent ecc478e commit 5eeb021

27 files changed

+261
-250
lines changed

.babelrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
"transform-es2015-function-name",
1010
"transform-es2015-arrow-functions",
1111
"transform-es2015-block-scoped-functions",
12-
["transform-es2015-classes", {loose: true}],
12+
["transform-es2015-classes", { "loose": true }],
1313
"transform-es2015-object-super",
1414
"transform-es2015-shorthand-properties",
1515
"transform-es2015-duplicate-keys",
1616
"transform-es2015-computed-properties",
1717
"check-es2015-constants",
18-
["transform-es2015-spread", {loose: true}],
18+
["transform-es2015-spread", { "loose": true }],
1919
"transform-es2015-parameters",
20-
["transform-es2015-destructuring", {loose: true}],
20+
["transform-es2015-destructuring", { "loose": true }],
2121
"transform-es2015-block-scoping",
2222
"transform-es2015-modules-commonjs",
23-
"transform-regenerator",
23+
"transform-regenerator"
2424
]
2525
}

.eslintrc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"parser": "babel-eslint",
33

4-
"plugins": [
5-
"babel",
6-
"flowtype"
7-
],
4+
"plugins": ["babel", "flowtype"],
85

96
"env": {
107
"es6": true,
@@ -16,16 +13,16 @@
1613
"flowtype/space-before-type-colon": [2, "never"],
1714
"flowtype/space-before-generic-bracket": [2, "never"],
1815
"flowtype/union-intersection-spacing": [2, "always"],
19-
"flowtype/no-weak-types": [2, {"any": false}],
16+
"flowtype/no-weak-types": [2, { "any": false }],
2017
"flowtype/define-flow-type": 2,
2118
"flowtype/use-flow-type": 2,
2219
"flowtype/semi": 2,
2320

2421
"arrow-spacing": 2,
2522
"block-scoped-var": 0,
26-
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
23+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
2724
"callback-return": 2,
28-
"camelcase": [2, {"properties": "always"}],
25+
"camelcase": [2, { "properties": "always" }],
2926
"comma-dangle": 0,
3027
"comma-spacing": 0,
3128
"comma-style": [2, "last"],
@@ -41,13 +38,13 @@
4138
"eqeqeq": 2,
4239
"func-names": 0,
4340
"func-style": 0,
44-
"generator-star-spacing": [2, {"before": true, "after": false}],
41+
"generator-star-spacing": [2, { "before": true, "after": false }],
4542
"guard-for-in": 2,
4643
"handle-callback-err": [2, "error"],
4744
"id-length": 0,
4845
"id-match": [2, "^(?:_?[a-zA-Z0-9]*)|[_A-Z0-9]+$"],
4946
"init-declarations": 0,
50-
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
47+
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
5148
"keyword-spacing": 2,
5249
"linebreak-style": 2,
5350
"lines-around-comment": 0,
@@ -101,7 +98,7 @@
10198
"no-irregular-whitespace": 2,
10299
"no-iterator": 2,
103100
"no-label-var": 2,
104-
"no-labels": [2, {"allowLoop": true}],
101+
"no-labels": [2, { "allowLoop": true }],
105102
"no-lone-blocks": 2,
106103
"no-lonely-if": 2,
107104
"no-loop-func": 0,
@@ -151,7 +148,7 @@
151148
"no-unneeded-ternary": 2,
152149
"no-unreachable": 2,
153150
"no-unused-expressions": 2,
154-
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
151+
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
155152
"no-use-before-define": 0,
156153
"no-useless-call": 2,
157154
"no-useless-escape": 2,
@@ -168,17 +165,20 @@
168165
"prefer-const": 2,
169166
"prefer-reflect": 0,
170167
"prefer-spread": 0,
171-
"quote-props": [2, "as-needed", {"numbers": true}],
168+
"quote-props": [2, "as-needed", { "numbers": true }],
172169
"radix": 2,
173170
"require-yield": 2,
174171
"semi": [2, "always"],
175-
"semi-spacing": [2, {"before": false, "after": true}],
172+
"semi-spacing": [2, { "before": false, "after": true }],
176173
"sort-vars": 0,
177174
"space-before-blocks": [2, "always"],
178-
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
175+
"space-before-function-paren": [
176+
2,
177+
{ "anonymous": "always", "named": "never" }
178+
],
179179
"space-in-parens": 0,
180-
"space-infix-ops": [2, {"int32Hint": false}],
181-
"space-unary-ops": [2, {"words": true, "nonwords": false}],
180+
"space-infix-ops": [2, { "int32Hint": false }],
181+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
182182
"spaced-comment": [2, "always"],
183183
"strict": 0,
184184
"use-isnan": 2,
@@ -187,6 +187,6 @@
187187
"vars-on-top": 0,
188188
"wrap-iife": 2,
189189
"wrap-regex": 0,
190-
"yoda": [2, "never", {"exceptRange": true}]
190+
"yoda": [2, "never", { "exceptRange": true }]
191191
}
192192
}

.prettierrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"singleQuote": true,
3-
"trailingComma": "es5",
4-
"bracketSpacing": false,
5-
"jsxBracketSameLine": true
3+
"trailingComma": "all"
64
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ before_install:
1616
- npm config set spin false --global
1717

1818
script:
19-
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then npm run lint && npm run check && npm run cover:lcov; else npm run testonly; fi
19+
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then npm run prettier:check && npm run lint && npm run check && npm run cover:lcov; else npm run testonly; fi
2020

2121
after_success:
2222
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Contributing
2-
============
1+
# Contributing
32

43
After cloning this repo, ensure dependencies are installed by running:
54

README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,21 @@ Helper functions are provided for both building the GraphQL types for connection
4242
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
4343

4444
```js
45-
var {connectionType: ShipConnection} =
46-
connectionDefinitions({nodeType: shipType});
45+
var { connectionType: ShipConnection } = connectionDefinitions({
46+
nodeType: shipType,
47+
});
4748
var factionType = new GraphQLObjectType({
4849
name: 'Faction',
4950
fields: () => ({
5051
ships: {
5152
type: ShipConnection,
5253
args: connectionArgs,
53-
resolve: (faction, args) => connectionFromArray(
54-
faction.ships.map((id) => data.Ship[id]),
55-
args
56-
),
57-
}
54+
resolve: (faction, args) =>
55+
connectionFromArray(
56+
faction.ships.map((id) => data.Ship[id]),
57+
args,
58+
),
59+
},
5860
}),
5961
});
6062
```
@@ -65,38 +67,38 @@ This shows adding a `ships` field to the `Faction` object that is a connection.
6567

6668
Helper functions are provided for both building the GraphQL types for nodes and for implementing global IDs around local IDs.
6769

68-
- `nodeDefinitions` returns the `Node` interface that objects can implement, and returns the `node` root field to include on the query type. To implement this, it takes a function to resolve an ID to an object, and to determine the type of a given object.
69-
- `toGlobalId` takes a type name and an ID specific to that type name, and returns a "global ID" that is unique among all types.
70-
- `fromGlobalId` takes the "global ID" created by `toGlobalID`, and returns the type name and ID used to create it.
71-
- `globalIdField` creates the configuration for an `id` field on a node.
72-
- `pluralIdentifyingRootField` creates a field that accepts a list of non-ID identifiers (like a username) and maps them to their corresponding objects.
70+
- `nodeDefinitions` returns the `Node` interface that objects can implement, and returns the `node` root field to include on the query type. To implement this, it takes a function to resolve an ID to an object, and to determine the type of a given object.
71+
- `toGlobalId` takes a type name and an ID specific to that type name, and returns a "global ID" that is unique among all types.
72+
- `fromGlobalId` takes the "global ID" created by `toGlobalID`, and returns the type name and ID used to create it.
73+
- `globalIdField` creates the configuration for an `id` field on a node.
74+
- `pluralIdentifyingRootField` creates a field that accepts a list of non-ID identifiers (like a username) and maps them to their corresponding objects.
7375

7476
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
7577

7678
```js
77-
var {nodeInterface, nodeField} = nodeDefinitions(
79+
var { nodeInterface, nodeField } = nodeDefinitions(
7880
(globalId) => {
79-
var {type, id} = fromGlobalId(globalId);
81+
var { type, id } = fromGlobalId(globalId);
8082
return data[type][id];
8183
},
8284
(obj) => {
8385
return obj.ships ? factionType : shipType;
84-
}
86+
},
8587
);
8688

8789
var factionType = new GraphQLObjectType({
8890
name: 'Faction',
8991
fields: () => ({
9092
id: globalIdField(),
9193
}),
92-
interfaces: [nodeInterface]
94+
interfaces: [nodeInterface],
9395
});
9496

9597
var queryType = new GraphQLObjectType({
9698
name: 'Query',
9799
fields: () => ({
98-
node: nodeField
99-
})
100+
node: nodeField,
101+
}),
100102
});
101103
```
102104

@@ -106,7 +108,7 @@ This uses `nodeDefinitions` to construct the `Node` interface and the `node` fie
106108

107109
A helper function is provided for building mutations with single inputs and client mutation IDs.
108110

109-
- `mutationWithClientMutationId` takes a name, input fields, output fields, and a mutation method to map from the input fields to the output fields, performing the mutation along the way. It then creates and returns a field configuration that can be used as a top-level field on the mutation type.
111+
- `mutationWithClientMutationId` takes a name, input fields, output fields, and a mutation method to map from the input fields to the output fields, performing the mutation along the way. It then creates and returns a field configuration that can be used as a top-level field on the mutation type.
110112

111113
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
112114

@@ -115,41 +117,41 @@ var shipMutation = mutationWithClientMutationId({
115117
name: 'IntroduceShip',
116118
inputFields: {
117119
shipName: {
118-
type: new GraphQLNonNull(GraphQLString)
120+
type: new GraphQLNonNull(GraphQLString),
119121
},
120122
factionId: {
121-
type: new GraphQLNonNull(GraphQLID)
122-
}
123+
type: new GraphQLNonNull(GraphQLID),
124+
},
123125
},
124126
outputFields: {
125127
ship: {
126128
type: shipType,
127-
resolve: (payload) => data['Ship'][payload.shipId]
129+
resolve: (payload) => data['Ship'][payload.shipId],
128130
},
129131
faction: {
130132
type: factionType,
131-
resolve: (payload) => data['Faction'][payload.factionId]
132-
}
133+
resolve: (payload) => data['Faction'][payload.factionId],
134+
},
133135
},
134-
mutateAndGetPayload: ({shipName, factionId}) => {
136+
mutateAndGetPayload: ({ shipName, factionId }) => {
135137
var newShip = {
136138
id: getNewShipId(),
137-
name: shipName
139+
name: shipName,
138140
};
139141
data.Ship[newShip.id] = newShip;
140142
data.Faction[factionId].ships.push(newShip.id);
141143
return {
142144
shipId: newShip.id,
143145
factionId: factionId,
144146
};
145-
}
147+
},
146148
});
147149

148150
var mutationType = new GraphQLObjectType({
149151
name: 'Mutation',
150152
fields: () => ({
151-
introduceShip: shipMutation
152-
})
153+
introduceShip: shipMutation,
154+
}),
153155
});
154156
```
155157

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
},
2929
"scripts": {
3030
"prepublish": "./resources/prepublish.sh",
31-
"prettier": "find src -name '*.js' | xargs prettier --write",
32-
"test": "npm run lint && npm run check && npm run testonly",
31+
"prettier": "prettier --write --list-different .",
32+
"prettier:check": "prettier --check .",
33+
"test": "npm run lint && npm run check && npm run testonly && npm run prettier:check",
3334
"testonly": "babel-node ./node_modules/.bin/_mocha $npm_package_options_mocha",
3435
"lint": "eslint src",
3536
"check": "flow check",
@@ -76,7 +77,7 @@
7677
"graphql": "^14.1.1",
7778
"isparta": "4.1.0",
7879
"mocha": "^5.2.0",
79-
"prettier": "^1.19.1",
80+
"prettier": "2.0.5",
8081
"sane": "^2.5.2"
8182
}
8283
}

0 commit comments

Comments
 (0)