Skip to content

Commit c1d795c

Browse files
authored
Prettier (#1112)
Closes #1081
1 parent 4a6c8ca commit c1d795c

File tree

169 files changed

+11624
-10601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+11624
-10601
lines changed

.eslintrc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
"plugins": [
55
"babel",
6-
"flowtype"
6+
"flowtype",
7+
"prettier"
78
],
89

910
"env": {
@@ -39,6 +40,8 @@
3940
},
4041

4142
"rules": {
43+
"prettier/prettier": 2,
44+
4245
"flowtype/space-after-type-colon": [2, "always"],
4346
"flowtype/space-before-type-colon": [2, "never"],
4447
"flowtype/space-before-generic-bracket": [2, "never"],
@@ -48,7 +51,6 @@
4851
"flowtype/use-flow-type": 2,
4952
"flowtype/semi": 2,
5053

51-
"array-bracket-spacing": [2, "always"],
5254
"arrow-parens": [2, "as-needed"],
5355
"arrow-spacing": 2,
5456
"block-scoped-var": 0,
@@ -70,7 +72,6 @@
7072
"eqeqeq": ["error", "smart"],
7173
"func-names": 0,
7274
"func-style": 0,
73-
"generator-star-spacing": [2, {"before": false, "after": true}],
7475
"guard-for-in": 2,
7576
"handle-callback-err": [2, "error"],
7677
"id-length": 0,
@@ -82,7 +83,10 @@
8283
"linebreak-style": 2,
8384
"lines-around-comment": 0,
8485
"max-depth": 0,
85-
"max-len": [2, 80, 4],
86+
"max-len": [2, 80, {
87+
"ignoreComments": true,
88+
"ignoreStrings": true
89+
}],
8690
"max-nested-callbacks": 0,
8791
"max-params": 0,
8892
"max-statements": 0,
@@ -194,20 +198,17 @@
194198
"object-shorthand": [2, "always"],
195199
"one-var": [2, "never"],
196200
"operator-assignment": [2, "always"],
197-
"operator-linebreak": [2, "after"],
198201
"padded-blocks": 0,
199202
"prefer-const": 2,
200203
"prefer-reflect": 0,
201204
"prefer-spread": 0,
202205
"quote-props": [2, "as-needed", {"numbers": true}],
203-
"quotes": [2, "single"],
204206
"radix": 2,
205207
"require-yield": 0,
206208
"semi": [2, "always"],
207209
"semi-spacing": [2, {"before": false, "after": true}],
208210
"sort-vars": 0,
209211
"space-before-blocks": [2, "always"],
210-
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
211212
"space-in-parens": 0,
212213
"space-infix-ops": [2, {"int32Hint": false}],
213214
"space-unary-ops": [2, {"words": true, "nonwords": false}],

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parser": "flow",
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ This will watch the file system run any relevant lint, tests, and type checks au
6969

7070
## Coding Style
7171

72+
This project uses [Prettier](https://prettier.io/) for standard formatting. To
73+
ensure your pull request matches the style guides, run `npm run prettier`.
74+
7275
* 2 spaces for indentation (no tabs)
7376
* 80 character line length strongly preferred.
7477
* Prefer `'` over `"`

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"testonly": "babel-node ./node_modules/.bin/_mocha $npm_package_options_mocha",
2727
"t": "babel-node ./node_modules/.bin/_mocha --require ./resources/mocha-bootload",
2828
"lint": "eslint --rulesdir ./resources/lint src || (printf '\\033[33mTry: \\033[7m npm run lint -- --fix \\033[0m\\n' && exit 1)",
29+
"prettier": "prettier --write 'src/**/*.js'",
2930
"check": "flow check",
3031
"check-cover": "for file in {src/*.js,src/**/*.js}; do echo $file; flow coverage $file; done",
3132
"build": "npm run build:clean && npm run build:npm && npm run build:npm-flow && npm run build:module && npm run build:module-flow",
@@ -62,9 +63,11 @@
6263
"eslint": "4.4.1",
6364
"eslint-plugin-babel": "4.1.2",
6465
"eslint-plugin-flowtype": "2.35.0",
66+
"eslint-plugin-prettier": "^2.3.1",
6567
"flow-bin": "^0.58.0",
6668
"isparta": "4.0.0",
6769
"mocha": "3.5.0",
70+
"prettier": "^1.8.2",
6871
"sane": "2.0.0"
6972
}
7073
}

src/__tests__/starWarsData.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,43 @@ const luke = {
1919
type: 'Human',
2020
id: '1000',
2121
name: 'Luke Skywalker',
22-
friends: [ '1002', '1003', '2000', '2001' ],
23-
appearsIn: [ 4, 5, 6 ],
22+
friends: ['1002', '1003', '2000', '2001'],
23+
appearsIn: [4, 5, 6],
2424
homePlanet: 'Tatooine',
2525
};
2626

2727
const vader = {
2828
type: 'Human',
2929
id: '1001',
3030
name: 'Darth Vader',
31-
friends: [ '1004' ],
32-
appearsIn: [ 4, 5, 6 ],
31+
friends: ['1004'],
32+
appearsIn: [4, 5, 6],
3333
homePlanet: 'Tatooine',
3434
};
3535

3636
const han = {
3737
type: 'Human',
3838
id: '1002',
3939
name: 'Han Solo',
40-
friends: [ '1000', '1003', '2001' ],
41-
appearsIn: [ 4, 5, 6 ],
40+
friends: ['1000', '1003', '2001'],
41+
appearsIn: [4, 5, 6],
4242
};
4343

4444
const leia = {
4545
type: 'Human',
4646
id: '1003',
4747
name: 'Leia Organa',
48-
friends: [ '1000', '1002', '2000', '2001' ],
49-
appearsIn: [ 4, 5, 6 ],
48+
friends: ['1000', '1002', '2000', '2001'],
49+
appearsIn: [4, 5, 6],
5050
homePlanet: 'Alderaan',
5151
};
5252

5353
const tarkin = {
5454
type: 'Human',
5555
id: '1004',
5656
name: 'Wilhuff Tarkin',
57-
friends: [ '1001' ],
58-
appearsIn: [ 4 ],
57+
friends: ['1001'],
58+
appearsIn: [4],
5959
};
6060

6161
const humanData = {
@@ -70,17 +70,17 @@ const threepio = {
7070
type: 'Droid',
7171
id: '2000',
7272
name: 'C-3PO',
73-
friends: [ '1000', '1002', '1003', '2001' ],
74-
appearsIn: [ 4, 5, 6 ],
73+
friends: ['1000', '1002', '1003', '2001'],
74+
appearsIn: [4, 5, 6],
7575
primaryFunction: 'Protocol',
7676
};
7777

7878
const artoo = {
7979
type: 'Droid',
8080
id: '2001',
8181
name: 'R2-D2',
82-
friends: [ '1000', '1002', '1003' ],
83-
appearsIn: [ 4, 5, 6 ],
82+
friends: ['1000', '1002', '1003'],
83+
appearsIn: [4, 5, 6],
8484
primaryFunction: 'Astromech',
8585
};
8686

@@ -115,7 +115,7 @@ export type Droid = {
115115
name: string,
116116
friends: Array<string>,
117117
appearsIn: Array<number>,
118-
primaryFunction: string
118+
primaryFunction: string,
119119
};
120120

121121
/**

0 commit comments

Comments
 (0)