Thibault Malbranche il y a 5 ans
Parent
révision
ec5aba9d2f
6 fichiers modifiés avec 2299 ajouts et 2232 suppressions
  1. 23
    5
      .eslintrc.js
  2. 20
    21
      package.json
  3. 3
    8
      src/WebView.android.tsx
  4. 3
    8
      src/WebView.ios.tsx
  5. 16
    24
      src/WebViewTypes.ts
  6. 2234
    2166
      yarn.lock

+ 23
- 5
.eslintrc.js Voir le fichier

@@ -20,10 +20,17 @@ module.exports = {
20 20
     // Remove this rule because we only destructure props, but never state
21 21
     'react/destructuring-assignment': 'off',
22 22
     'react/prop-types': 'off',
23
+    'react/jsx-props-no-spreading': 'off',
24
+    'react/static-property-placement': 'off',
25
+    'react/state-in-constructor': 'off',
23 26
     '@typescript-eslint/adjacent-overload-signatures': 'error',
24
-    '@typescript-eslint/array-type': ['error', 'array'],
27
+    '@typescript-eslint/array-type': [
28
+      'error',
29
+      {
30
+        default: 'array',
31
+      },
32
+    ],
25 33
     '@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
26
-    '@typescript-eslint/no-angle-bracket-type-assertion': 'error',
27 34
     '@typescript-eslint/no-array-constructor': 'error',
28 35
     '@typescript-eslint/no-empty-interface': 'error',
29 36
     '@typescript-eslint/no-explicit-any': 'error',
@@ -32,10 +39,18 @@ module.exports = {
32 39
     '@typescript-eslint/no-misused-new': 'error',
33 40
     '@typescript-eslint/no-namespace': 'error',
34 41
     '@typescript-eslint/no-non-null-assertion': 'error',
35
-    '@typescript-eslint/no-object-literal-type-assertion': 'error',
42
+    '@typescript-eslint/consistent-type-assertions': [
43
+      'error',
44
+      {
45
+        assertionStyle: 'as',
46
+      },
47
+    ],
36 48
     '@typescript-eslint/no-parameter-properties': 'error',
37 49
     '@typescript-eslint/no-this-alias': 'error',
38
-    '@typescript-eslint/no-triple-slash-reference': 'error',
50
+    '@typescript-eslint/triple-slash-reference': [
51
+      'error',
52
+      { path: 'never', types: 'never', lib: 'never' },
53
+    ],
39 54
     '@typescript-eslint/no-type-alias': [
40 55
       'error',
41 56
       {
@@ -48,7 +63,10 @@ module.exports = {
48 63
       'error',
49 64
       { ignoreRestSiblings: true },
50 65
     ],
51
-    '@typescript-eslint/prefer-interface': 'error',
66
+    '@typescript-eslint/consistent-type-definitions': [
67
+      'error',
68
+      'interface',
69
+    ],
52 70
     '@typescript-eslint/prefer-namespace-keyword': 'error',
53 71
     '@typescript-eslint/type-annotation-spacing': 'error',
54 72
   },

+ 20
- 21
package.json Voir le fichier

@@ -23,34 +23,33 @@
23 23
     "react-native": ">=0.60 <0.62"
24 24
   },
25 25
   "dependencies": {
26
-    "escape-string-regexp": "1.0.5",
26
+    "escape-string-regexp": "2.0.0",
27 27
     "invariant": "2.2.4"
28 28
   },
29 29
   "devDependencies": {
30
-    "@babel/core": "7.3.4",
31
-    "@semantic-release/git": "7.0.5",
32
-    "@types/escape-string-regexp": "1.0.0",
33
-    "@types/invariant": "^2.2.29",
34
-    "@types/jest": "24.0.11",
30
+    "@babel/core": "7.5.5",
31
+    "@semantic-release/git": "7.0.16",
32
+    "@types/invariant": "^2.2.30",
33
+    "@types/jest": "24.0.18",
35 34
     "@types/react": "16.8.8",
36
-    "@types/react-native": "0.57.40",
37
-    "@typescript-eslint/eslint-plugin": "1.4.2",
38
-    "@typescript-eslint/parser": "1.4.2",
39
-    "babel-eslint": "10.0.1",
40
-    "babel-jest": "^24.0.0",
41
-    "eslint": "5.15.1",
42
-    "eslint-config-airbnb": "17.1.0",
43
-    "eslint-config-prettier": "4.1.0",
44
-    "eslint-plugin-import": "2.16.0",
45
-    "eslint-plugin-jsx-a11y": "6.2.1",
46
-    "eslint-plugin-react": "7.12.4",
47
-    "eslint-plugin-react-native": "3.6.0",
48
-    "jest": "24.5.0",
35
+    "@types/react-native": "0.60.11",
36
+    "@typescript-eslint/eslint-plugin": "2.1.0",
37
+    "@typescript-eslint/parser": "2.1.0",
38
+    "babel-eslint": "10.0.3",
39
+    "babel-jest": "^24.9.0",
40
+    "eslint": "6.3.0",
41
+    "eslint-config-airbnb": "18.0.1",
42
+    "eslint-config-prettier": "6.2.0",
43
+    "eslint-plugin-import": "2.18.2",
44
+    "eslint-plugin-jsx-a11y": "6.2.3",
45
+    "eslint-plugin-react": "7.14.3",
46
+    "eslint-plugin-react-native": "3.7.0",
47
+    "jest": "24.9.0",
49 48
     "metro-react-native-babel-preset": "0.53.1",
50 49
     "react": "16.8.3",
51 50
     "react-native": "0.60.5",
52
-    "semantic-release": "15.10.3",
53
-    "typescript": "3.3.3333"
51
+    "semantic-release": "15.13.24",
52
+    "typescript": "3.6.2"
54 53
   },
55 54
   "repository": {
56 55
     "type": "git",

+ 3
- 8
src/WebView.android.tsx Voir le fichier

@@ -26,12 +26,12 @@ import {
26 26
   AndroidWebViewProps,
27 27
   NativeWebViewAndroid,
28 28
   State,
29
-  CustomUIManager,
29
+  RNCWebViewUIManager,
30 30
 } from './WebViewTypes';
31 31
 
32 32
 import styles from './WebView.styles';
33 33
 
34
-const UIManager = NotTypedUIManager as CustomUIManager;
34
+const UIManager = NotTypedUIManager as RNCWebViewUIManager;
35 35
 
36 36
 const RNCWebView = requireNativeComponent(
37 37
   'RNCWebView',
@@ -73,7 +73,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
73 73
     UIManager.dispatchViewManagerCommand(
74 74
       this.getWebViewHandle(),
75 75
       this.getCommands().goForward,
76
-      null,
77 76
     );
78 77
   };
79 78
 
@@ -81,7 +80,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
81 80
     UIManager.dispatchViewManagerCommand(
82 81
       this.getWebViewHandle(),
83 82
       this.getCommands().goBack,
84
-      null,
85 83
     );
86 84
   };
87 85
 
@@ -92,7 +90,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
92 90
     UIManager.dispatchViewManagerCommand(
93 91
       this.getWebViewHandle(),
94 92
       this.getCommands().reload,
95
-      null,
96 93
     );
97 94
   };
98 95
 
@@ -100,7 +97,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
100 97
     UIManager.dispatchViewManagerCommand(
101 98
       this.getWebViewHandle(),
102 99
       this.getCommands().stopLoading,
103
-      null,
104 100
     );
105 101
   };
