Skip to content

Commit 85b921c

Browse files
authored
fix(deps): updated dependancies and types (react-native-webview#847)
* wip * Update WebViewShared.tsx * Update config.yml
1 parent 36ffbe0 commit 85b921c

File tree

8 files changed

+2304
-2237
lines changed

8 files changed

+2304
-2237
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defaults: &defaults
22
working_directory: ~/code
33
docker:
4-
- image: circleci/node:10.6.0-browsers
4+
- image: circleci/node:12.9.1-browsers
55

66
version: 2
77
jobs:

.eslintrc.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ module.exports = {
2020
// Remove this rule because we only destructure props, but never state
2121
'react/destructuring-assignment': 'off',
2222
'react/prop-types': 'off',
23+
'react/jsx-props-no-spreading': 'off',
24+
'react/static-property-placement': 'off',
25+
'react/state-in-constructor': 'off',
2326
'@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+
],
2533
'@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
26-
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
2734
'@typescript-eslint/no-array-constructor': 'error',
2835
'@typescript-eslint/no-empty-interface': 'error',
2936
'@typescript-eslint/no-explicit-any': 'error',
@@ -32,10 +39,18 @@ module.exports = {
3239
'@typescript-eslint/no-misused-new': 'error',
3340
'@typescript-eslint/no-namespace': 'error',
3441
'@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+
],
3648
'@typescript-eslint/no-parameter-properties': 'error',
3749
'@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+
],
3954
'@typescript-eslint/no-type-alias': [
4055
'error',
4156
{
@@ -48,7 +63,10 @@ module.exports = {
4863
'error',
4964
{ ignoreRestSiblings: true },
5065
],
51-
'@typescript-eslint/prefer-interface': 'error',
66+
'@typescript-eslint/consistent-type-definitions': [
67+
'error',
68+
'interface',
69+
],
5270
'@typescript-eslint/prefer-namespace-keyword': 'error',
5371
'@typescript-eslint/type-annotation-spacing': 'error',
5472
},

package.json

+20-21
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,33 @@
2727
"react-native": ">=0.60 <0.62"
2828
},
2929
"dependencies": {
30-
"escape-string-regexp": "1.0.5",
30+
"escape-string-regexp": "2.0.0",
3131
"invariant": "2.2.4"
3232
},
3333
"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",
3938
"@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",
5352
"metro-react-native-babel-preset": "0.53.1",
5453
"react": "16.8.3",
5554
"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"
5857
},
5958
"repository": {
6059
"type": "git",

src/WebView.android.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import {
2626
AndroidWebViewProps,
2727
NativeWebViewAndroid,
2828
State,
29-
CustomUIManager,
29+
RNCWebViewUIManager,
3030
} from './WebViewTypes';
3131

3232
import styles from './WebView.styles';
3333

34-
const UIManager = NotTypedUIManager as CustomUIManager;
34+
const UIManager = NotTypedUIManager as RNCWebViewUIManager;
3535

3636
const RNCWebView = requireNativeComponent(
3737
'RNCWebView',
@@ -73,15 +73,13 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
7373
UIManager.dispatchViewManagerCommand(
7474
this.getWebViewHandle(),
7575
this.getCommands().goForward,
76-
null,
7776
);
7877
};
7978

8079
goBack = () => {
8180
UIManager.dispatchViewManagerCommand(
8281
this.getWebViewHandle(),
8382
this.getCommands().goBack,
84-
null,
8583
);
8684
};
8785

@@ -92,23 +90,20 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
9290
UIManager.dispatchViewManagerCommand(
9391
this.getWebViewHandle(),
9492
this.getCommands().reload,
95-
null,
9693
);
9794
};
9895

9996
stopLoading = () => {
10097
UIManager.dispatchViewManagerCommand(
10198
this.getWebViewHandle(),
10299
this.getCommands().stopLoading,
103-
null,
104100
);
105101
};
106102

107103
requestFocus = () => {
108104
UIManager.dispatchViewManagerCommand(
109105
this.getWebViewHandle(),
110106
this.getCommands().requestFocus,
111-
null,
112107
);
113108
};
114109

@@ -268,7 +263,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
268263
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
269264
this.onShouldStartLoadWithRequestCallback,
270265
// casting cause it's in the default props
271-
originWhitelist as ReadonlyArray<string>,
266+
originWhitelist as readonly string[],
272267
onShouldStartLoadWithRequestProp,
273268
);
274269

src/WebView.ios.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import {
2626
NativeWebViewIOS,
2727
ViewManager,
2828
State,
29-
CustomUIManager,
29+
RNCWebViewUIManager,
3030
} from './WebViewTypes';
3131

3232
import styles from './WebView.styles';
3333

34-
const UIManager = NotTypedUIManager as CustomUIManager;
34+
const UIManager = NotTypedUIManager as RNCWebViewUIManager;
3535

