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

.eslintrc

Lines changed: 2 additions & 2 deletions
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
],

.prettierrc

Lines changed: 6 additions & 0 deletions
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+
}

package.json

Lines changed: 5 additions & 2 deletions
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",

src/Libraries/EventEmitter/EmitterSubscription.js

Lines changed: 0 additions & 1 deletion
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

src/Libraries/EventEmitter/EventEmitter.js

Lines changed: 21 additions & 19 deletions
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];

src/Libraries/EventEmitter/EventSubscriptionVendor.js

Lines changed: 2 additions & 2 deletions
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
}

src/Libraries/NavigationExperimental/NavigationCard.js

Lines changed: 2 additions & 4 deletions
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;

src/Libraries/NavigationExperimental/NavigationStateUtils.js

Lines changed: 4 additions & 6 deletions
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) {
Lines changed: 2 additions & 7 deletions
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;

src/NativeModules/AlertManager.js

Lines changed: 1 addition & 3 deletions
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;

0 commit comments

Comments
 (0)