Skip to content

Commit

Permalink
fix(deps): updated dependancies and types (#847)
Browse files Browse the repository at this point in the history
* wip

* Update WebViewShared.tsx

* Update config.yml
  • Loading branch information
Titozzz committed Sep 19, 2019
1 parent 36ffbe0 commit 85b921c
Show file tree
Hide file tree
Showing 8 changed files with 2,304 additions and 2,237 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
@@ -1,7 +1,7 @@
defaults: &defaults
working_directory: ~/code
docker:
- image: circleci/node:10.6.0-browsers
- image: circleci/node:12.9.1-browsers

version: 2
jobs:
Expand Down
28 changes: 23 additions & 5 deletions .eslintrc.js
Expand Up @@ -20,10 +20,17 @@ module.exports = {
// Remove this rule because we only destructure props, but never state
'react/destructuring-assignment': 'off',
'react/prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
'react/static-property-placement': 'off',
'react/state-in-constructor': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', 'array'],
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
},
],
'@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
Expand All @@ -32,10 +39,18 @@ module.exports = {
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-object-literal-type-assertion': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
},
],
'@typescript-eslint/no-parameter-properties': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-triple-slash-reference': 'error',
'@typescript-eslint/triple-slash-reference': [
'error',
{ path: 'never', types: 'never', lib: 'never' },
],
'@typescript-eslint/no-type-alias': [
'error',
{
Expand All @@ -48,7 +63,10 @@ module.exports = {
'error',
{ ignoreRestSiblings: true },
],
'@typescript-eslint/prefer-interface': 'error',
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
},
Expand Down
41 changes: 20 additions & 21 deletions package.json
Expand Up @@ -27,34 +27,33 @@
"react-native": ">=0.60 <0.62"
},
"dependencies": {
"escape-string-regexp": "1.0.5",
"escape-string-regexp": "2.0.0",
"invariant": "2.2.4"
},
"devDependencies": {
"@babel/core": "7.3.4",
"@semantic-release/git": "7.0.5",
"@types/escape-string-regexp": "1.0.0",
"@types/invariant": "^2.2.29",
"@types/jest": "24.0.11",
"@babel/core": "7.5.5",
"@semantic-release/git": "7.0.16",
"@types/invariant": "^2.2.30",
"@types/jest": "24.0.18",
"@types/react": "16.8.8",
"@types/react-native": "0.57.40",
"@typescript-eslint/eslint-plugin": "1.4.2",
"@typescript-eslint/parser": "1.4.2",
"babel-eslint": "10.0.1",
"babel-jest": "^24.0.0",
"eslint": "5.15.1",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "4.1.0",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-react": "7.12.4",
"eslint-plugin-react-native": "3.6.0",
"jest": "24.5.0",
"@types/react-native": "0.60.11",
"@typescript-eslint/eslint-plugin": "2.1.0",
"@typescript-eslint/parser": "2.1.0",
"babel-eslint": "10.0.3",
"babel-jest": "^24.9.0",
"eslint": "6.3.0",
"eslint-config-airbnb": "18.0.1",
"eslint-config-prettier": "6.2.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-native": "3.7.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.53.1",
"react": "16.8.3",
"react-native": "0.60.5",
"semantic-release": "15.10.3",
"typescript": "3.3.3333"
"semantic-release": "15.13.24",
"typescript": "3.6.2"
},
"repository": {
"type": "git",
Expand Down
11 changes: 3 additions & 8 deletions src/WebView.android.tsx
Expand Up @@ -26,12 +26,12 @@ import {
AndroidWebViewProps,
NativeWebViewAndroid,
State,
CustomUIManager,
RNCWebViewUIManager,
} from './WebViewTypes';

import styles from './WebView.styles';

const UIManager = NotTypedUIManager as CustomUIManager;
const UIManager = NotTypedUIManager as RNCWebViewUIManager;

const RNCWebView = requireNativeComponent(
'RNCWebView',
Expand Down Expand Up @@ -73,15 +73,13 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().goForward,
null,
);
};

goBack = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().goBack,
null,
);
};