3636
const { resolveAssetSource } = Image;
3737
const processDecelerationRate = (
@@ -82,7 +82,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
8282
UIManager.dispatchViewManagerCommand(
8383
this.getWebViewHandle(),
8484
this.getCommands().goForward,
85-
null,
8685
);
8786
};
8887

@@ -93,7 +92,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
9392
UIManager.dispatchViewManagerCommand(
9493
this.getWebViewHandle(),
9594
this.getCommands().goBack,
96-
null,
9795
);
9896
};
9997

@@ -105,7 +103,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
105103
UIManager.dispatchViewManagerCommand(
106104
this.getWebViewHandle(),
107105
this.getCommands().reload,
108-
null,
109106
);
110107
};
111108

@@ -116,7 +113,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
116113
UIManager.dispatchViewManagerCommand(
117114
this.getWebViewHandle(),
118115
this.getCommands().stopLoading,
119-
null,
120116
);
121117
};
122118

@@ -127,7 +123,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
127123
UIManager.dispatchViewManagerCommand(
128124
this.getWebViewHandle(),
129125
this.getCommands().requestFocus,
130-
null,
131126
);
132127
};
133128

@@ -301,7 +296,7 @@ class WebView extends React.Component<IOSWebViewProps, State> {
301296
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
302297
this.onShouldStartLoadWithRequestCallback,
303298
// casting cause it's in the default props
304-
originWhitelist as ReadonlyArray<string>,
299+
originWhitelist as readonly string[],
305300
onShouldStartLoadWithRequestProp,
306301
);
307302

src/WebViewShared.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ const originWhitelistToRegex = (originWhitelist: string): string =>
1818
`^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
1919

2020
const passesWhitelist = (
21-
compiledWhitelist: ReadonlyArray<string>,
21+
compiledWhitelist: readonly string[],
2222
url: string,
2323
) => {
2424
const origin = extractOrigin(url);
2525
return compiledWhitelist.some(x => new RegExp(x).test(origin));
2626
};
2727

2828
const compileWhitelist = (
29-
originWhitelist: ReadonlyArray<string>,
30-
): ReadonlyArray<string> =>
29+
originWhitelist: readonly string[],
30+
): readonly string[] =>
3131
['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
3232

3333
const createOnShouldStartLoadWithRequest = (
@@ -36,7 +36,7 @@ const createOnShouldStartLoadWithRequest = (
3636
url: string,
3737
lockIdentifier: number,
3838
) => void,
39-
originWhitelist: ReadonlyArray<string>,
39+
originWhitelist: readonly string[],
4040
onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
4141
) => {
4242
return ({ nativeEvent }: WebViewNavigationEvent) => {

src/WebViewTypes.ts

+16-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable react/no-multi-comp */
1+
/* eslint-disable react/no-multi-comp, max-classes-per-file */
22

33
import { ReactElement, Component } from 'react';
44
import {
@@ -11,30 +11,22 @@ import {
1111
} from 'react-native';
1212

1313
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;
2222
}
2323

24-
export interface CustomUIManager extends UIManagerStatic {
24+
export interface RNCWebViewUIManager extends UIManagerStatic {
2525
getViewManagerConfig: (
26-
name: string,
26+
name: 'RNCWebView',
2727
) => {
2828
Commands: WebViewCommands;
2929
};
30-
dispatchViewManagerCommand: (
31-
viewHandle: number,
32-
command: Function,
33-
params: object | null,
34-
) => void;
35-
RNCWebView: {
36-
Commands: WebViewCommands;
37-
};
3830
}
3931

4032
type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
@@ -246,7 +238,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
246238
saveFormDataDisabled?: boolean;
247239
textZoom?: number;
248240
thirdPartyCookiesEnabled?: boolean;
249-
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
241+
urlPrefixesForDefaultIntent?: readonly string[];
250242
}
251243

252244
export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
@@ -262,7 +254,7 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
262254
| 'scrollableAxes'
263255
| 'never'
264256
| 'always';
265-
dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
257+
dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
266258
decelerationRate?: number;
267259
directionalLockEnabled?: boolean;
268260
hideKeyboardAccessoryView?: boolean;
@@ -360,7 +352,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {
360352
*
361353
* @platform ios
362354
*/
363-
dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
355+
dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
364356

365357
/**
366358
* Boolean that determines whether HTML5 videos play inline or use the
@@ -500,7 +492,7 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
500492
* Use this to list URLs that WebView cannot handle, e.g. a PDF url.
501493
* @platform android
502494
*/
503-
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
495+
urlPrefixesForDefaultIntent?: readonly string[];
504496

505497
/**
506498
* Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
@@ -662,7 +654,7 @@ export interface WebViewSharedProps extends ViewProps {
662654
* this whitelist, we will open the URL in Safari.
663655
* The default whitelisted origins are "http://*" and "https://*".
664656
*/
665-
originWhitelist?: ReadonlyArray<string>;
657+
originWhitelist?: readonly string[];
666658

667659
/**
668660
* Function that allows custom handling of any web view requests. Return

0 commit comments

Comments
 (0)