Skip to content

Commit

Permalink
Add prettier, format files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Stanberry committed Aug 19, 2018
1 parent 8ac0d7f commit ee4dd64
Show file tree
Hide file tree
Showing 104 changed files with 1,013 additions and 1,174 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "airbnb",
"plugins": [
"extends": ["airbnb", "prettier"],
"plugins": [
"react",
"react-native"
],
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"jsxBracketSameLine": true
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"main": "build/react-native.js",
"scripts": {
"prepublish": "npm run build",
"test": "npm run lint && npm run mocha",
"test": "npm run lint && prettier \"./**/*.js\" --list-different && npm run mocha",
"mocha": "mocha --require test/setup-tests.js --require babel-core/register 'test/**/*.js'",
"mocha:watch": "npm run test -- --watch",
"build": "babel src --out-dir build",
"lint": "./node_modules/.bin/eslint 'src/' 'test/' 'mock.js'"
"lint": "./node_modules/.bin/eslint 'src/' 'test/' 'mock.js'",
"prettier": "prettier \"./**/*.js\" --write"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,12 +39,14 @@
"enzyme-adapter-react-16": "^1.0.0",
"eslint": "2.10.2",
"eslint-config-airbnb": "9.0.1",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-import": "1.8.0",
"eslint-plugin-jsx-a11y": "1.2.2",
"eslint-plugin-react": "5.1.1",
"eslint-plugin-react-native": "1.0.2",
"jsdom": "^11.3.0",
"mocha": "^3.0.2",
"prettier": "1.14.2",
"react": "16.0.0-beta.5",
"react-native": "^0.49.3",
"react-test-renderer": "^16.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/Libraries/EventEmitter/EmitterSubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const EventSubscription = require('./EventSubscription');
* EmitterSubscription represents a subscription with listener and context data.
*/
class EmitterSubscription extends EventSubscription {

/**
* @param {EventEmitter} emitter - The event emitter that registered this
* subscription
Expand Down
40 changes: 21 additions & 19 deletions src/Libraries/EventEmitter/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class EventEmitter {
* listener
*/
addListener(eventType, listener, context) {
return (this._subscriber.addSubscription(
return this._subscriber.addSubscription(
eventType,
new EmitterSubscription(this, this._subscriber, listener, context)
));
new EmitterSubscription(this, this._subscriber, listener, context),
);
}

/**
Expand Down Expand Up @@ -96,19 +96,19 @@ class EventEmitter {
*
* @example
* var subscription = emitter.addListenerMap({
* someEvent: function(data, event) {
* console.log(data);
* emitter.removeCurrentListener();
* }
* });
* someEvent: function(data, event) {
* console.log(data);
* emitter.removeCurrentListener();
* }
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
* emitter.emit('someEvent', 'def'); // does not log anything
*/
removeCurrentListener() {
invariant(
!!this._currentSubscription,
'Not in an emitting cycle; there is no current subscription'
'Not in an emitting cycle; there is no current subscription',
);
this.removeSubscription(this._currentSubscription);
}
Expand All @@ -120,7 +120,7 @@ class EventEmitter {
removeSubscription(subscription) {
invariant(
subscription.emitter === this,
'Subscription does not belong to this emitter.'
'Subscription does not belong to this emitter.',
);
this._subscriber.removeSubscription(subscription);
}
Expand All @@ -133,8 +133,10 @@ class EventEmitter {
* @returns {array}
*/
listeners(eventType) {
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
return subscriptions ? subscriptions.map(subscription => subscription.listener) : [];
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
return subscriptions
? subscriptions.map(subscription => subscription.listener)
: [];
}

/**
Expand All @@ -146,13 +148,13 @@ class EventEmitter {
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
emit(eventType) {
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
if (subscriptions) {
for (let i = 0, l = subscriptions.length; i < l; i++) {
const subscription = subscriptions[i];
Expand All @@ -162,7 +164,7 @@ class EventEmitter {
this._currentSubscription = subscription;
subscription.listener.apply(
subscription.context,
Array.prototype.slice.call(arguments, 1)
Array.prototype.slice.call(arguments, 1),
);
}
}
Expand All @@ -179,12 +181,12 @@ class EventEmitter {
*
* @example
* emitter.removeListener('someEvent', function(message) {
* console.log(message);
* }); // removes the listener if already registered
* console.log(message);
* }); // removes the listener if already registered
*
*/
removeListener(eventType, listener) {
const subscriptions = (this._subscriber.getSubscriptionsForType(eventType));
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
if (subscriptions) {
for (let i = 0, l = subscriptions.length; i < l; i++) {
const subscription = subscriptions[i];
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/EventEmitter/EventSubscriptionVendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const invariant = require('invariant');
* subscribed to a particular event type.
*/
class EventSubscriptionVendor {

constructor() {
this._subscriptionsForType = {};
this._currentSubscription = null;
Expand All @@ -30,7 +29,8 @@ class EventSubscriptionVendor {
/* eslint-disable no-param-reassign */
invariant(
subscription.subscriber === this,
'The subscriber of the subscription is incorrectly set.');
'The subscriber of the subscription is incorrectly set.',
);
if (!this._subscriptionsForType[eventType]) {
this._subscriptionsForType[eventType] = [];
}
Expand Down
6 changes: 2 additions & 4 deletions src/Libraries/NavigationExperimental/NavigationCard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react';

class CardStackPanResponder {
}
class CardStackPanResponder {}

class PagerPanResponder {
}
class PagerPanResponder {}

class NavigationCard extends React.Component {
static CardStackPanResponder = CardStackPanResponder;
Expand Down
10 changes: 4 additions & 6 deletions src/Libraries/NavigationExperimental/NavigationStateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ function push(state, route) {
throw new Error('should not push route with duplicated key ' + route.key);
}

const routes = [
...state.routes,
route,
];
const routes = [...state.routes, route];

return {
...state,
Expand Down Expand Up @@ -54,15 +51,16 @@ function jumpToIndex(state, index: number) {
};
}


function jumpTo(state, key) {
const index = indexOf(state, key);
return jumpToIndex(state, index);
}

function replaceAtIndex(state, index, route) {
if (!state.routes[index]) {
throw new Error('invalid index ' + index + ' for replacing route ' + route.key);
throw new Error(
'invalid index ' + index + ' for replacing route ' + route.key,
);
}

if (state.routes[index] === route) {
Expand Down
9 changes: 2 additions & 7 deletions src/NativeModules/ActionSheetManager.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

const ActionSheetManager = {
showActionSheetWithOptions(options, callback) {

},
showShareActionSheetWithOptions(options, failure, success) {

},
showActionSheetWithOptions(options, callback) {},
showShareActionSheetWithOptions(options, failure, success) {},
};

module.exports = ActionSheetManager;
4 changes: 1 addition & 3 deletions src/NativeModules/AlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
* https://github.com/facebook/react-native/blob/master/React/Modules/RCTAlertManager.m
*/
const AlertManager = {
alertWithArgs(args, callback) {

},
alertWithArgs(args, callback) {},
};

module.exports = AlertManager;
4 changes: 2 additions & 2 deletions src/NativeModules/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ DeviceEventEmitter.on('appStateDidChange', data => {

const AppState = {
getCurrentAppState(callback, error) {
Promise.resolve({ _appState }).then(callback);
Promise.resolve({_appState}).then(callback);
},

__setAppState(appState) {
DeviceEventEmitter.emit('appStateDidChange', { _appState: appState });
DeviceEventEmitter.emit('appStateDidChange', {_appState: appState});
},
};

Expand Down
26 changes: 13 additions & 13 deletions src/NativeModules/CameraRollManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const CameraRollManager = {
image: {
uri: 'content://media/external/images/media/1',
height: 2448,
width: 3968
width: 3968,
},
timestamp: 1528972673375
}
timestamp: 1528972673375,
},
},
{
node: {
Expand All @@ -24,10 +24,10 @@ const CameraRollManager = {
image: {
uri: 'content://media/external/images/media/2',
height: 2448,
width: 3968
width: 3968,
},
timestamp: 1528972673375
}
timestamp: 1528972673375,
},
},
{
node: {
Expand All @@ -36,18 +36,18 @@ const CameraRollManager = {
image: {
uri: 'content://media/external/images/media/3',
height: 2448,
width: 3968
width: 3968,
},
timestamp: 1528972673375
}
}
timestamp: 1528972673375,
},
},
],
page_info: {
has_next_page: true,
end_cursor: '1528919312601'
}
end_cursor: '1528919312601',
},
});
}
},
};

module.exports = CameraRollManager;
2 changes: 1 addition & 1 deletion src/NativeModules/DatePickerAndroid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO(lmr): figure out a good way to have separate responses like "dismissed" vs "set".
const DatePickerAndroid = {
open(options) {
return Promise.resolve().then({ action: 'dismissedAction' });
return Promise.resolve().then({action: 'dismissedAction'});
},
};

Expand Down
4 changes: 1 addition & 3 deletions src/NativeModules/DeviceEventManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const DeviceEventManager = {
invokeDefaultBackPressHandler() {

},
invokeDefaultBackPressHandler() {},
};

module.exports = DeviceEventManager;
2 changes: 1 addition & 1 deletion src/NativeModules/LinkingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LinkingManger = {

__setCanOpenURLTest(test) {
_test = test;
}
},
};

module.exports = LinkingManger;
31 changes: 14 additions & 17 deletions src/NativeModules/ScrollViewManager.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@

const ScrollViewManager = {
getContentSize(reactTag, callback) {
Promise.resolve().then(() => callback({
width: 20,
height: 20,
}));
Promise.resolve().then(() =>
callback({
width: 20,
height: 20,
}),
);
},
calculateChildFrames(reactTag, callback) {
Promise.resolve().then(() => callback({
// TODO(lmr):
}));
},
endRefreshing(reactTag) {

},
scrollTo(reactTag, offset, animated) {

},
zoomToRect(reactTag, rect, animated) {

Promise.resolve().then(() =>
callback({
// TODO(lmr):
}),
);
},
endRefreshing(reactTag) {},
scrollTo(reactTag, offset, animated) {},
zoomToRect(reactTag, rect, animated) {},
DecelerationRate: {
normal: 0,
fast: 1,
Expand Down
4 changes: 1 addition & 3 deletions src/NativeModules/SourceCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ const SourceCode = {
: Promise.reject(new Error('Source code is not available'));
},
__setScriptText(url, text) {
_sourceCode = !!url && !!text
? { url, text }
: null;
_sourceCode = !!url && !!text ? {url, text} : null;
},
};

Expand Down
Loading

0 comments on commit ee4dd64

Please sign in to comment.