Expand All @@ -92,23 +90,20 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().reload,
null,
);
};

stopLoading = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().stopLoading,
null,
);
};

requestFocus = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().requestFocus,
null,
);
};

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

Expand Down
11 changes: 3 additions & 8 deletions src/WebView.ios.tsx
Expand Up @@ -26,12 +26,12 @@ import {
NativeWebViewIOS,
ViewManager,
State,
CustomUIManager,
RNCWebViewUIManager,
} from './WebViewTypes';

import styles from './WebView.styles';

const UIManager = NotTypedUIManager as CustomUIManager;
const UIManager = NotTypedUIManager as RNCWebViewUIManager;

const { resolveAssetSource } = Image;
const processDecelerationRate = (
Expand Down Expand Up @@ -82,7 +82,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().goForward,
null,
);
};

Expand All @@ -93,7 +92,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().goBack,
null,
);
};

Expand All @@ -105,7 +103,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().reload,
null,
);
};

Expand All @@ -116,7 +113,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().stopLoading,
null,
);
};

Expand All @@ -127,7 +123,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
this.getCommands().requestFocus,
null,
);
};

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

Expand Down
8 changes: 4 additions & 4 deletions src/WebViewShared.tsx
Expand Up @@ -18,16 +18,16 @@ const originWhitelistToRegex = (originWhitelist: string): string =>
`^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;

const passesWhitelist = (
compiledWhitelist: ReadonlyArray<string>,
compiledWhitelist: readonly string[],
url: string,
) => {
const origin = extractOrigin(url);
return compiledWhitelist.some(x => new RegExp(x).test(origin));
};

const compileWhitelist = (
originWhitelist: ReadonlyArray<string>,
): ReadonlyArray<string> =>
originWhitelist: readonly string[],
): readonly string[] =>
['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);

const createOnShouldStartLoadWithRequest = (
Expand All @@ -36,7 +36,7 @@ const createOnShouldStartLoadWithRequest = (
url: string,
lockIdentifier: number,
) => void,
originWhitelist: ReadonlyArray<string>,
originWhitelist: readonly string[],
onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
) => {
return ({ nativeEvent }: WebViewNavigationEvent) => {
Expand Down
40 changes: 16 additions & 24 deletions src/WebViewTypes.ts
@@ -1,4 +1,4 @@
/* eslint-disable react/no-multi-comp */
/* eslint-disable react/no-multi-comp, max-classes-per-file */

import { ReactElement, Component } from 'react';
import {
Expand All @@ -11,30 +11,22 @@ import {
} from 'react-native';

export interface WebViewCommands {
goForward: Function;
goBack: Function;
reload: Function;
stopLoading: Function;
postMessage: Function;
injectJavaScript: Function;
loadUrl: Function;
requestFocus: Function;
goForward: number;
goBack: number;
reload: number;
stopLoading: number;
postMessage: number;
injectJavaScript: number;
loadUrl: number;
requestFocus: number;
}

export interface CustomUIManager extends UIManagerStatic {
export interface RNCWebViewUIManager extends UIManagerStatic {
getViewManagerConfig: (
name: string,
name: 'RNCWebView',
) => {
Commands: WebViewCommands;
};
dispatchViewManagerCommand: (
viewHandle: number,
command: Function,
params: object | null,
) => void;
RNCWebView: {
Commands: WebViewCommands;
};
}

type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
Expand Down Expand Up @@ -246,7 +238,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
saveFormDataDisabled?: boolean;
textZoom?: number;
thirdPartyCookiesEnabled?: boolean;
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
urlPrefixesForDefaultIntent?: readonly string[];
}

export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
Expand All @@ -262,7 +254,7 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
| 'scrollableAxes'
| 'never'
| 'always';
dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
decelerationRate?: number;
directionalLockEnabled?: boolean;
hideKeyboardAccessoryView?: boolean;
Expand Down Expand Up @@ -360,7 +352,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {
*
* @platform ios
*/
dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];

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

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

/**
* Function that allows custom handling of any web view requests. Return
Expand Down

0 comments on commit 85b921c

Please sign in to comment.