Skip to content

Commit ee4dd64

Browse files
author
Andy Stanberry
committed
Add prettier, format files
1 parent 8ac0d7f commit ee4dd64

File tree

104 files changed

+1013
-1174
lines changed

Some content is hidden

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

104 files changed

+1013
-1174
lines changed

Diff for: .eslintrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"extends": "airbnb",
3-
"plugins": [
2+
"extends": ["airbnb", "prettier"],
3+
"plugins": [
44
"react",
55
"react-native"
66
],

Diff for: .prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"bracketSpacing": false,
5+
"jsxBracketSameLine": true
6+
}

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"main": "build/react-native.js",
66
"scripts": {
77
"prepublish": "npm run build",
8-
"test": "npm run lint && npm run mocha",
8+
"test": "npm run lint && prettier \"./**/*.js\" --list-different && npm run mocha",
99
"mocha": "mocha --require test/setup-tests.js --require babel-core/register 'test/**/*.js'",
1010
"mocha:watch": "npm run test -- --watch",
1111
"build": "babel src --out-dir build",
12-
"lint": "./node_modules/.bin/eslint 'src/' 'test/' 'mock.js'"
12+
"lint": "./node_modules/.bin/eslint 'src/' 'test/' 'mock.js'",
13+
"prettier": "prettier \"./**/*.js\" --write"
1314
},
1415
"repository": {
1516
"type": "git",
@@ -38,12 +39,14 @@
3839
"enzyme-adapter-react-16": "^1.0.0",
3940
"eslint": "2.10.2",
4041
"eslint-config-airbnb": "9.0.1",
42+
"eslint-config-prettier": "2.9.0",
4143
"eslint-plugin-import": "1.8.0",
4244
"eslint-plugin-jsx-a11y": "1.2.2",
4345
"eslint-plugin-react": "5.1.1",
4446
"eslint-plugin-react-native": "1.0.2",
4547
"jsdom": "^11.3.0",
4648
"mocha": "^3.0.2",
49+
"prettier": "1.14.2",
4750
"react": "16.0.0-beta.5",
4851
"react-native": "^0.49.3",
4952
"react-test-renderer": "^16.0.0",

Diff for: src/Libraries/EventEmitter/EmitterSubscription.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const EventSubscription = require('./EventSubscription');
1313
* EmitterSubscription represents a subscription with listener and context data.
1414
*/
1515
class EmitterSubscription extends EventSubscription {
16-
1716
/**
1817
* @param {EventEmitter} emitter - The event emitter that registered this
1918
* subscription

Diff for: src/Libraries/EventEmitter/EventEmitter.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class EventEmitter {
5050
* listener
5151
*/
5252
addListener(eventType, listener, context) {
53-
return (this._subscriber.addSubscription(
53+
return this._subscriber.addSubscription(
5454
eventType,
55-
new EmitterSubscription(this, this._subscriber, listener, context)
56-
));
55+
new EmitterSubscription(this, this._subscriber, listener, context),
56+
);
5757
}
5858

5959
/**
@@ -96,19 +96,19 @@ class EventEmitter {
9696
*
9797
* @example
9898
* var subscription = emitter.addListenerMap({
99-
* someEvent: function(data, event) {
100-
* console.log(data);
101-
* emitter.removeCurrentListener();
102-
* }
103-
* });
99+
* someEvent: function(data, event) {
100+
* console.log(data);
101+
* emitter.removeCurrentListener();
102+
* }
103+
* });
104104
*
105105
* emitter.emit('someEvent', 'abc'); // logs 'abc'
106106
* emitter.emit('someEvent', 'def'); // does not log anything
107107
*/
108108
removeCurrentListener() {
109109
invariant(
110110
!!this._currentSubscription,
111-
'Not in an emitting cycle; there is no current subscription'
111+
'Not in an emitting cycle; there is no current subscription',
112112
);
113113
this.removeSubscription(this._currentSubscription);
114114
}
@@ -120,7 +120,7 @@ class EventEmitter {
120120
removeSubscription(subscription) {
121121
invariant(
122122
subscription.emitter === this,
123-
'Subscription does not belong to this emitter.'
123+
'Subscription does not belong to this emitter.',
124124
);
125125
this._subscriber.removeSubscription(subscription);
126126
}
@@ -133,8 +133,10 @@ class EventEmitter {
133133
* @returns {array}
134134
*/
135135
listeners(eventType) {
136-
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
137-
return subscriptions ? subscriptions.map(subscription => subscription.listener) : [];
136+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
137+
return subscriptions
138+
? subscriptions.map(subscription => subscription.listener)
139+
: [];
138140
}
139141

140142
/**
@@ -146,13 +148,13 @@ class EventEmitter {
146148
*
147149
* @example
148150
* emitter.addListener('someEvent', function(message) {
149-
* console.log(message);
150-
* });
151+
* console.log(message);
152+
* });
151153
*
152154
* emitter.emit('someEvent', 'abc'); // logs 'abc'
153155
*/
154156
emit(eventType) {
155-
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
157+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
156158
if (subscriptions) {
157159
for (let i = 0, l = subscriptions.length; i < l; i++) {
158160
const subscription = subscriptions[i];
@@ -162,7 +164,7 @@ class EventEmitter {
162164
this._currentSubscription = subscription;
163165
subscription.listener.apply(
164166
subscription.context,
165-
Array.prototype.slice.call(arguments, 1)
167+
Array.prototype.slice.call(arguments, 1),
166168
);
167169
}
168170
}
@@ -179,12 +181,12 @@ class EventEmitter {
179181
*
180182
* @example
181183
* emitter.removeListener('someEvent', function(message) {
182-
* console.log(message);
183-
* }); // removes the listener if already registered
184+
* console.log(message);
185+
* }); // removes the listener if already registered
184186
*
185187
*/
186188
removeListener(eventType, listener) {
187-
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
189+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
188190
if (subscriptions) {
189191
for (let i = 0, l = subscriptions.length; i < l; i++) {
190192
const subscription = subscriptions[i];

Diff for: src/Libraries/EventEmitter/EventSubscriptionVendor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const invariant = require('invariant');
1414
* subscribed to a particular event type.
1515
*/
1616
class EventSubscriptionVendor {
17-
1817
constructor() {
1918
this._subscriptionsForType = {};
2019
this._currentSubscription = null;
@@ -30,7 +29,8 @@ class EventSubscriptionVendor {
3029
/* eslint-disable no-param-reassign */
3130
invariant(
3231
subscription.subscriber === this,
33-
'The subscriber of the subscription is incorrectly set.');
32+
'The subscriber of the subscription is incorrectly set.',
33+
);
3434
if (!this._subscriptionsForType[eventType]) {
3535
this._subscriptionsForType[eventType] = [];
3636
}

Diff for: src/Libraries/NavigationExperimental/NavigationCard.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React from 'react';
22

3-
class CardStackPanResponder {
4-
}
3+
class CardStackPanResponder {}
54

6-
class PagerPanResponder {
7-
}
5+
class PagerPanResponder {}
86

97
class NavigationCard extends React.Component {
108
static CardStackPanResponder = CardStackPanResponder;

Diff for: src/Libraries/NavigationExperimental/NavigationStateUtils.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ function push(state, route) {
1515
throw new Error('should not push route with duplicated key ' + route.key);
1616
}
1717

18-
const routes = [
19-
...state.routes,
20-
route,
21-
];
18+
const routes = [...state.routes, route];
2219

2320
return {
2421
...state,
@@ -54,15 +51,16 @@ function jumpToIndex(state, index: number) {
5451
};
5552
}
5653

57-
5854
function jumpTo(state, key) {
5955
const index = indexOf(state, key);
6056
return jumpToIndex(state, index);
6157
}
6258

6359
function replaceAtIndex(state, index, route) {
6460
if (!state.routes[index]) {
65-
throw new Error('invalid index ' + index + ' for replacing route ' + route.key);
61+
throw new Error(
62+
'invalid index ' + index + ' for replacing route ' + route.key,
63+
);
6664
}
6765

6866
if (state.routes[index] === route) {

Diff for: src/NativeModules/ActionSheetManager.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
21
const ActionSheetManager = {
3-
showActionSheetWithOptions(options, callback) {
4-
5-
},
6-
showShareActionSheetWithOptions(options, failure, success) {
7-
8-
},
2+
showActionSheetWithOptions(options, callback) {},
3+
showShareActionSheetWithOptions(options, failure, success) {},
94
};
105

116
module.exports = ActionSheetManager;

Diff for: src/NativeModules/AlertManager.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
* https://github.com/facebook/react-native/blob/master/React/Modules/RCTAlertManager.m
33
*/
44
const AlertManager = {
5-
alertWithArgs(args, callback) {
6-
7-
},
5+
alertWithArgs(args, callback) {},
86
};
97

108
module.exports = AlertManager;

Diff for: src/NativeModules/AppState.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ DeviceEventEmitter.on('appStateDidChange', data => {
88

99
const AppState = {
1010
getCurrentAppState(callback, error) {
11-
Promise.resolve({ _appState }).then(callback);
11+
Promise.resolve({_appState}).then(callback);
1212
},
1313

1414
__setAppState(appState) {
15-
DeviceEventEmitter.emit('appStateDidChange', { _appState: appState });
15+
DeviceEventEmitter.emit('appStateDidChange', {_appState: appState});
1616
},
1717
};
1818

Diff for: src/NativeModules/CameraRollManager.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const CameraRollManager = {
1212
image: {
1313
uri: 'content://media/external/images/media/1',
1414
height: 2448,
15-
width: 3968
15+
width: 3968,
1616
},
17-
timestamp: 1528972673375
18-
}
17+
timestamp: 1528972673375,
18+
},
1919
},
2020
{
2121
node: {
@@ -24,10 +24,10 @@ const CameraRollManager = {
2424
image: {
2525
uri: 'content://media/external/images/media/2',
2626
height: 2448,
27-
width: 3968
27+
width: 3968,
2828
},
29-
timestamp: 1528972673375
30-
}
29+
timestamp: 1528972673375,
30+
},
3131
},
3232
{
3333
node: {
@@ -36,18 +36,18 @@ const CameraRollManager = {
3636
image: {
3737
uri: 'content://media/external/images/media/3',
3838
height: 2448,
39-
width: 3968
39+
width: 3968,
4040
},
41-
timestamp: 1528972673375
42-
}
43-
}
41+
timestamp: 1528972673375,
42+
},
43+
},
4444
],
4545
page_info: {
4646
has_next_page: true,
47-
end_cursor: '1528919312601'
48-
}
47+
end_cursor: '1528919312601',
48+
},
4949
});
50-
}
50+
},
5151
};
5252

5353
module.exports = CameraRollManager;

Diff for: src/NativeModules/DatePickerAndroid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TODO(lmr): figure out a good way to have separate responses like "dismissed" vs "set".
22
const DatePickerAndroid = {
33
open(options) {
4-
return Promise.resolve().then({ action: 'dismissedAction' });
4+
return Promise.resolve().then({action: 'dismissedAction'});
55
},
66
};
77

Diff for: src/NativeModules/DeviceEventManager.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const DeviceEventManager = {
2-
invokeDefaultBackPressHandler() {
3-
4-
},
2+
invokeDefaultBackPressHandler() {},
53
};
64

75
module.exports = DeviceEventManager;

Diff for: src/NativeModules/LinkingManager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const LinkingManger = {
99

1010
__setCanOpenURLTest(test) {
1111
_test = test;
12-
}
12+
},
1313
};
1414

1515
module.exports = LinkingManger;

Diff for: src/NativeModules/ScrollViewManager.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
21
const ScrollViewManager = {
32
getContentSize(reactTag, callback) {
4-
Promise.resolve().then(() => callback({
5-
width: 20,
6-
height: 20,
7-
}));
3+
Promise.resolve().then(() =>
4+
callback({
5+
width: 20,
6+
height: 20,
7+
}),
8+
);
89
},
910
calculateChildFrames(reactTag, callback) {
10-
Promise.resolve().then(() => callback({
11-
// TODO(lmr):
12-
}));
13-
},
14-
endRefreshing(reactTag) {
15-
16-
},
17-
scrollTo(reactTag, offset, animated) {
18-
19-
},
20-
zoomToRect(reactTag, rect, animated) {
21-
11+
Promise.resolve().then(() =>
12+
callback({
13+
// TODO(lmr):
14+
}),
15+
);
2216
},
17+
endRefreshing(reactTag) {},
18+
scrollTo(reactTag, offset, animated) {},
19+
zoomToRect(reactTag, rect, animated) {},
2320
DecelerationRate: {
2421
normal: 0,
2522
fast: 1,

Diff for: src/NativeModules/SourceCode.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const SourceCode = {
1010
: Promise.reject(new Error('Source code is not available'));
1111
},
1212
__setScriptText(url, text) {
13-
_sourceCode = !!url && !!text
14-
? { url, text }
15-
: null;
13+
_sourceCode = !!url && !!text ? {url, text} : null;
1614
},
1715
};
1816

0 commit comments

Comments
 (0)