Skip to content

Commit 0a78a64

Browse files
authored
Add Prettier (#312)
1 parent b49a1d2 commit 0a78a64

32 files changed

+2994
-5817
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package.json
2+
example/

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5"
4+
}

README.md

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
2-
31
# react-native-meteor
4-
[![react-native-meteor](http://img.shields.io/npm/dm/react-native-meteor.svg)](https://www.npmjs.org/package/react-native-meteor) [![npm version](https://badge.fury.io/js/react-native-meteor.svg)](http://badge.fury.io/js/react-native-meteor) [![Dependency Status](https://david-dm.org/inProgress-team/react-native-meteor.svg)](https://david-dm.org/inProgress-team/react-native-meteor)
2+
3+
[![react-native-meteor](http://img.shields.io/npm/dm/react-native-meteor.svg)](https://www.npmjs.org/package/react-native-meteor) [![npm version](https://badge.fury.io/js/react-native-meteor.svg)](http://badge.fury.io/js/react-native-meteor) [![Dependency Status](https://david-dm.org/inProgress-team/react-native-meteor.svg)](https://david-dm.org/inProgress-team/react-native-meteor)
54

65
Meteor-like methods for React Native.
76

87
If you have questions, you can open a new issue in the repository or ask in the our Gitter chat:
98
https://gitter.im/react-native-meteor/Lobby
109

10+
<!-- prettier-ignore-start -->
1111
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
1212

1313
- [react-native-meteor](#react-native-meteor)
@@ -48,6 +48,7 @@ https://gitter.im/react-native-meteor/Lobby
4848
- [Want to help ?](#want-to-help-)
4949

5050
<!-- /TOC -->
51+
<!-- prettier-ignore-end -->
5152

5253
## Compatibility notes
5354

@@ -61,67 +62,64 @@ https://gitter.im/react-native-meteor/Lobby
6162
## What is it for ?
6263

6364
The purpose of this library is :
65+
6466
* to set up and maintain a ddp connection with a ddp server, freeing the developer from having to do it on their own.
6567
* be fully compatible with react-native and help react-native developers.
6668
* **to match with [Meteor documentation](http://docs.meteor.com/) used with React.**
6769

68-
69-
7070
## Install
7171

7272
npm i --save react-native-meteor
7373

7474
[!! See detailed installation guide](https://github.com/inProgress-team/react-native-meteor/blob/master/docs/Install.md)
7575

7676
## Install from Git
77+
7778
Sometimes we do not have time to update the version of the NPM package. In this case, you can use the latest version from the repository.
7879

7980
npm i --save https://github.com/inProgress-team/react-native-meteor
8081

8182
## Example usage
8283

8384
```javascript
84-
8585
import React, { Component } from 'react';
8686
import { View, Text } from 'react-native';
8787
import Meteor, { createContainer, MeteorListView } from 'react-native-meteor';
8888

89-
Meteor.connect('ws://192.168.X.X:3000/websocket');//do this only once
89+
Meteor.connect('ws://192.168.X.X:3000/websocket'); //do this only once
9090

9191
class App extends Component {
9292
renderRow(todo) {
93-
return (
94-
<Text>{todo.title}</Text>
95-
);
93+
return <Text>{todo.title}</Text>;
9694
}
9795
render() {
9896
const { settings, todosReady } = this.props;
9997

100-
return(
98+
return (
10199
<View>
102100
<Text>{settings.title}</Text>
103-
{!todosReady && <Text>Not ready</Text>}
104-
105-
<MeteorListView
106-
collection="todos"
107-
selector={{done: true}}
108-
options={{sort: {createdAt: -1}}}
109-
renderRow={this.renderRow}
110-
/>
101+
{!todosReady && <Text>Not ready</Text>}
102+
103+
<MeteorListView
104+
collection="todos"
105+
selector={{ done: true }}
106+
options={{ sort: { createdAt: -1 } }}
107+
renderRow={this.renderRow}
108+
/>
111109
</View>
112-
)
110+
);
113111
}
114112
}
115113

116-
export default createContainer(params=>{
114+
export default createContainer(params => {
117115
const handle = Meteor.subscribe('todos');
118116
Meteor.subscribe('settings');
119117

120118
return {
121119
todosReady: handle.ready(),
122-
settings: Meteor.collection('settings').findOne()
120+
settings: Meteor.collection('settings').findOne(),
123121
};
124-
}, App)
122+
}, App);
125123
```
126124

127125
# Connect your components
@@ -130,7 +128,7 @@ export default createContainer(params=>{
130128

131129
## createContainer
132130

133-
Very similar to getMeteorData but your separate container components from presentational components.
131+
Very similar to getMeteorData but your separate container components from presentational components.
134132

135133
### Example
136134

@@ -215,23 +213,23 @@ These methods (except update) work offline. That means that elements are correct
215213
* [.remove(id, callback(err, countRemoved))](http://docs.meteor.com/#/full/remove)
216214

217215
# ListView Components
216+
218217
## MeteorListView Component
219218

220219
Same as [ListView](https://facebook.github.io/react-native/docs/listview.html) Component but does not need dataSource and accepts three arguments :
221220

222-
- `collection` **string** *required*
223-
- `selector` [**string** / **object**]
224-
- `options` **object**
225-
- `listViewRef` [**string** / **function**] ref to ListView component.
226-
221+
* `collection` **string** _required_
222+
* `selector` [**string** / **object**]
223+
* `options` **object**
224+
* `listViewRef` [**string** / **function**] ref to ListView component.
227225

228226
### Example usage
229227

230228
```javascript
231229
<MeteorListView
232230
collection="todos"
233-
selector={{done: true}}
234-
options={{sort: {createdAt: -1}}}
231+
selector={{ done: true }}
232+
options={{ sort: { createdAt: -1 } }}
235233
renderRow={this.renderItem}
236234
//...other listview props
237235
/>
@@ -241,14 +239,16 @@ Same as [ListView](https://facebook.github.io/react-native/docs/listview.html) C
241239

242240
Same as [ListView](https://facebook.github.io/react-native/docs/listview.html) Component but does not need dataSource and accepts one argument. You may need it if you make complex requests combining multiples collections.
243241

244-
- `elements` **function** *required* : a reactive function which returns an array of elements.
245-
- `listViewRef` [**string** / **function**] ref to ListView component.
242+
* `elements` **function** _required_ : a reactive function which returns an array of elements.
243+
* `listViewRef` [**string** / **function**] ref to ListView component.
246244

247245
### Example usage
248246

249247
```javascript
250248
<MeteorComplexListView
251-
elements={()=>{return Meteor.collection('todos').find()}}
249+
elements={() => {
250+
return Meteor.collection('todos').find();
251+
}}
252252
renderRow={this.renderItem}
253253
//...other listview props
254254
/>
@@ -259,9 +259,11 @@ Same as [ListView](https://facebook.github.io/react-native/docs/listview.html) C
259259
## Meteor Collections
260260

261261
### Meteor.subscribe
262+
262263
[Meteor.subscribe()](http://docs.meteor.com/#/full/meteor_subscribe) returns an handle. If the component which called subscribe is unmounted, the subscription is automatically canceled.
263264

264265
### Meteor.collection(collectionName, options)
266+
265267
You need pass the `cursoredFind` option when you get your collection if you want to use cursor-like method:
266268

267269
```‍‍‍javascript
@@ -270,20 +272,19 @@ Meteor.collection("collectionName", { cursoredFind: true })
270272

271273
Or you can simply use `find()` to get an array of documents. The option default to false for backward compatibility. Cursor methods are available to share code more easily between a react-native app and a standard Meteor app.
272274

273-
274275
## Meteor DDP connection
275276

276277
### Meteor.connect(endpoint, options)
277278

278279
Connect to a DDP server. You only have to do this once in your app.
279280

280-
*Arguments*
281+
_Arguments_
281282

282-
- `url` **string** *required*
283-
- `options` **object** Available options are :
284-
- autoConnect **boolean** [true] whether to establish the connection to the server upon instantiation. When false, one can manually establish the connection with the Meteor.ddp.connect method.
285-
- autoReconnect **boolean** [true] whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.
286-
- reconnectInterval **number** [10000] the interval in ms between reconnection attempts.
283+
* `url` **string** _required_
284+
* `options` **object** Available options are :
285+
* autoConnect **boolean** [true] whether to establish the connection to the server upon instantiation. When false, one can manually establish the connection with the Meteor.ddp.connect method.
286+
* autoReconnect **boolean** [true] whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.
287+
* reconnectInterval **number** [10000] the interval in ms between reconnection attempts.
287288

288289
### Meteor.disconnect()
289290

@@ -298,7 +299,8 @@ Disconnect from the DDP server.
298299

299300
## Availables packages
300301

301-
### Convenience packages
302+
### Convenience packages
303+
302304
Example `import { composeWithTracker } from 'react-native-meteor';``
303305

304306
* EJSON
@@ -310,7 +312,6 @@ Example `import { composeWithTracker } from 'react-native-meteor';``
310312

311313
See [documentation](https://atmospherejs.com/meteor/reactive-dict).
312314

313-
314315
### Meteor.Accounts
315316

316317
`import { Accounts } from 'react-native-meteor';``
@@ -339,6 +340,7 @@ import { FSCollectionImagesPreloader } from 'react-native-meteor';
339340
### Meteor.ddp
340341

341342
Once connected to the ddp server, you can access every method available in [ddp.js](https://github.com/mondora/ddp.js/).
343+
342344
* Meteor.ddp.on('connected')
343345
* Meteor.ddp.on('added')
344346
* Meteor.ddp.on('changed')
@@ -349,6 +351,7 @@ Once connected to the ddp server, you can access every method available in [ddp.
349351
## react-native-router-flux
350352

351353
* You can use Switch with createContainer. Example :
354+
352355
```javascript
353356
componentWillMount() {
354357
this.scenes = Actions.create(
@@ -381,7 +384,6 @@ Once connected to the ddp server, you can access every method available in [ddp.
381384
return "loggedIn";
382385
}
383386
}
384-
385387
```
386388

387389
# Author

docs/FSCollection.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ export default class ImageFS extends Component {
1010
}
1111
getMeteorData() {
1212
return {
13-
image: Meteor.FSCollection('imagesFiles').findOne()
14-
}
13+
image: Meteor.FSCollection('imagesFiles').findOne(),
14+
};
1515
}
1616
render() {
1717
const { image } = this.data;
1818

19-
if(!image) return null;
19+
if (!image) return null;
2020

2121
return (
2222
<Image
23-
style={{height: 400, width: 400}}
24-
source={{uri: image.url()}}
23+
style={{ height: 400, width: 400 }}
24+
source={{ uri: image.url() }}
2525
/>
2626
);
2727
}
@@ -46,4 +46,3 @@ All methods accept an optional parameter to choose another store. Example `file.
4646
## Something wrong or missing ?
4747

4848
Please create an issue or make a PR ;)
49-

docs/Install.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ If running an android emulator you have to forward the port of your meteor app.
1616
$ adb reverse tcp:3000 tcp:3000
1717
```
1818

19-
20-
2119
# Installing decorators
2220

2321
## With RN >= 0.16.0 (Babel 6)
2422

25-
- `npm i --save-dev babel-plugin-transform-decorators-legacy babel-preset-react-native` in your project
26-
- Create a .babelrc file at the root of your project :
23+
* `npm i --save-dev babel-plugin-transform-decorators-legacy babel-preset-react-native` in your project
24+
* Create a .babelrc file at the root of your project :
2725

2826
```json
2927
{
@@ -38,6 +36,6 @@ Use a .babelrc file at the root of your project that contains :
3836

3937
```json
4038
{
41-
"optional": ["es7.decorators"],
39+
"optional": ["es7.decorators"]
4240
}
4341
```

lib/Random.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
const UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz";
1+
const UNMISTAKABLE_CHARS =
2+
'23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz';
23

34
module.exports = {
45
id(count = 17) {
5-
let res = "";
6-
for(let i=0;i<count;i++) {
7-
res+=UNMISTAKABLE_CHARS[Math.floor(Math.random() * UNMISTAKABLE_CHARS.length)];
6+
let res = '';
7+
for (let i = 0; i < count; i++) {
8+
res +=
9+
UNMISTAKABLE_CHARS[
10+
Math.floor(Math.random() * UNMISTAKABLE_CHARS.length)
11+
];
812
}
913
return res;
10-
}
14+
},
1115
};
12-
13-

0 commit comments

Comments
 (0)