Daniel Zlotin преди 8 години
родител
ревизия
93d9cbb1db

+ 2
- 19
.eslintrc Целия файл

@@ -302,7 +302,7 @@
302 302
     "no-whitespace-before-property": "error",
303 303
     "object-curly-spacing": [
304 304
       "error",
305
-      "never"
305
+      "always"
306 306
     ],
307 307
     "one-var": 0,
308 308
     "one-var-declaration-per-line": 0,
@@ -481,23 +481,6 @@
481 481
      *                              react-native plugin
482 482
      */
483 483
     "react-native/no-unused-styles": "error",
484
-    "react-native/split-platform-components": "error",
485
-    /*
486
-     *                              babel plugin
487
-     */
488
-    "babel/new-cap": [
489
-      "error",
490
-      {
491
-        "capIsNewExceptions": [
492
-          "Immutable"
493
-        ]
494
-      }
495
-    ],
496
-    "babel/object-curly-spacing": [
497
-      "error",
498
-      "never"
499
-    ],
500
-    "babel/object-shorthand": 0,
501
-    "babel/no-await-in-loop": 0
484
+    "react-native/split-platform-components": "error"
502 485
   }
503 486
 }

+ 3
- 3
integration/env.test.js Целия файл

@@ -1,12 +1,12 @@
1 1
 describe('test environment', () => {
2 2
   it('handles object spread', () => {
3
-    const {x, y, ...z} = {x: 1, y: 2, a: 3, b: 4};
3
+    const { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
4 4
     expect(x).toEqual(1);
5 5
     expect(y).toEqual(2);
6
-    expect(z).toEqual({a: 3, b: 4});
6
+    expect(z).toEqual({ a: 3, b: 4 });
7 7
   });
8 8
 
9
-  it('handles async await', async() => {
9
+  it('handles async await', async () => {
10 10
     const result = await new Promise((r) => r('hello'));
11 11
     expect(result).toEqual('hello');
12 12
   });

+ 4
- 4
integration/remx/component.js Целия файл

@@ -1,9 +1,9 @@
1
-import {Text} from 'react-native';
2
-import React, {Component} from 'react';
1
+import { Text } from 'react-native';
2
+import React, { Component } from 'react';
3 3
 
4
-import {connect} from 'remx/react-native';
4
+import { connect } from 'remx/react-native';
5 5
 
6
-import {selectors} from './store';
6
+import { selectors } from './store';
7 7
 
8 8
 class MyContainer extends Component {
9 9
   constructor(props) {

+ 1
- 1
integration/remx/store.js Целия файл

@@ -13,7 +13,7 @@ export const mutators = remx.setters({
13 13
   },
14 14
 
15 15
   setAge(age) {
16
-    state.merge({person: {age}});
16
+    state.merge({ person: { age } });
17 17
   }
18 18
 });
19 19
 

+ 9
- 4
jsconfig.json Целия файл

@@ -1,9 +1,14 @@
1 1
 {
2 2
     "compilerOptions": {
3 3
         "allowJs": true,
4
-        "allowSyntheticDefaultImports": true
4
+        "allowSyntheticDefaultImports": true,
5
+        "target": "ES6"
5 6
     },
6 7
     "exclude": [
7
-        "node_modules"
8
-    ]
9
-}
8
+        "node_modules",
9
+        "playground/node_modules"
10
+    ],
11
+    "react-native-tools": {
12
+        "projectRoot": "./"
13
+    }
14
+}

+ 1
- 1
package.json Целия файл

@@ -26,7 +26,7 @@
26 26
   "main": "src/index.js",
27 27
   "scripts": {
28 28
     "build": ":",
29
-    "lint": "eslint src",
29
+    "lint": "eslint src integration scripts playground/src playground/e2e playground/scripts",
30 30
     "test-js": "BABEL_ENV=test jest --coverage",
31 31
     "test-android": "node ./scripts/test.android.js",
32 32
     "test-ios": "node ./scripts/test.ios.js",

+ 1
- 1
playground/e2e/app.test.js Целия файл

@@ -7,7 +7,7 @@ describe('app', () => {
7 7
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
8 8
   });
9 9
 
10
-  xit('switch to tab based app', () => {
10
+  it('switch to tab based app', () => {
11 11
     elementByLabel('Switch to tab based app').tap();
12 12
     expect(elementByLabel('This is a tab screen')).toBeVisible();
13 13
   });

+ 3
- 3
playground/e2e/init.js Целия файл

@@ -5,15 +5,15 @@ const detoxConfig = require('../package.json').detox;
5 5
 
6 6
 detoxConfig['ios-simulator'].app = process.env.detoxAppBuildPath;
7 7
 
8
-before(function(done) {
8
+before(function (done) {
9 9
   detox.config(detoxConfig);
10 10
   detox.start(done);
11 11
 });
12 12
 
13
-afterEach(function(done) {
13
+afterEach(function (done) {
14 14
   detox.waitForTestResult(done);
15 15
 });
16 16
 
17
-after(function(done) {
17
+after(function (done) {
18 18
   detox.cleanup(done);
19 19
 });

+ 1
- 1
playground/src/app.js Целия файл

@@ -1,6 +1,6 @@
1 1
 import Navigation from 'react-native-navigation';
2 2
 
3
-import {registerContainers} from './containers';
3
+import { registerContainers } from './containers';
4 4
 
5 5
 export function start() {
6 6
   registerContainers();

+ 2
- 2
playground/src/containers/SimpleTabScreen.js Целия файл

@@ -1,5 +1,5 @@
1
-import React, {Component} from 'react';
2
-import {View, Text} from 'react-native';
1
+import React, { Component } from 'react';
2
+import { View, Text } from 'react-native';
3 3
 
4 4
 export default class SimpleTabScreen extends Component {
5 5
   render() {

+ 5
- 2
playground/src/containers/WelcomeScreen.js Целия файл

@@ -1,11 +1,14 @@
1
-import React, {Component} from 'react';
2
-import {View, Text} from 'react-native';
1
+import React, { Component } from 'react';
2
+import { View, Text, Button } from 'react-native';
3 3
 
4 4
 export default class WelcomeScreen extends Component {
5 5
   render() {
6 6
     return (
7 7
       <View style={styles.root}>
8 8
         <Text style={styles.h1}>{`React Native Navigation!`}</Text>
9
+        <Button>
10
+          <Text style={styles.h1}>{`Switch to tab based app`}</Text>
11
+        </Button>
9 12
       </View>
10 13
     );
11 14
   }

+ 1
- 1
playground/src/index.js Целия файл

@@ -1,3 +1,3 @@
1
-import {start} from './app';
1
+import { start } from './app';
2 2
 
3 3
 start();

+ 1
- 0
scripts/release.js Целия файл

@@ -1,3 +1,4 @@
1
+/*eslint-disable no-console*/
1 2
 const shellUtils = require('shell-utils');
2 3
 const p = require('path');
3 4
 const semver = require('semver');

+ 1
- 1
src/adapters/NativeCommandsSender.js Целия файл

@@ -1,4 +1,4 @@
1
-import {NativeModules} from 'react-native';
1
+import { NativeModules } from 'react-native';
2 2
 
3 3
 export default class NativeCommandsSender {
4 4
   constructor() {

+ 1
- 1
src/adapters/NativeEventsReceiver.js Целия файл

@@ -1,4 +1,4 @@
1
-import {NativeModules, NativeEventEmitter} from 'react-native';
1
+import { NativeModules, NativeEventEmitter } from 'react-native';
2 2
 
3 3
 export default class NativeEventsReceiver {
4 4
   constructor() {

+ 1
- 1
src/adapters/NativeEventsReceiver.test.js Целия файл

@@ -1,6 +1,6 @@
1 1
 describe('NativeEventsReceiver', () => {
2 2
   let uut;
3
-  const eventEmitterMock = {addListener: jest.fn()};
3
+  const eventEmitterMock = { addListener: jest.fn() };
4 4
 
5 5
   beforeEach(() => {
6 6
     require('react-native').NativeModules.RNNEventEmitter = {};

+ 3
- 3
src/commands/LayoutTreeParser.test.js Целия файл

@@ -4,7 +4,7 @@ describe('LayoutTreeParser', () => {
4 4
   let uut;
5 5
 
6 6
   beforeEach(() => {
7
-    const uniqueIdProvider = {generate: (prefix) => `${prefix}+UNIQUE_ID`};
7
+    const uniqueIdProvider = { generate: (prefix) => `${prefix}+UNIQUE_ID` };
8 8
     const LayoutTreeParser = require('./LayoutTreeParser').default;
9 9
     uut = new LayoutTreeParser(uniqueIdProvider);
10 10
   });
@@ -108,8 +108,8 @@ describe('LayoutTreeParser', () => {
108 108
   });
109 109
 
110 110
   xit('adds uniqueId to containers', () => {
111
-    const input = {container: {}};
112
-    expect(uut.parse(input)).toEqual({container: {id: 'Container+UNIQUE_ID'}});
111
+    const input = { container: {} };
112
+    expect(uut.parse(input)).toEqual({ container: { id: 'Container+UNIQUE_ID' } });
113 113
   });
114 114
 
115 115
   xit('parses side menus', () => {

+ 1
- 1
src/containers/ContainerRegistry.js Целия файл

@@ -1,4 +1,4 @@
1
-import {AppRegistry} from 'react-native';
1
+import { AppRegistry } from 'react-native';
2 2
 import ContainerWrapper from './ContainerWrapper';
3 3
 
4 4
 export default class ContainerRegistry {

+ 3
- 3
src/containers/ContainerRegistry.test.js Целия файл

@@ -1,5 +1,5 @@
1
-import React, {Component} from 'react';
2
-import {AppRegistry, Text} from 'react-native';
1
+import React, { Component } from 'react';
2
+import { AppRegistry, Text } from 'react-native';
3 3
 import renderer from 'react-test-renderer';
4 4
 
5 5
 describe('ContainerRegistry', () => {
@@ -28,7 +28,7 @@ describe('ContainerRegistry', () => {
28 28
   it('resulting in a normal component', () => {
29 29
     uut.registerContainer('example.MyContainer.name', () => MyContainer);
30 30
     const Container = AppRegistry.registerComponent.mock.calls[0][1]();
31
-    const tree = renderer.create(<Container containerId="123"/>);
31
+    const tree = renderer.create(<Container containerId="123" />);
32 32
     expect(tree.toJSON().children).toEqual(['Hello, World!']);
33 33
   });
34 34
 });

+ 3
- 3
src/containers/ContainerWrapper.js Целия файл

@@ -1,4 +1,4 @@
1
-import React, {Component} from 'react';
1
+import React, { Component } from 'react';
2 2
 
3 3
 export default class ContainerWrapper {
4 4
   static wrap(containerName, OriginalContainer, propStore) {
@@ -10,13 +10,13 @@ export default class ContainerWrapper {
10 10
         }
11 11
         this.state = {
12 12
           containerId: props.containerId,
13
-          allProps: {...props, ...propStore.getPropsForContainerId(props.containerId)}
13
+          allProps: { ...props, ...propStore.getPropsForContainerId(props.containerId) }
14 14
         };
15 15
       }
16 16
 
17 17
       componentWillReceiveProps(nextProps) {
18 18
         this.setState({
19
-          allProps: {...nextProps, ...propStore.getPropsForContainerId(this.state.containerId)}
19
+          allProps: { ...nextProps, ...propStore.getPropsForContainerId(this.state.containerId) }
20 20
         });
21 21
       }
22 22
 

+ 17
- 17
src/containers/ContainerWrapper.test.js Целия файл

@@ -1,5 +1,5 @@
1
-import React, {Component} from 'react';
2
-import {AppRegistry, Text} from 'react-native';
1
+import React, { Component } from 'react';
2
+import { AppRegistry, Text } from 'react-native';
3 3
 import renderer from 'react-test-renderer';
4 4
 
5 5
 describe('ContainerWrapper', () => {
@@ -25,13 +25,13 @@ describe('ContainerWrapper', () => {
25 25
       super(props);
26 26
       testParentRef = this; //eslint-disable-line
27 27
       this.ChildClass = props.ChildClass;
28
-      this.state = {propsFromState: {}};
28
+      this.state = { propsFromState: {} };
29 29
     }
30 30
 
31 31
     render() {
32 32
       const Child = this.ChildClass;
33 33
       return (
34
-        <Child containerId="container1" {...this.state.propsFromState}/>
34
+        <Child containerId="container1" {...this.state.propsFromState} />
35 35
       );
36 36
     }
37 37
   }
@@ -45,55 +45,55 @@ describe('ContainerWrapper', () => {
45 45
   it('must have containerId as prop', () => {
46 46
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
47 47
     expect(() => {
48
-      renderer.create(<NavigationContainer/>);
48
+      renderer.create(<NavigationContainer />);
49 49
     }).toThrow(new Error('Container example.MyContainer does not have a containerId!'));
50 50
   });
51 51
 
52 52
   it('wraps the container and saves to store', () => {
53 53
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
54 54
     expect(NavigationContainer).not.toBeInstanceOf(MyContainer);
55
-    const tree = renderer.create(<NavigationContainer containerId={'container1'}/>);
55
+    const tree = renderer.create(<NavigationContainer containerId={'container1'} />);
56 56
     expect(tree.toJSON().children).toEqual(['Hello, World!']);
57 57
     expect(myContainerRef).toBeInstanceOf(MyContainer);
58 58
   });
59 59
 
60 60
   it('injects props from wrapper into original container', () => {
61 61
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
62
-    renderer.create(<NavigationContainer containerId={'container1'} myProp={'yo'}/>);
62
+    renderer.create(<NavigationContainer containerId={'container1'} myProp={'yo'} />);
63 63
     expect(myContainerRef.props.myProp).toEqual('yo');
64 64
   });
65 65
 
66 66
   it('updates props from wrapper into original container', () => {
67 67
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
68
-    renderer.create(<TestParent ChildClass={NavigationContainer}/>);
68
+    renderer.create(<TestParent ChildClass={NavigationContainer} />);
69 69
     expect(myContainerRef.props.foo).toEqual(undefined);
70
-    testParentRef.setState({propsFromState: {foo: 'yo'}});
70
+    testParentRef.setState({ propsFromState: { foo: 'yo' } });
71 71
     expect(myContainerRef.props.foo).toEqual('yo');
72 72
   });
73 73
 
74 74
   it('pulls props from the store and injects them into the inner container', () => {
75
-    store.setPropsForContainerId('container123', {numberProp: 1, stringProp: 'hello', objectProp: {a: 2}});
75
+    store.setPropsForContainerId('container123', { numberProp: 1, stringProp: 'hello', objectProp: { a: 2 } });
76 76
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
77
-    renderer.create(<NavigationContainer containerId={'container123'}/>);
78
-    expect(myContainerRef.props).toEqual({containerId: 'container123', numberProp: 1, stringProp: 'hello', objectProp: {a: 2}});
77
+    renderer.create(<NavigationContainer containerId={'container123'} />);
78
+    expect(myContainerRef.props).toEqual({ containerId: 'container123', numberProp: 1, stringProp: 'hello', objectProp: { a: 2 } });
79 79
   });
80 80
 
81 81
   it('updates props from store into inner container', () => {
82 82
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
83
-    renderer.create(<TestParent ChildClass={NavigationContainer}/>);
84
-    store.setPropsForContainerId('container1', {myProp: 'hello'});
83
+    renderer.create(<TestParent ChildClass={NavigationContainer} />);
84
+    store.setPropsForContainerId('container1', { myProp: 'hello' });
85 85
     expect(myContainerRef.props.foo).toEqual(undefined);
86 86
     expect(myContainerRef.props.myProp).toEqual(undefined);
87
-    testParentRef.setState({propsFromState: {foo: 'yo'}});
87
+    testParentRef.setState({ propsFromState: { foo: 'yo' } });
88 88
     expect(myContainerRef.props.foo).toEqual('yo');
89 89
     expect(myContainerRef.props.myProp).toEqual('hello');
90 90
   });
91 91
 
92 92
   it('protects containerId from change', () => {
93 93
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
94
-    renderer.create(<TestParent ChildClass={NavigationContainer}/>);
94
+    renderer.create(<TestParent ChildClass={NavigationContainer} />);
95 95
     expect(myContainerRef.props.containerId).toEqual('container1');
96
-    testParentRef.setState({propsFromState: {containerId: 'ERROR'}});
96
+    testParentRef.setState({ propsFromState: { containerId: 'ERROR' } });
97 97
     expect(myContainerRef.props.containerId).toEqual('container1');
98 98
   });
99 99
 });

+ 2
- 2
src/containers/Store.test.js Целия файл

@@ -11,8 +11,8 @@ describe('Store', () => {
11 11
   });
12 12
 
13 13
   it('holds props by containerId', () => {
14
-    uut.setPropsForContainerId('container1', {a: 1, b: 2});
15
-    expect(uut.getPropsForContainerId('container1')).toEqual({a: 1, b: 2});
14
+    uut.setPropsForContainerId('container1', { a: 1, b: 2 });
15
+    expect(uut.getPropsForContainerId('container1')).toEqual({ a: 1, b: 2 });
16 16
   });
17 17
 
18 18
   it('defensive for invalid containerId and props', () => {

+ 2
- 2
src/index.test.js Целия файл

@@ -1,11 +1,11 @@
1
-jest.mock('./Navigation', () => ({startApp: () => 'import'}));
1
+jest.mock('./Navigation', () => ({ startApp: () => 'import' }));
2 2
 import Navigation from './index';
3 3
 
4 4
 describe('index', () => {
5 5
   let uut;
6 6
 
7 7
   beforeEach(() => {
8
-    jest.mock('./Navigation', () => ({startApp: () => 'require'}));
8
+    jest.mock('./Navigation', () => ({ startApp: () => 'require' }));
9 9
     uut = require('./index');
10 10
   });
11 11