Skip to content

Commit b1b4a2f

Browse files
authored
Merge pull request #9101 from sebmarkbage/prettier
Use Prettier
2 parents 2b59afb + 7e078d6 commit b1b4a2f

File tree

328 files changed

+12794
-11435
lines changed

Some content is hidden

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

328 files changed

+12794
-11435
lines changed

.eslintrc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
'dot-notation': ERROR,
2424
'eol-last': ERROR,
2525
'eqeqeq': [ERROR, 'allow-null'],
26-
'indent': [ERROR, 2, {SwitchCase: 1}],
26+
'indent': OFF,
2727
'jsx-quotes': [ERROR, 'prefer-double'],
2828
'keyword-spacing': [ERROR, {after: true, before: true}],
2929
'no-bitwise': OFF,
@@ -33,9 +33,10 @@ module.exports = {
3333
'no-shadow': ERROR,
3434
'no-unused-expressions': ERROR,
3535
'no-unused-vars': [ERROR, {args: 'none'}],
36+
'no-useless-concat': OFF,
3637
'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }],
3738
'space-before-blocks': ERROR,
38-
'space-before-function-paren': [ERROR, {anonymous: 'never', named: 'never'}],
39+
'space-before-function-paren': OFF,
3940

4041
// React & JSX
4142
// Our transforms set this automatically

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"merge-stream": "^1.0.0",
7272
"object-assign": "^4.1.1",
7373
"platform": "^1.1.0",
74+
"prettier": "^0.22.0",
7475
"run-sequence": "^1.1.4",
7576
"through2": "^2.0.0",
7677
"tmp": "~0.0.28",
@@ -92,7 +93,8 @@
9293
"lint": "grunt lint",
9394
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
9495
"test": "jest",
95-
"flow": "flow"
96+
"flow": "flow",
97+
"prettier": "prettier --write --no-bracket-spacing --single-quote --jsx-bracket-same-line --trailing-comma all --print-width 80 \"src/**/!(third_party)/*.js\""
9698
},
9799
"jest": {
98100
"modulePathIgnorePatterns": [

src/__mocks__/InitializeCore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
// Noop
1313

1414
// TODO #10932517: Move all initialization callers back into react-native
15+

src/__mocks__/deepDiffer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ var deepDiffer = function(one: any, two: any): boolean {
1616
// Short circuit on identical object references instead of traversing them.
1717
return false;
1818
}
19-
if ((typeof one === 'function') && (typeof two === 'function')) {
19+
if (typeof one === 'function' && typeof two === 'function') {
2020
// We consider all functions equal
2121
return false;
2222
}
23-
if ((typeof one !== 'object') || (one === null)) {
23+
if (typeof one !== 'object' || one === null) {
2424
// Primitives can be directly compared
2525
return one !== two;
2626
}
27-
if ((typeof two !== 'object') || (two === null)) {
27+
if (typeof two !== 'object' || two === null) {
2828
// We know they are different because the previous case would have triggered
2929
// otherwise.
3030
return true;

src/__mocks__/deepFreezeAndThrowOnMutationInDev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
// TODO: move into react or fbjs
1313

14-
var deepFreezeAndThrowOnMutationInDev = function() { };
14+
var deepFreezeAndThrowOnMutationInDev = function() {};
1515

1616
module.exports = deepFreezeAndThrowOnMutationInDev;

src/__mocks__/flattenStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
// TODO: Move flattenStyle into react
1313

14-
var flattenStyle = function() { };
14+
var flattenStyle = function() {};
1515

1616
module.exports = flattenStyle;

src/addons/ReactFragment.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ var ReactFragment = {
4141
warning(
4242
false,
4343
'React.addons.createFragment only accepts a single object. Got: %s',
44-
object
44+
object,
4545
);
4646
return object;
4747
}
4848
if (ReactElement.isValidElement(object)) {
4949
warning(
5050
false,
5151
'React.addons.createFragment does not accept a ReactElement ' +
52-
'without a wrapper object.'
52+
'without a wrapper object.',
5353
);
5454
return object;
5555
}
5656

5757
invariant(
5858
object.nodeType !== 1,
5959
'React.addons.createFragment(...): Encountered an invalid child; DOM ' +
60-
'elements are not valid children of React components.'
60+
'elements are not valid children of React components.',
6161
);
6262

6363
var result = [];
@@ -68,7 +68,7 @@ var ReactFragment = {
6868
warning(
6969
false,
7070
'React.addons.createFragment(...): Child objects should have ' +
71-
'non-numeric keys so ordering is preserved.'
71+
'non-numeric keys so ordering is preserved.',
7272
);
7373
warnedAboutNumeric = true;
7474
}
@@ -77,7 +77,7 @@ var ReactFragment = {
7777
object[key],
7878
result,
7979
key,
80-
emptyFunction.thatReturnsArgument
80+
emptyFunction.thatReturnsArgument,
8181
);
8282
}
8383

src/addons/ReactWithAddons.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
var React = require('react');
1515
var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');
16-
var ReactComponentWithPureRenderMixin =
17-
require('ReactComponentWithPureRenderMixin');
16+
var ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
1817
var ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');
1918
var ReactFragment = require('ReactFragment');
2019
var ReactTransitionGroup = require('ReactTransitionGroup');

src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ var ReactComponentWithPureRenderMixin;
1616
var ReactTestUtils;
1717

1818
describe('ReactComponentWithPureRenderMixin', () => {
19-
2019
beforeEach(() => {
2120
React = require('react');
22-
ReactComponentWithPureRenderMixin =
23-
require('ReactComponentWithPureRenderMixin');
21+
ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
2422
ReactTestUtils = require('ReactTestUtils');
2523
});
2624

@@ -35,12 +33,7 @@ describe('ReactComponentWithPureRenderMixin', () => {
3533
}
3634

3735
render() {
38-
return (
39-
<Apple
40-
color={this.state.color}
41-
ref="apple"
42-
/>
43-
);
36+
return <Apple color={this.state.color} ref="apple" />;
4437
}
4538
}
4639

@@ -141,5 +134,4 @@ describe('ReactComponentWithPureRenderMixin', () => {
141134
instance.setState(getInitialState());
142135
expect(renderCalls).toBe(3);
143136
});
144-
145137
});

src/addons/__tests__/ReactFragment-test.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var ReactDOM;
1616
var ReactFragment;
1717

1818
describe('ReactFragment', () => {
19-
2019
beforeEach(() => {
2120
React = require('react');
2221
ReactDOM = require('react-dom');
@@ -33,9 +32,9 @@ describe('ReactFragment', () => {
3332
var container = document.createElement('div');
3433
expect(() => ReactDOM.render(element, container)).toThrowError(
3534
'Objects are not valid as a React child (found: object with keys ' +
36-
'{x, y, z}). If you meant to render a collection of children, use an ' +
37-
'array instead or wrap the object using createFragment(object) from ' +
38-
'the React add-ons.'
35+
'{x, y, z}). If you meant to render a collection of children, use an ' +
36+
'array instead or wrap the object using createFragment(object) from ' +
37+
'the React add-ons.',
3938
);
4039
});
4140

@@ -53,9 +52,9 @@ describe('ReactFragment', () => {
5352
var container = document.createElement('div');
5453
expect(() => ReactDOM.render(<Foo />, container)).toThrowError(
5554
'Objects are not valid as a React child (found: object with keys ' +
56-
'{a, b, c}). If you meant to render a collection of children, use an ' +
57-
'array instead or wrap the object using createFragment(object) from ' +
58-
'the React add-ons.\n\nCheck the render method of `Foo`.'
55+
'{a, b, c}). If you meant to render a collection of children, use an ' +
56+
'array instead or wrap the object using createFragment(object) from ' +
57+
'the React add-ons.\n\nCheck the render method of `Foo`.',
5958
);
6059
});
6160

@@ -66,7 +65,7 @@ describe('ReactFragment', () => {
6665

6766
expectDev(console.error.calls.count()).toBe(1);
6867
expectDev(console.error.calls.argsFor(0)[0]).toContain(
69-
'Child objects should have non-numeric keys so ordering is preserved.'
68+
'Child objects should have non-numeric keys so ordering is preserved.',
7069
);
7170
});
7271

@@ -75,7 +74,7 @@ describe('ReactFragment', () => {
7574
ReactFragment.create(null);
7675
expectDev(console.error.calls.count()).toBe(1);
7776
expectDev(console.error.calls.argsFor(0)[0]).toContain(
78-
'React.addons.createFragment only accepts a single object.'
77+
'React.addons.createFragment only accepts a single object.',
7978
);
8079
});
8180

@@ -84,7 +83,7 @@ describe('ReactFragment', () => {
8483
ReactFragment.create([]);
8584
expectDev(console.error.calls.count()).toBe(1);
8685
expectDev(console.error.calls.argsFor(0)[0]).toContain(
87-
'React.addons.createFragment only accepts a single object.'
86+
'React.addons.createFragment only accepts a single object.',
8887
);
8988
});
9089

@@ -94,8 +93,7 @@ describe('ReactFragment', () => {
9493
expectDev(console.error.calls.count()).toBe(1);
9594
expectDev(console.error.calls.argsFor(0)[0]).toContain(
9695
'React.addons.createFragment does not accept a ReactElement without a ' +
97-
'wrapper object.'
96+
'wrapper object.',
9897
);
9998
});
100-
10199
});

0 commit comments

Comments
 (0)