106 102
 
@@ -108,7 +104,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
108 104
     UIManager.dispatchViewManagerCommand(
109 105
       this.getWebViewHandle(),
110 106
       this.getCommands().requestFocus,
111
-      null,
112 107
     );
113 108
   };
114 109
 
@@ -268,7 +263,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
268 263
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
269 264
       this.onShouldStartLoadWithRequestCallback,
270 265
       // casting cause it's in the default props
271
-      originWhitelist as ReadonlyArray<string>,
266
+      originWhitelist as readonly string[],
272 267
       onShouldStartLoadWithRequestProp,
273 268
     );
274 269
 

+ 3
- 8
src/WebView.ios.tsx Voir le fichier

@@ -26,12 +26,12 @@ import {
26 26
   NativeWebViewIOS,
27 27
   ViewManager,
28 28
   State,
29
-  CustomUIManager,
29
+  RNCWebViewUIManager,
30 30
 } from './WebViewTypes';
31 31
 
32 32
 import styles from './WebView.styles';
33 33
 
34
-const UIManager = NotTypedUIManager as CustomUIManager;
34
+const UIManager = NotTypedUIManager as RNCWebViewUIManager;
35 35
 
36 36
 const { resolveAssetSource } = Image;
37 37
 const processDecelerationRate = (
@@ -82,7 +82,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
82 82
     UIManager.dispatchViewManagerCommand(
83 83
       this.getWebViewHandle(),
84 84
       this.getCommands().goForward,
85
-      null,
86 85
     );
87 86
   };
88 87
 
