Parcourir la source

moved to using XO

Daniel Zlotin il y a 7 ans
Parent
révision
f56267e71e

+ 0
- 483
.eslintrc Voir le fichier

@@ -1,483 +0,0 @@
1
-{
2
-  "env": {
3
-    "es6": true,
4
-    "node": true
5
-  },
6
-  "parser": "babel-eslint",
7
-  "parserOptions": {
8
-    "ecmaVersion": 8,
9
-    "sourceType": "module",
10
-    "ecmaFeatures": {
11
-      "impliedStrict": true,
12
-      "jsx": true,
13
-      "experimentalObjectRestSpread": true
14
-    }
15
-  },
16
-  "plugins": [
17
-    "react",
18
-    "react-native",
19
-    "babel"
20
-  ],
21
-  "rules": {
22
-    /*
23
-     *                          possible errors
24
-     */
25
-    "comma-dangle": "error",
26
-    "no-cond-assign": [
27
-      "error",
28
-      "except-parens"
29
-    ],
30
-    "no-console": "error",
31
-    "no-constant-condition": "error",
32
-    "no-control-regex": "error",
33
-    "no-debugger": "warn",
34
-    "no-dupe-args": "error",
35
-    "no-dupe-keys": "error",
36
-    "no-duplicate-case": "error",
37
-    "no-empty": "error",
38
-    "no-empty-character-class": "error",
39
-    "no-ex-assign": "error",
40
-    "no-extra-boolean-cast": "error",
41
-    "no-extra-parens": 0,
42
-    "no-extra-semi": "error",
43
-    "no-func-assign": "error",
44
-    "no-inner-declarations": "error",
45
-    "no-invalid-regexp": "error",
46
-    "no-irregular-whitespace": "error",
47
-    "no-negated-in-lhs": "error",
48
-    "no-obj-calls": "error",
49
-    "no-regex-spaces": "error",
50
-    "no-sparse-arrays": "error",
51
-    "no-unexpected-multiline": "error",
52
-    "no-unreachable": "error",
53
-    "use-isnan": "error",
54
-    "valid-jsdoc": 0,
55
-    "valid-typeof": "error",
56
-    /*
57
-     *                          best practices
58
-     */
59
-    "accessor-pairs": "warn",
60
-    "array-callback-return": 0,
61
-    "block-scoped-var": "error",
62
-    "complexity": 0,
63
-    "consistent-return": "error",
64
-    "curly": [
65
-      "error",
66
-      "all"
67
-    ],
68
-    "default-case": "error",
69
-    "dot-location": [
70
-      "error",
71
-      "property"
72
-    ],
73
-    "dot-notation": "error",
74
-    "eqeqeq": "error",
75
-    "guard-for-in": "error",
76
-    "no-alert": "error",
77
-    "no-caller": "error",
78
-    "no-case-declarations": "error",
79
-    "no-div-regex": 0,
80
-    "no-else-return": 0,
81
-    "no-empty-function": "error",
82
-    "no-empty-pattern": "error",
83
-    "no-eq-null": "error",
84
-    "no-eval": "error",
85
-    "no-extend-native": "error",
86
-    "no-extra-bind": "error",
87
-    "no-extra-label": "error",
88
-    "no-fallthrough": "error",
89
-    "no-floating-decimal": "error",
90
-    "no-implicit-coercion": "error",
91
-    "no-implicit-globals": 0,
92
-    "no-implied-eval": "error",
93
-    "no-invalid-this": 0,
94
-    "no-iterator": "error",
95
-    "no-labels": "error",
96
-    "no-lone-blocks": "error",
97
-    "no-loop-func": "error",
98
-    "no-magic-numbers": 0,
99
-    "no-multi-spaces": "error",
100
-    "no-multi-str": 0,
101
-    "no-native-reassign": "error",
102
-    "no-new": "error",
103
-    "no-new-func": "error",
104
-    "no-new-wrappers": "error",
105
-    "no-octal": "error",
106
-    "no-octal-escape": "error",
107
-    "no-param-reassign": "error",
108
-    "no-proto": "error",
109
-    "no-redeclare": 0,
110
-    "no-return-assign": 0,
111
-    "no-script-url": "error",
112
-    "no-self-assign": "error",
113
-    "no-self-compare": "error",
114
-    "no-sequences": "error",
115
-    "no-throw-literal": "error",
116
-    "no-unmodified-loop-condition": 0,
117
-    "no-unused-expressions": "error",
118
-    "no-unused-labels": 0,
119
-    "no-useless-call": "error",
120
-    "no-useless-concat": "error",
121
-    "no-void": "error",
122
-    "no-warning-comments": 0,
123
-    "no-with": "error",
124
-    "radix": 0,
125
-    "vars-on-top": 0,
126
-    "wrap-iife": "error",
127
-    "yoda": 0,
128
-    "strict": [
129
-      "error",
130
-      "never"
131
-    ],
132
-    /*
133
-     *                           variables
134
-     */
135
-    "init-declarations": 0,
136
-    "no-catch-shadow": "error",
137
-    "no-delete-var": "error",
138
-    "no-label-var": "error",
139
-    "no-restricted-globals": "error",
140
-    "no-shadow": "error",
141
-    "no-shadow-restricted-names": "error",
142
-    "no-undef": 0,
143
-    "no-undef-init": "error",
144
-    "no-undefined": 0,
145
-    "no-unused-vars": 0,
146
-    "no-use-before-define": 0,
147
-    /*
148
-     *                          Node.js
149
-     */
150
-    "callback-return": 0,
151
-    "global-require": 0,
152
-    "handle-callback-err": 0,
153
-    "no-mixed-requires": "error",
154
-    "no-new-require": "error",
155
-    "no-path-concat": "error",
156
-    "no-process-env": 0,
157
-    "no-process-exit": "error",
158
-    "no-restricted-modules": 0,
159
-    "no-sync": 0,
160
-    /*
161
-     *                          style
162
-     */
163
-    "array-bracket-spacing": [
164
-      "error",
165
-      "never"
166
-    ],
167
-    "block-spacing": "error",
168
-    "brace-style": [
169
-      "error",
170
-      "1tbs"
171
-    ],
172
-    "camelcase": [
173
-      "error",
174
-      {
175
-        "properties": "never"
176
-      }
177
-    ],
178
-    "comma-spacing": [
179
-      "error",
180
-      {
181
-        "before": false,
182
-        "after": true
183
-      }
184
-    ],
185
-    "comma-style": [
186
-      "error",
187
-      "last"
188
-    ],
189
-    "computed-property-spacing": [
190
-      "error",
191
-      "never"
192
-    ],
193
-    "consistent-this": [
194
-      "error",
195
-      "self"
196
-    ],
197
-    "eol-last": [
198
-      "error",
199
-      "unix"
200
-    ],
201
-    "func-names": 0,
202
-    "func-style": 0,
203
-    "id-blacklist": 0,
204
-    "id-length": 0,
205
-    "id-match": 0,
206
-    "indent": [
207
-      "error",
208
-      2,
209
-      {
210
-        "SwitchCase": 1
211
-      }
212
-    ],
213
-    "jsx-quotes": "error",
214
-    "key-spacing": [
215
-      "error",
216
-      {
217
-        "singleLine": {
218
-          "beforeColon": false,
219
-          "afterColon": true,
220
-          "mode": "strict"
221
-        },
222
-        "multiLine": {
223
-          "beforeColon": false,
224
-          "afterColon": true,
225
-          "mode": "strict"
226
-        }
227
-      }
228
-    ],
229
-    "keyword-spacing": [
230
-      "error",
231
-      {
232
-        "before": true,
233
-        "after": true
234
-      }
235
-    ],
236
-    "linebreak-style": [
237
-      "error",
238
-      "unix"
239
-    ],
240
-    "lines-around-comment": 0,
241
-    "max-depth": [
242
-      "error",
243
-      4
244
-    ],
245
-    "max-len": [
246
-      "warn",
247
-      150
248
-    ],
249
-    "max-nested-callbacks": [
250
-      "error",
251
-      4
252
-    ],
253
-    "max-params": [
254
-      "error",
255
-      6
256
-    ],
257
-    "max-statements": [
258
-      "error",
259
-      15,
260
-      {
261
-        "ignoreTopLevelFunctions": true
262
-      }
263
-    ],
264
-    "new-cap": [
265
-      "error",
266
-      {
267
-        "capIsNewExceptions": [
268
-          "Immutable"
269
-        ]
270
-      }
271
-    ],
272
-    "new-parens": "error",
273
-    "newline-after-var": 0,
274
-    "newline-before-return": 0,
275
-    "newline-per-chained-call": 0,
276
-    "no-array-constructor": "error",
277
-    "no-bitwise": 0,
278
-    "no-continue": 0,
279
-    "no-inline-comments": 0,
280
-    "no-lonely-if": "error",
281
-    "no-mixed-spaces-and-tabs": 0,
282
-    "no-multiple-empty-lines": [
283
-      "error",
284
-      {
285
-        "max": 1
286
-      }
287
-    ],
288
-    "no-negated-condition": 0,
289
-    "no-nested-ternary": "error",
290
-    "no-new-object": "error",
291
-    "no-plusplus": 0,
292
-    "no-restricted-syntax": 0,
293
-    "no-spaced-func": "error",
294
-    "no-ternary": 0,
295
-    "no-trailing-spaces": [
296
-      "error",
297
-      {
298
-        "skipBlankLines": true
299
-      }
300
-    ],
301
-    "no-underscore-dangle": 0,
302
-    "no-unneeded-ternary": "error",
303
-    "no-whitespace-before-property": "error",
304
-    "object-curly-spacing": [
305
-      "error",
306
-      "always"
307
-    ],
308
-    "one-var": 0,
309
-    "one-var-declaration-per-line": 0,
310
-    "operator-assignment": 0,
311
-    "operator-linebreak": [
312
-      "error",
313
-      "before"
314
-    ],
315
-    "padded-blocks": [
316
-      "error",
317
-      "never"
318
-    ],
319
-    "quote-props": [
320
-      "error",
321
-      "consistent-as-needed"
322
-    ],
323
-    "quotes": 0,
324
-    "require-jsdoc": 0,
325
-    "semi": [
326
-      "error",
327
-      "always"
328
-    ],
329
-    "semi-spacing": [
330
-      "error",
331
-      {
332
-        "before": false,
333
-        "after": true
334
-      }
335
-    ],
336
-    "sort-imports": 0,
337
-    "sort-vars": 0,
338
-    "space-before-blocks": [
339
-      "error",
340
-      "always"
341
-    ],
342
-    "space-in-parens": [
343
-      "error",
344
-      "never"
345
-    ],
346
-    "space-infix-ops": "error",
347
-    "space-unary-ops": "error",
348
-    "spaced-comment": 0,
349
-    "wrap-regex": "error",
350
-    /*
351
-     *                             ECMAScript 6
352
-     */
353
-    "arrow-body-style": 0,
354
-    "arrow-parens": [
355
-      "error",
356
-      "always"
357
-    ],
358
-    "arrow-spacing": [
359
-      "error",
360
-      {
361
-        "before": true,
362
-        "after": true
363
-      }
364
-    ],
365
-    "constructor-super": "error",
366
-    "generator-star-spacing": [
367
-      "error",
368
-      "after"
369
-    ],
370
-    "no-class-assign": "error",
371
-    "no-confusing-arrow": "error",
372
-    "no-const-assign": "error",
373
-    "no-dupe-class-members": "error",
374
-    "no-new-symbol": "error",
375
-    "no-restricted-imports": 0,
376
-    "no-this-before-super": "error",
377
-    "no-useless-constructor": 0,
378
-    "no-var": "error",
379
-    "object-shorthand": 0,
380
-    "prefer-arrow-callback": 0,
381
-    "prefer-const": "error",
382
-    "prefer-reflect": 0,
383
-    "prefer-rest-params": "error",
384
-    "prefer-spread": "error",
385
-    "prefer-template": 0,
386
-    "require-yield": 0,
387
-    "template-curly-spacing": [
388
-      "error",
389
-      "never"
390
-    ],
391
-    "yield-star-spacing": [
392
-      "error",
393
-      "after"
394
-    ],
395
-    /*
396
-     *                              react plugin
397
-     */
398
-    "react/display-name": 0,
399
-    "react/forbid-prop-types": [
400
-      "error",
401
-      {
402
-        "forbid": [
403
-          "any"
404
-        ]
405
-      }
406
-    ],
407
-    "react/no-danger": "error",
408
-    "react/no-deprecated": "error",
409
-    "react/no-did-mount-set-state": "error",
410
-    "react/no-did-update-set-state": "error",
411
-    "react/no-direct-mutation-state": "error",
412
-    "react/no-is-mounted": "error",
413
-    "react/no-multi-comp": "error",
414
-    "react/no-set-state": 0,
415
-    "react/no-string-refs": 0,
416
-    "react/no-unknown-property": 0,
417
-    "react/prefer-es6-class": [
418
-      "error",
419
-      "always"
420
-    ],
421
-    "react/prefer-stateless-function": 0,
422
-    "react/prop-types": 0,
423
-    "react/react-in-jsx-scope": "error",
424
-    "react/require-extension": 0,
425
-    "react/self-closing-comp": "error",
426
-    "react/sort-comp": 0,
427
-    "react/sort-prop-types": 0,
428
-    "react/jsx-wrap-multilines": "error",
429
-    "react/jsx-boolean-value": [
430
-      "error",
431
-      "always"
432
-    ],
433
-    "react/jsx-closing-bracket-location": "error",
434
-    "react/jsx-curly-spacing": [
435
-      "error",
436
-      "never"
437
-    ],
438
-    "react/jsx-equals-spacing": [
439
-      "error",
440
-      "never"
441
-    ],
442
-    "react/jsx-handler-names": [
443
-      "error",
444
-      {
445
-        "eventHandlerPropPrefix": "handle"
446
-      }
447
-    ],
448
-    "react/jsx-indent-props": [
449
-      0,
450
-      2
451
-    ],
452
-    "react/jsx-indent": [
453
-      "error",
454
-      2
455
-    ],
456
-    "react/jsx-key": "error",
457
-    "react/jsx-max-props-per-line": [
458
-      "error",
459
-      {
460
-        "maximum": 2
461
-      }
462
-    ],
463
-    "react/jsx-no-bind": 0,
464
-    "react/jsx-no-duplicate-props": [
465
-      "error",
466
-      {
467
-        "ignoreCase": true
468
-      }
469
-    ],
470
-    "react/jsx-no-literals": "error",
471
-    "react/jsx-no-undef": "error",
472
-    "react/jsx-pascal-case": "error",
473
-    "react/jsx-sort-props": 0,
474
-    "react/jsx-space-before-closing": 0,
475
-    "react/jsx-uses-react": "error",
476
-    "react/jsx-uses-vars": "error",
477
-    /*
478
-     *                              react-native plugin
479
-     */
480
-    "react-native/no-unused-styles": "error",
481
-    "react-native/split-platform-components": "error"
482
-  }
483
-}

