瀏覽代碼

fix(deps): updated dependancies and types (#847)

* wip

* Update WebViewShared.tsx

* Update config.yml
Thibault Malbranche 5 年之前
父節點
當前提交
85b921ce64
No account linked to committer's email address
共有 8 個檔案被更改,包括 2304 行新增2237 行删除
  1. 1
    1
      .circleci/config.yml
  2. 23
    5
      .eslintrc.js
  3. 20
    21
      package.json
  4. 3
    8
      src/WebView.android.tsx
  5. 3
    8
      src/WebView.ios.tsx
  6. 4
    4
      src/WebViewShared.tsx
  7. 16
    24
      src/WebViewTypes.ts
  8. 2234
    2166
      yarn.lock

+ 1
- 1
.circleci/config.yml 查看文件

@@ -1,7 +1,7 @@
1 1
 defaults: &defaults
2 2
   working_directory: ~/code
3 3
   docker:
4
-    - image: circleci/node:10.6.0-browsers
4
+    - image: circleci/node:12.9.1-browsers
5 5
 
6 6
 version: 2
7 7
 jobs:

+ 23
- 5
.eslintrc.js 查看文件

@@ -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 查看文件

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

+ 3
- 8
src/WebView.android.tsx 查看文件

@@ -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 查看文件

@@ -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
 

+ 4
- 4
src/WebViewShared.tsx 查看文件

@@ -18,7 +18,7 @@ const originWhitelistToRegex = (originWhitelist: string): string =>
18 18
   `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
19 19
 
20 20
 const passesWhitelist = (
21
-  compiledWhitelist: ReadonlyArray<string>,
21
+  compiledWhitelist: readonly string[],
22 22
   url: string,
23 23
 ) => {
24 24
   const origin = extractOrigin(url);
@@ -26,8 +26,8 @@ const passesWhitelist = (
26 26
 };
27 27
 
28 28
 const compileWhitelist = (
29
-  originWhitelist: ReadonlyArray<string>,
30
-): ReadonlyArray<string> =>
29
+  originWhitelist: readonly string[],
30
+): readonly string[] =>
31 31
   ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
32 32
 
33 33
 const createOnShouldStartLoadWithRequest = (
@@ -36,7 +36,7 @@ const createOnShouldStartLoadWithRequest = (
36 36
     url: string,
37 37
     lockIdentifier: number,
38 38
   ) => void,
39
-  originWhitelist: ReadonlyArray<string>,
39
+  originWhitelist: readonly string[],
40 40
   onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
41 41
 ) => {
42 42
   return ({ nativeEvent }: WebViewNavigationEvent) => {

+ 16
- 24
src/WebViewTypes.ts 查看文件

@@ -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
文件差異過大導致無法顯示
查看文件