@@ -93,7 +92,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
93 92
     UIManager.dispatchViewManagerCommand(
94 93
       this.getWebViewHandle(),
95 94
       this.getCommands().goBack,
96
-      null,
97 95
     );
98 96
   };
99 97
 
@@ -105,7 +103,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
105 103
     UIManager.dispatchViewManagerCommand(
106 104
       this.getWebViewHandle(),
107 105
       this.getCommands().reload,
108
-      null,
109 106
     );
110 107
   };
111 108
 
@@ -116,7 +113,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
116 113
     UIManager.dispatchViewManagerCommand(
117 114
       this.getWebViewHandle(),
118 115
       this.getCommands().stopLoading,
119
-      null,
120 116
     );
121 117
   };
122 118
 
@@ -127,7 +123,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
127 123
     UIManager.dispatchViewManagerCommand(
128 124
       this.getWebViewHandle(),
129 125
       this.getCommands().requestFocus,
130
-      null,
131 126
     );
132 127
   };
133 128
 
@@ -301,7 +296,7 @@ class WebView extends React.Component<IOSWebViewProps, State> {
301 296
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
302 297
       this.onShouldStartLoadWithRequestCallback,
303 298
       // casting cause it's in the default props
304
-      originWhitelist as ReadonlyArray<string>,
299
+      originWhitelist as readonly string[],
305 300
       onShouldStartLoadWithRequestProp,
306 301
     );
307 302
 

+ 16
- 24
src/WebViewTypes.ts Voir le fichier

@@ -1,4 +1,4 @@
1
-/* eslint-disable react/no-multi-comp */
1
+/* eslint-disable react/no-multi-comp, max-classes-per-file */
2 2
 
3 3
 import { ReactElement, Component } from 'react';
4 4
 import {
@@ -11,30 +11,22 @@ import {
11 11
 } from 'react-native';
12 12
 
13 13
 export interface WebViewCommands {
14
-  goForward: Function;
15
-  goBack: Function;
16
-  reload: Function;
17
-  stopLoading: Function;
18
-  postMessage: Function;
19
-  injectJavaScript: Function;
20
-  loadUrl: Function;
21
-  requestFocus: Function;
14
+  goForward: number;
15
+  goBack: number;
16
+  reload: number;
17
+  stopLoading: number;
18
+  postMessage: number;
19
+  injectJavaScript: number;
20
+  loadUrl: number;
21
+  requestFocus: number;
22 22
 }
23 23
 
24
-export interface CustomUIManager extends UIManagerStatic {
24
+export interface RNCWebViewUIManager extends UIManagerStatic {
25 25
   getViewManagerConfig: (
26
-    name: string,
26
+    name: 'RNCWebView',
27 27
   ) => {
28 28
     Commands: WebViewCommands;
29 29
   };
30
-  dispatchViewManagerCommand: (
31
-    viewHandle: number,
32
-    command: Function,
33
-    params: object | null,
34
-  ) => void;
35
-  RNCWebView: {
36
-    Commands: WebViewCommands;
37
-  };
38 30
 }
39 31
 
40 32
 type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
@@ -246,7 +238,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
246 238
   saveFormDataDisabled?: boolean;
247 239
   textZoom?: number;
248 240
   thirdPartyCookiesEnabled?: boolean;
249
-  urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
241
+  urlPrefixesForDefaultIntent?: readonly string[];
250 242
 }
251 243
 
252 244
 export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
@@ -262,7 +254,7 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
262 254
     | 'scrollableAxes'
263 255
     | 'never'
264 256
     | 'always';
265
-  dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
257
+  dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
266 258
   decelerationRate?: number;
267 259
   directionalLockEnabled?: boolean;
268 260
   hideKeyboardAccessoryView?: boolean;
@@ -360,7 +352,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {
360 352
    *
361 353
    * @platform ios
362 354
    */
363
-  dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
355
+  dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
364 356
 
365 357
   /**
366 358
    * Boolean that determines whether HTML5 videos play inline or use the
@@ -500,7 +492,7 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
500 492
    * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
501 493
    * @platform android
502 494
    */
503
-  urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
495
+  urlPrefixesForDefaultIntent?: readonly string[];
504 496
 
505 497
   /**
506 498
    * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
@@ -662,7 +654,7 @@ export interface WebViewSharedProps extends ViewProps {
662 654
    * this whitelist, we will open the URL in Safari.
663 655
    * The default whitelisted origins are "http://*" and "https://*".
664 656
    */
665
-  originWhitelist?: ReadonlyArray<string>;
657
+  originWhitelist?: readonly string[];
666 658
 
667 659
   /**
668 660
    * Function that allows custom handling of any web view requests. Return

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