+ 2
- 2
README.md Voir le fichier

@@ -344,11 +344,11 @@ class LifecycleScreen extends Component {
344 344
   }
345 345
 
346 346
   onStop() {
347
-    alert('onStop'); //eslint-disable-line
347
+    alert('onStop');
348 348
   }
349 349
 
350 350
   componentWillUnmount() {
351
-    alert('componentWillUnmount'); //eslint-disable-line
351
+    alert('componentWillUnmount');
352 352
   }
353 353
 
354 354
   render() {

+ 1
- 0
e2e/Modals.test.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 const Utils = require('./Utils');
2
+
2 3
 const elementByLabel = Utils.elementByLabel;
3 4
 
4 5
 describe('modal', () => {

+ 1
- 0
e2e/ScreenStack.test.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 const Utils = require('./Utils');
2
+
2 3
 const elementByLabel = Utils.elementByLabel;
3 4
 
4 5
 describe('screen stack', () => {

+ 1
- 0
e2e/ScreenStyle.test.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 const Utils = require('./Utils');
2
+
2 3
 const elementByLabel = Utils.elementByLabel;
3 4
 
4 5
 describe('screen style', () => {

+ 1
- 0
e2e/TopLevelApi.test.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 const Utils = require('./Utils');
2
+
2 3
 const elementByLabel = Utils.elementByLabel;
3 4
 
4 5
 describe('top level api', () => {

+ 1
- 2
e2e/init.js Voir le fichier

@@ -1,4 +1,3 @@
1
-/*eslint-disable*/
2 1
 require('babel-polyfill');
3 2
 const detox = require('detox');
4 3
 
@@ -11,7 +10,7 @@ before(async () => {
11 10
         name: 'iPhone 7'
12 11
       }
13 12
     }
14
-  }
13
+  };
15 14
   await detox.init(detoxConfig);
16 15
 });
17 16
 

+ 1
- 0
integration/env.test.js Voir le fichier

@@ -1,4 +1,5 @@
1 1
 import * as _ from 'lodash';
2
+
2 3
 describe('test environment', () => {
3 4
   it('handles object spread', () => {
4 5
     const { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };

+ 3
- 10
integration/remx/component.js Voir le fichier

@@ -6,19 +6,12 @@ import { connect } from 'remx/react-native';
6 6
 import * as store from './store';
7 7
 
8 8
 class MyContainer extends Component {
9
-  constructor(props) {
10
-    super(props);
11
-  }
12
-
13 9
   render() {
14 10
     if (this.props.renderCountIncrement) {
15 11
       this.props.renderCountIncrement();
16 12
     }
17
-    if (this.props.printAge) {
18
-      return this.renderText(this.props.age);
19
-    } else {
20
-      return this.renderText(this.props.name);
21
-    }
13
+
14
+    return this.renderText(this.props.printAge ? this.props.age : this.props.name);
22 15
   }
23 16
 
24 17
   renderText(txt) {
@@ -28,7 +21,7 @@ class MyContainer extends Component {
28 21
   }
29 22
 }
30 23
 
31
-function mapStateToProps(ownProps) {
24
+function mapStateToProps() {
32 25
   return {
33 26
     name: store.getters.getName(),
34 27
     age: store.getters.getAge()

+ 2
- 4
integration/remx/remx.test.js Voir le fichier

@@ -1,6 +1,6 @@
1
-import React from 'react';
1
+const React = require('react');
2 2
 require('react-native');
3
-import renderer from 'react-test-renderer';
3
+const renderer = require('react-test-renderer');
4 4
 
5 5
 describe('remx support', () => {
6 6
   let MyConnectedContainer;
@@ -20,7 +20,6 @@ describe('remx support', () => {
20 20
   it('rerenders as a result of an underlying state change (by selector)', () => {
21 21
     const renderCountIncrement = jest.fn();
22 22
     const tree = renderer.create(<MyConnectedContainer renderCountIncrement={renderCountIncrement} />);
23
-    const instance = tree.getInstance();
24 23
 
25 24
     expect(tree.toJSON().children).toEqual(['no name']);
26 25
     expect(renderCountIncrement).toHaveBeenCalledTimes(1);
@@ -35,7 +34,6 @@ describe('remx support', () => {
35 34
   it('rerenders as a result of an underlying state change with a new key using merge', () => {
36 35
     const renderCountIncrement = jest.fn();
37 36
     const tree = renderer.create(<MyConnectedContainer printAge={true} renderCountIncrement={renderCountIncrement} />);
38
-    const instance = tree.getInstance();
39 37
 
40 38
     expect(tree.toJSON().children).toEqual(null);
41 39
     expect(renderCountIncrement).toHaveBeenCalledTimes(1);

+ 8
- 8
lib/src/commands/Commands.test.js Voir le fichier

@@ -66,15 +66,15 @@ describe('Commands', () => {
66 66
 
67 67
   describe('setOptions', () => {
68 68
     it('deep clones input to avoid mutation errors', () => {
69
-      const obj = { title: "test" };
69
+      const obj = { title: 'test' };
70 70
       uut.setOptions('theContainerId', obj);
71 71
       expect(mockCommandsSender.setOptions.mock.calls[0][1]).not.toBe(obj);
72 72
     });
73 73
 
74 74
     it('passes options for container', () => {
75
-      uut.setOptions('theContainerId', { title: "1" });
75
+      uut.setOptions('theContainerId', { title: '1' });
76 76
       expect(mockCommandsSender.setOptions).toHaveBeenCalledTimes(1);
77
-      expect(mockCommandsSender.setOptions).toHaveBeenCalledWith('theContainerId', { title: "1" });
77
+      expect(mockCommandsSender.setOptions).toHaveBeenCalledWith('theContainerId', { title: '1' });
78 78
     });
79 79
   });
80 80
 
@@ -87,14 +87,14 @@ describe('Commands', () => {
87 87
       });
88 88
       expect(mockCommandsSender.showModal).toHaveBeenCalledTimes(1);
89 89
       expect(mockCommandsSender.showModal).toHaveBeenCalledWith({
90
-        type: "ContainerStack",
91
-        id: "ContainerStack+UNIQUE_ID",
90
+        type: 'ContainerStack',
91
+        id: 'ContainerStack+UNIQUE_ID',
92 92
         data: {},
93 93
         children: [{
94
-          type: "Container",
95
-          id: "Container+UNIQUE_ID",
94
+          type: 'Container',
95
+          id: 'Container+UNIQUE_ID',
96 96
           data: {
97
-            name: "com.example.MyScreen",
97
+            name: 'com.example.MyScreen',
98 98
             navigationOptions: {}
99 99
           },
100 100
           children: []

+ 0
- 1
lib/src/commands/LayoutTreeCrawler.js Voir le fichier

@@ -1,5 +1,4 @@
1 1
 import _ from 'lodash';
2
-import { processColor } from 'react-native';
3 2
 import LayoutTypes from './LayoutTypes';
4 3
 import optionsProcessor from './OptionsProcessor';
5 4
 

+ 10
- 4
lib/src/commands/LayoutTreeCrawler.test.js Voir le fichier

@@ -50,7 +50,9 @@ describe('LayoutTreeCrawler', () => {
50 50
   it('Containers: injects navigationOptions from original container class static property', () => {
51 51
     const theStyle = {};
52 52
     const MyContainer = class {
53
-      static navigationOptions = theStyle;
53
+      static get navigationOptions() {
54
+        return theStyle;
55
+      }
54 56
     };
55 57
 
56 58
     const node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
@@ -62,7 +64,9 @@ describe('LayoutTreeCrawler', () => {
62 64
   it('Containers: deepClones navigationOptions', () => {
63 65
     const theStyle = {};
64 66
     const MyContainer = class {
65
-      static navigationOptions = theStyle;
67
+      static get navigationOptions() {
68
+        return theStyle;
69
+      }
66 70
     };
67 71
 
68 72
     const node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
@@ -93,7 +97,9 @@ describe('LayoutTreeCrawler', () => {
93 97
     beforeEach(() => {
94 98
       navigationOptions = {};
95 99
       MyContainer = class {
96
-        static navigationOptions = navigationOptions;
100
+        static get navigationOptions() {
101
+          return navigationOptions;
102
+        }
97 103
       };
98 104
       node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
99 105
       store.setOriginalContainerClassForName('theContainerName', MyContainer);
@@ -154,7 +160,7 @@ describe('LayoutTreeCrawler', () => {
154 160
     });
155 161
 
156 162
     it('keys ending with Color case sensitive', () => {
157
-      navigationOptions.otherKey_color = 'red';
163
+      navigationOptions.otherKey_color = 'red'; // eslint-disable-line camelcase
158 164
       uut.crawl(node);
159 165
       expect(node.data.navigationOptions.otherKey_color).toEqual('red');
160 166
     });

+ 2
- 2
lib/src/commands/OptionsProcessor.test.js Voir le fichier

@@ -1,5 +1,5 @@
1 1
 import optionsProcessor from './OptionsProcessor';
2
- 
2
+
3 3
 describe('navigation options', () => {
4 4
   let navigationOptions;
5 5
 
@@ -63,7 +63,7 @@ describe('navigation options', () => {
63 63
   });
64 64
 
65 65
   it('keys ending with Color case sensitive', () => {
66
-    navigationOptions.otherKey_color = 'red';
66
+    navigationOptions.otherKey_color = 'red'; // eslint-disable-line camelcase
67 67
     optionsProcessor(navigationOptions);
68 68
     expect(navigationOptions.otherKey_color).toEqual('red');
69 69
   });

+ 1
- 1
lib/src/commands/SimpleLayouts.js Voir le fichier

@@ -14,7 +14,7 @@ export const passProps = {
14 14
 export const singleScreenWithAditionalParams = {
15 15
   container: {
16 16
     name: 'com.example.MyScreen',
17
-    passProps: passProps,
17
+    passProps,
18 18
     style: {},
19 19
     buttons: {}
20 20
   }

+ 15
- 18
lib/src/containers/ContainerWrapper.test.js Voir le fichier

@@ -1,6 +1,6 @@
1 1
 /* eslint-disable consistent-this, react/no-multi-comp */
2 2
 import React, { Component } from 'react';
3
-import { AppRegistry, Text } from 'react-native';
3
+import { Text } from 'react-native';
4 4
 import renderer from 'react-test-renderer';
5 5
 
6 6
 import ContainerWrapper from './ContainerWrapper';
@@ -9,12 +9,9 @@ import Store from './Store';
9 9
 describe('ContainerWrapper', () => {
10 10
   let store;
11 11
   const containerName = 'example.MyContainer';
12
+  let childRef;
12 13
 
13 14
   class MyContainer extends Component {
14
-    constructor(props) {
15
-      super(props);
16
-    }
17
-
18 15
     render() {
19 16
       return <Text>{'Hello, World!'}</Text>;
20 17
     }
@@ -31,7 +28,7 @@ describe('ContainerWrapper', () => {
31 28
       const Child = this.ChildClass;
32 29
       return (
33 30
         <Child
34
-          ref="child"
31
+          ref={(r) => childRef = r}
35 32
           containerId="container1"
36 33
           {...this.state.propsFromState}
37 34
         />
@@ -45,12 +42,12 @@ describe('ContainerWrapper', () => {
45 42
 
46 43
   it('must have containerId as prop', () => {
47 44
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
48
-    const orig = console.error; //eslint-disable-line
49
-    console.error = (a) => a; //eslint-disable-line
45
+    const orig = console.error;
46
+    console.error = (a) => a;
50 47
     expect(() => {
51 48
       renderer.create(<NavigationContainer />);
52 49
     }).toThrow(new Error('Container example.MyContainer does not have a containerId!'));
53
-    console.error = orig; //eslint-disable-line
50
+    console.error = orig;
54 51
   });
55 52
 
56 53
   it('wraps the container', () => {
@@ -70,16 +67,16 @@ describe('ContainerWrapper', () => {
70 67
   it('updates props from wrapper into original container', () => {
71 68
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
72 69
     const tree = renderer.create(<TestParent ChildClass={NavigationContainer} />);
73
-    expect(tree.getInstance().refs.child.props.foo).toEqual(undefined);
70
+    expect(childRef.props.foo).toEqual(undefined);
74 71
     tree.getInstance().setState({ propsFromState: { foo: 'yo' } });
75
-    expect(tree.getInstance().refs.child.props.foo).toEqual('yo');
72
+    expect(childRef.props.foo).toEqual('yo');
76 73
   });
77 74
 
78 75
   it('pulls props from the store and injects them into the inner container', () => {
79 76
     store.setPropsForContainerId('container123', { numberProp: 1, stringProp: 'hello', objectProp: { a: 2 } });
80 77
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
81 78
     const tree = renderer.create(<NavigationContainer containerId={'container123'} />);
82
-    originalContainerProps = tree.getInstance().originalContainerRef.props;
79
+    const originalContainerProps = tree.getInstance().originalContainerRef.props;
83 80
     expect(originalContainerProps).toEqual({ containerId: 'container123', numberProp: 1, stringProp: 'hello', objectProp: { a: 2 } });
84 81
   });
85 82
 
@@ -87,19 +84,19 @@ describe('ContainerWrapper', () => {
87 84
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
88 85
     const tree = renderer.create(<TestParent ChildClass={NavigationContainer} />);
89 86
     store.setPropsForContainerId('container1', { myProp: 'hello' });
90
-    expect(tree.getInstance().refs.child.originalContainerRef.props.foo).toEqual(undefined);
91
-    expect(tree.getInstance().refs.child.originalContainerRef.props.myProp).toEqual(undefined);
87
+    expect(childRef.originalContainerRef.props.foo).toEqual(undefined);
88
+    expect(childRef.originalContainerRef.props.myProp).toEqual(undefined);
92 89
     tree.getInstance().setState({ propsFromState: { foo: 'yo' } });
93
-    expect(tree.getInstance().refs.child.originalContainerRef.props.foo).toEqual('yo');
94
-    expect(tree.getInstance().refs.child.originalContainerRef.props.myProp).toEqual('hello');
90
+    expect(childRef.originalContainerRef.props.foo).toEqual('yo');
91
+    expect(childRef.originalContainerRef.props.myProp).toEqual('hello');
95 92
   });
96 93
 
97 94
   it('protects id from change', () => {
98 95
     const NavigationContainer = ContainerWrapper.wrap(containerName, MyContainer, store);
99 96
     const tree = renderer.create(<TestParent ChildClass={NavigationContainer} />);
100
-    expect(tree.getInstance().refs.child.originalContainerRef.props.containerId).toEqual('container1');
97
+    expect(childRef.originalContainerRef.props.containerId).toEqual('container1');
101 98
     tree.getInstance().setState({ propsFromState: { id: 'ERROR' } });
102
-    expect(tree.getInstance().refs.child.originalContainerRef.props.containerId).toEqual('container1');
99
+    expect(childRef.originalContainerRef.props.containerId).toEqual('container1');
103 100
   });
104 101
 
105 102
   it('assignes key by id', () => {

+ 1
- 0
lib/src/containers/Lifecycle.test.js Voir le fichier

@@ -2,6 +2,7 @@ import Lifecycle from './Lifecycle';
2 2
 import Store from '../containers/Store';
3 3
 
4 4
 describe('Lifecycle', () => {
5
+  let store;
5 6
   let uut;
6 7
   let mockRef;
7 8
 

+ 0
- 1
lib/src/events/PrivateEventsListener.js Voir le fichier

@@ -1,4 +1,3 @@
1
-import _ from 'lodash';
2 1
 import Lifecycle from '../containers/Lifecycle';
3 2
 
4 3
 export default class PrivateEventsListener {

+ 0
- 1
lib/src/events/PrivateEventsListener.test.js Voir le fichier

@@ -1,4 +1,3 @@
1
-import _ from 'lodash';
2 1
 import PrivateEventsListener from './PrivateEventsListener';
3 2
 import NativeEventsReceiver from '../adapters/NativeEventsReceiver.mock';
4 3
 import Store from '../containers/Store';

+ 78
- 5
package.json Voir le fichier

@@ -48,18 +48,17 @@
48 48
     "lodash": "4.x.x"
49 49
   },
50 50
   "devDependencies": {
51
+    "xo": "0.18.x",
52
+    "eslint-config-xo": "0.18.x",
53
+    "eslint-config-xo-react": "0.13.x",
54
+    "eslint-plugin-react": "7.x.x",
51 55
     "babel-cli": "6.x.x",
52 56
     "babel-core": "6.x.x",
53
-    "babel-eslint": "7.x.x",
54 57
     "babel-jest": "20.x.x",
55 58
     "babel-polyfill": "6.x.x",
56 59
     "babel-preset-react-native": "2.x.x",
57 60
     "babel-register": "6.x.x",
58 61
     "detox": "5.x.x",
59
-    "eslint": "4.x.x",
60
-    "eslint-plugin-babel": "4.x.x",
61
-    "eslint-plugin-react": "7.x.x",
62
-    "eslint-plugin-react-native": "2.x.x",
63 62
     "jest": "20.x.x",
64 63
     "jest-cli": "20.x.x",
65 64
     "mocha": "3.x.x",
@@ -104,5 +103,79 @@
104 103
         "statements": 100
105 104
       }
106 105
     }
106
+  },
107
+  "xo": {
108
+    "extends": "xo-react",
109
+    "space": true,
110
+    "env": [
111
+      "node",
112
+      "jest",
113
+      "es6"
114
+    ],
115
+    "globals": [
116
+      "alert"
117
+    ],
118
+    "overrides": [
119
+      {
120
+        "files": "e2e/**/*",
121
+        "env": [
122
+          "mocha"
123
+        ],
124
+        "globals": [
125
+          "before",
126
+          "after",
127
+          "beforeEach",
128
+          "afterEach",
129
+          "expect",
130
+          "element",
131
+          "by",
132
+          "device"
133
+        ]
134
+      }
135
+    ],
136
+    "settings": {
137
+      "import/core-modules": [
138
+        "react-native-navigation"
139
+      ]
140
+    },
141
+    "rules": {
142
+      "unicorn/filename-case": 0,
143
+      "unicorn/number-literal-case": 0,
144
+      "import/order": 0,
145
+      "import/no-unassigned-import": 0,
146
+      "import/no-unresolved": [
147
+        2,
148
+        {
149
+          "ignore": [
150
+            "react-native-navigation"
151
+          ]
152
+        }
153
+      ],
154
+      "react/jsx-tag-spacing": 0,
155
+      "react/jsx-sort-props": 0,
156
+      "react/jsx-boolean-value": 0,
157
+      "react/prop-types": 0,
158
+      "react/jsx-no-bind": 0,
159
+      "react/jsx-handler-names": 0,
160
+      "react/forbid-component-props": 0,
161
+      "capitalized-comments": 0,
162
+      "no-use-before-define": [
163
+        2,
164
+        {
165
+          "functions": false,
166
+          "variables": false
167
+        }
168
+      ],
169
+      "promise/param-names": 0,
170
+      "no-return-assign": 0,
171
+      "arrow-parens": [
172
+        2,
173
+        "always"
174
+      ],
175
+      "object-curly-spacing": [
176
+        2,
177
+        "always"
178
+      ]
179
+    }
107 180
   }
108 181
 }

+ 5
- 1
playground/src/app.js Voir le fichier

@@ -2,7 +2,7 @@ import Navigation from 'react-native-navigation';
2 2
 
3 3
 import { registerContainers } from './containers';
4 4
 
5
-export function start() {
5
+function start() {
6 6
   registerContainers();
7 7
 
8 8
   Navigation.events().onAppLaunched(() => {
@@ -13,3 +13,7 @@ export function start() {
13 13
     });
14 14
   });
15 15
 }
16
+
17
+module.exports = {
18
+  start
19
+};

+ 2
- 2
playground/src/containers/LifecycleScreen.js Voir le fichier

@@ -17,11 +17,11 @@ class LifecycleScreen extends Component {
17 17
   }
18 18
 
19 19
   onStop() {
20
-    alert('onStop'); //eslint-disable-line
20
+    alert('onStop'); // eslint-disable-line no-alert
21 21
   }
22 22
 
23 23
   componentWillUnmount() {
24
-    alert('componentWillUnmount'); //eslint-disable-line
24
+    alert('componentWillUnmount'); // eslint-disable-line no-alert
25 25
   }
26 26
 
27 27
   render() {

+ 0
- 1
playground/src/containers/ModalScreen.js Voir le fichier

@@ -1,7 +1,6 @@
1 1
 import _ from 'lodash';
2 2
 import React, { Component } from 'react';
3 3
 import {
4
-  StyleSheet,
5 4
   View,
6 5
   Text,
7 6
   Button

+ 7
- 7
playground/src/containers/OptionsScreen.js Voir le fichier

@@ -1,7 +1,5 @@
1
-import _ from 'lodash';
2 1
 import React, { Component } from 'react';
3 2
 import {
4
-  StyleSheet,
5 3
   View,
6 4
   Text,
7 5
   Button
@@ -10,10 +8,12 @@ import {
10 8
 import Navigation from 'react-native-navigation';
11 9
 
12 10
 class OptionsScreen extends Component {
13
-  static navigationOptions = {
14
-    title: 'Static Title',
15
-    topBarBackgroundColor: "red",
16
-    topBarTextFontFamily: "HelveticaNeue-Italic"
11
+  static get navigationOptions() {
12
+    return {
13
+      title: 'Static Title',
14
+      topBarBackgroundColor: 'red',
15
+      topBarTextFontFamily: 'HelveticaNeue-Italic'
16
+    };
17 17
   }
18 18
 
19 19
   constructor(props) {
@@ -36,7 +36,7 @@ class OptionsScreen extends Component {
36 36
       title: 'Dynamic Title',
37 37
       topBarTextColor: '#00FFFF',
38 38
       topBarBackgroundColor: 'green',
39
-      topBarTextFontFamily: "HelveticaNeue-CondensedBold"
39
+      topBarTextFontFamily: 'HelveticaNeue-CondensedBold'
40 40
     });
41 41
   }
42 42
 }

+ 0
- 1
playground/src/containers/PushedScreen.js Voir le fichier

@@ -1,7 +1,6 @@
1 1
 import _ from 'lodash';
2 2
 import React, { Component } from 'react';
3 3
 import {
4
-  StyleSheet,
5 4
   View,
6 5
   Text,
7 6
   Button

+ 1
- 2
playground/src/containers/TextScreen.js Voir le fichier

@@ -1,7 +1,6 @@
1 1
 import _ from 'lodash/math';
2 2
 import React, { Component } from 'react';
3 3
 import {
4
-  StyleSheet,
5 4
   View,
6 5
   Text,
7 6
   Button
@@ -15,7 +14,7 @@ class TextScreen extends Component {
15 14
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
16 15
         {this.renderTextFromFunctionInProps()}
17 16
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
18
-        <Button title={"setTabBadge"} onPress={() => this.onButtonPress()}/>
17
+        <Button title={'setTabBadge'} onPress={() => this.onButtonPress()}/>
19 18
       </View>
20 19
     );
21 20
   }

+ 5
- 1
playground/src/containers/index.js Voir le fichier

@@ -7,7 +7,7 @@ import LifecycleScreen from './LifecycleScreen';
7 7
 import ModalScreen from './ModalScreen';
8 8
 import OptionsScreen from './OptionsScreen';
9 9
 
10
-export function registerContainers() {
10
+function registerContainers() {
11 11
   Navigation.registerContainer(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
12 12
   Navigation.registerContainer(`navigation.playground.ModalScreen`, () => ModalScreen);
13 13
   Navigation.registerContainer(`navigation.playground.LifecycleScreen`, () => LifecycleScreen);
@@ -15,3 +15,7 @@ export function registerContainers() {
15 15
   Navigation.registerContainer(`navigation.playground.PushedScreen`, () => PushedScreen);
16 16
   Navigation.registerContainer(`navigation.playground.OptionsScreen`, () => OptionsScreen);
17 17
 }
18
+
19
+module.exports = {
20
+  registerContainers
21
+};

+ 5
- 8
scripts/release.js Voir le fichier

@@ -1,6 +1,5 @@
1
-/*eslint-disable no-console*/
1
+/* eslint-disable no-console */
2 2
 const exec = require('shell-utils').exec;
3
-const p = require('path');
4 3
 const semver = require('semver');
5 4
 const fs = require('fs');
6 5
 const _ = require('lodash');
@@ -70,19 +69,17 @@ function findCurrentPublishedVersion() {
70 69
 
71 70
 function tryPublishAndTag(version) {
72 71
   let theCandidate = version;
73
-  let retry = 0;
74
-  while (retry < 5) {
72
+  for (let retry = 0; retry < 5; retry++) {
75 73
     try {
76 74
       tagAndPublish(theCandidate);
77 75
       console.log(`Released ${theCandidate}`);
78 76
       return;
79
-    } catch (e) {
80
-      const alreadyPublished = _.includes(e.toString(), 'You cannot publish over the previously published version');
77
+    } catch (err) {
78
+      const alreadyPublished = _.includes(err.toString(), 'You cannot publish over the previously published version');
81 79
       if (!alreadyPublished) {
82
-        throw e;
80
+        throw err;
83 81
       }
84 82
       console.log(`previously published. retrying with increased ${VERSION_INC}...`);
85
-      retry++;
86 83
       theCandidate = semver.inc(theCandidate, VERSION_INC);
87 84
     }
88 85
   }

+ 11
- 1
scripts/test-js.js Voir le fichier

@@ -1,8 +1,18 @@
1 1
 const exec = require('shell-utils').exec;
2
+const _ = require('lodash');
3
+
4
+const dirs = [
5
+  'lib/src',
6
+  'integration',
7
+  'e2e',
8
+  'scripts',
9
+  'playground/src'
10
+];
2 11
 
3 12
 run();
4 13
 
5 14
 function run() {
6
-  exec.execSync(`BABEL_ENV=test eslint lib/src integration e2e scripts playground/src`);
15
+  const paths = _.chain(dirs).map((d) => `${d}/**/**/**/**/**/**/*`).join(' ').value();
16
+  exec.execSync(`BABEL_ENV=test xo ${paths}`);
7 17
   exec.execSync(`BABEL_ENV=test jest --coverage`);
8 18
 }

+ 1
- 1
scripts/test.all.js Voir le fichier

@@ -1,4 +1,4 @@
1
-/* eslint no-console:0 */
1
+/* eslint-disable no-console */
2 2
 const exec = require('shell-utils').exec;
3 3
 
4 4
 async function run() {

+ 22
- 22
scripts/test.e2e.android.js Voir le fichier

@@ -1,12 +1,12 @@
1
-/*eslint-disable no-console*/
1
+/* eslint-disable no-console */
2 2
 const _ = require('lodash');
3 3
 const exec = require('shell-utils').exec;
4 4
 
5
-const avdName = 'pixel';
6
-const sdk = 'android-24';
7
-const apis = 'default';
8
-const abi = 'armeabi-v7a';
9
-const packageName = `system-images;${sdk};${apis};${abi}`;
5
+// const avdName = 'pixel';
6
+// const sdk = 'android-24';
7
+// const apis = 'default';
8
+// const abi = 'armeabi-v7a';
9
+// const packageName = `system-images;${sdk};${apis};${abi}`;
10 10
 
11 11
 const release = _.includes(process.argv, 'release');
12 12
 
@@ -30,19 +30,19 @@ function runTests() {
30 30
   exec.execSync(`cd AndroidE2E && ./gradlew ${filterParam} connectedDebugAndroidTest`);
31 31
 }
32 32
 
33
-function installEmulator() {
34
-  exec.execSync(`sdkmanager "emulator"`);
35
-  exec.execSync(`sdkmanager "${packageName}"`);
36
-  exec.execSync(`echo no | avdmanager create avd --force --name "${avdName}" --abi "${apis}/${abi}" --package "${packageName}" --device "pixel"`);
37
-  exec.execSync(`avdmanager list avd`);
38
-}
39
-
40
-function launchEmulator() {
41
-  console.log(`Launching Android Emulator`);
42
-  exec.execSync(`cd $ANDROID_HOME/tools && ./emulator -skin 1080x1920 -gpu host -no-audio @${avdName}`);
43
-  exec.execSync(`./scripts/waitForAndroidEmulator.sh`);
44
-}
45
-
46
-function killEmulators() {
47
-  exec.execSync(`adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done`);
48
-}
33
+// function installEmulator() {
34
+//   exec.execSync(`sdkmanager "emulator"`);
35
+//   exec.execSync(`sdkmanager "${packageName}"`);
36
+//   exec.execSync(`echo no | avdmanager create avd --force --name "${avdName}" --abi "${apis}/${abi}" --package "${packageName}" --device "pixel"`);
37
+//   exec.execSync(`avdmanager list avd`);
38
+// }
39
+
40
+// function launchEmulator() {
41
+//   console.log(`Launching Android Emulator`);
42
+//   exec.execSync(`cd $ANDROID_HOME/tools && ./emulator -skin 1080x1920 -gpu host -no-audio @${avdName}`);
43
+//   exec.execSync(`./scripts/waitForAndroidEmulator.sh`);
44
+// }
45
+
46
+// function killEmulators() {
47
+//   exec.execSync(`adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done`);
48
+// }

+ 2
- 2
v1tov2diff.md Voir le fichier

@@ -307,11 +307,11 @@ class LifecycleScreen extends Component {
307 307
   }
308 308
 
309 309
   onStop() {
310
-    alert('onStop'); //eslint-disable-line
310
+    alert('onStop');
311 311
   }
312 312
 
313 313
   componentWillUnmount() {
314
-    alert('componentWillUnmount'); //eslint-disable-line
314
+    alert('componentWillUnmount');
315 315
   }
316 316
 
317 317
   render() {

+ 0
- 2
wallaby.js Voir le fichier

@@ -1,5 +1,3 @@
1
-/*eslint-disable*/
2
-'use strict';
3 1
 process.env.BABEL_ENV = 'test';
4 2
 const babelOptions = require('./package.json').babel.env.test;
5 3
 module.exports = function (wallaby) {

+ 916
- 220
yarn.lock
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier