Skip to content

Commit

Permalink
Merge pull request #9101 from sebmarkbage/prettier
Browse files Browse the repository at this point in the history
Use Prettier
  • Loading branch information
jlongster committed Mar 14, 2017
2 parents 2b59afb + 7e078d6 commit b1b4a2f
Show file tree
Hide file tree
Showing 328 changed files with 12,794 additions and 11,435 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
'dot-notation': ERROR,
'eol-last': ERROR,
'eqeqeq': [ERROR, 'allow-null'],
'indent': [ERROR, 2, {SwitchCase: 1}],
'indent': OFF,
'jsx-quotes': [ERROR, 'prefer-double'],
'keyword-spacing': [ERROR, {after: true, before: true}],
'no-bitwise': OFF,
Expand All @@ -33,9 +33,10 @@ module.exports = {
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-useless-concat': OFF,
'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }],
'space-before-blocks': ERROR,
'space-before-function-paren': [ERROR, {anonymous: 'never', named: 'never'}],
'space-before-function-paren': OFF,

// React & JSX
// Our transforms set this automatically
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"merge-stream": "^1.0.0",
"object-assign": "^4.1.1",
"platform": "^1.1.0",
"prettier": "^0.22.0",
"run-sequence": "^1.1.4",
"through2": "^2.0.0",
"tmp": "~0.0.28",
Expand All @@ -92,7 +93,8 @@
"lint": "grunt lint",
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
"test": "jest",
"flow": "flow"
"flow": "flow",
"prettier": "prettier --write --no-bracket-spacing --single-quote --jsx-bracket-same-line --trailing-comma all --print-width 80 \"src/**/!(third_party)/*.js\""
},
"jest": {
"modulePathIgnorePatterns": [
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/InitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
// Noop

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

6 changes: 3 additions & 3 deletions src/__mocks__/deepDiffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ var deepDiffer = function(one: any, two: any): boolean {
// Short circuit on identical object references instead of traversing them.
return false;
}
if ((typeof one === 'function') && (typeof two === 'function')) {
if (typeof one === 'function' && typeof two === 'function') {
// We consider all functions equal
return false;
}
if ((typeof one !== 'object') || (one === null)) {
if (typeof one !== 'object' || one === null) {
// Primitives can be directly compared
return one !== two;
}
if ((typeof two !== 'object') || (two === null)) {
if (typeof two !== 'object' || two === null) {
// We know they are different because the previous case would have triggered
// otherwise.
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/deepFreezeAndThrowOnMutationInDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

// TODO: move into react or fbjs

var deepFreezeAndThrowOnMutationInDev = function() { };
var deepFreezeAndThrowOnMutationInDev = function() {};

module.exports = deepFreezeAndThrowOnMutationInDev;
2 changes: 1 addition & 1 deletion src/__mocks__/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

// TODO: Move flattenStyle into react

var flattenStyle = function() { };
var flattenStyle = function() {};

module.exports = flattenStyle;
10 changes: 5 additions & 5 deletions src/addons/ReactFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment only accepts a single object. Got: %s',
object
object,
);
return object;
}
if (ReactElement.isValidElement(object)) {
warning(
false,
'React.addons.createFragment does not accept a ReactElement ' +
'without a wrapper object.'
'without a wrapper object.',
);
return object;
}

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

var result = [];
Expand All @@ -68,7 +68,7 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment(...): Child objects should have ' +
'non-numeric keys so ordering is preserved.'
'non-numeric keys so ordering is preserved.',
);
warnedAboutNumeric = true;
}
Expand All @@ -77,7 +77,7 @@ var ReactFragment = {
object[key],
result,
key,
emptyFunction.thatReturnsArgument
emptyFunction.thatReturnsArgument,
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/addons/ReactWithAddons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

var React = require('react');
var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');
var ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
var ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
var ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');
var ReactFragment = require('ReactFragment');
var ReactTransitionGroup = require('ReactTransitionGroup');
Expand Down
12 changes: 2 additions & 10 deletions src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ var ReactComponentWithPureRenderMixin;
var ReactTestUtils;

describe('ReactComponentWithPureRenderMixin', () => {

beforeEach(() => {
React = require('react');
ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
ReactTestUtils = require('ReactTestUtils');
});

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

render() {
return (
<Apple
color={this.state.color}
ref="apple"
/>
);
return <Apple color={this.state.color} ref="apple" />;
}
}

Expand Down Expand Up @@ -141,5 +134,4 @@ describe('ReactComponentWithPureRenderMixin', () => {
instance.setState(getInitialState());
expect(renderCalls).toBe(3);
});

});
22 changes: 10 additions & 12 deletions src/addons/__tests__/ReactFragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var ReactDOM;
var ReactFragment;

describe('ReactFragment', () => {

beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
Expand All @@ -33,9 +32,9 @@ describe('ReactFragment', () => {
var container = document.createElement('div');
expect(() => ReactDOM.render(element, container)).toThrowError(
'Objects are not valid as a React child (found: object with keys ' +
'{x, y, z}). If you meant to render a collection of children, use an ' +
'array instead or wrap the object using createFragment(object) from ' +
'the React add-ons.'
'{x, y, z}). If you meant to render a collection of children, use an ' +
'array instead or wrap the object using createFragment(object) from ' +
'the React add-ons.',
);
});

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

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

expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'Child objects should have non-numeric keys so ordering is preserved.'
'Child objects should have non-numeric keys so ordering is preserved.',
);
});

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

Expand All @@ -84,7 +83,7 @@ describe('ReactFragment', () => {
ReactFragment.create([]);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment only accepts a single object.'
'React.addons.createFragment only accepts a single object.',
);
});

Expand All @@ -94,8 +93,7 @@ describe('ReactFragment', () => {
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment does not accept a ReactElement without a ' +
'wrapper object.'
'wrapper object.',
);
});

});
10 changes: 5 additions & 5 deletions src/addons/__tests__/renderSubtreeIntoContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var ReactTestUtils = require('ReactTestUtils');
var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');

describe('renderSubtreeIntoContainer', () => {

it('should pass context when rendering subtree elsewhere', () => {
var portal = document.createElement('div');

Expand Down Expand Up @@ -47,9 +46,11 @@ describe('renderSubtreeIntoContainer', () => {
}

componentDidMount() {
expect(function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this)).not.toThrow();
expect(
function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this),
).not.toThrow();
}
}

Expand Down Expand Up @@ -296,5 +297,4 @@ describe('renderSubtreeIntoContainer', () => {
ReactDOM.render(<Parent value="foo" />, container);
expect(portal2.textContent).toBe('foo');
});

});
Loading

0 comments on commit b1b4a2f

Please sign in to comment.