Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit b14b303

Browse files
satya164brentvatne
authored andcommitted
refactor: migrate code to typescript (#59)
1 parent da0a3a6 commit b14b303

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4193
-3725
lines changed

.babelrc

-3
This file was deleted.

.circleci/config.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
- v1-dependencies-example-{{ checksum "example/package.json" }}
2222
- v1-dependencies-example-
2323
- run: |
24-
yarn install
25-
yarn install --cwd example
24+
yarn install --frozen-lockfile
25+
yarn install --frozen-lockfile --cwd example
2626
- save_cache:
2727
key: v1-dependencies-{{ checksum "package.json" }}
2828
paths: node_modules
@@ -38,13 +38,20 @@ jobs:
3838
- attach_workspace:
3939
at: ~/project
4040
- run: |
41-
yarn run lint
41+
yarn lint
42+
typescript:
43+
<<: *defaults
44+
steps:
45+
- attach_workspace:
46+
at: ~/project
47+
- run: |
48+
yarn typescript
4249
unit-tests:
4350
<<: *defaults
4451
steps:
4552
- attach_workspace:
4653
at: ~/project
47-
- run: yarn test -- --coverage
54+
- run: yarn test --coverage
4855
- store_artifacts:
4956
path: coverage
5057
destination: coverage
@@ -57,6 +64,9 @@ workflows:
5764
- lint:
5865
requires:
5966
- install-dependencies
67+
- typescript:
68+
requires:
69+
- install-dependencies
6070
- unit-tests:
6171
requires:
6272
- install-dependencies

.eslintignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules/
2-
dist/
3-
jest-setup.js
2+
coverage/
3+
lib/

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
"rules": {
1212
"import/no-unresolved": "off",
13-
"eslint-comments/no-unlimited-disable": "off",
13+
"react-native/no-inline-styles": "off"
1414
}
1515
}

.gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# VSCode
99
.vscode/
10-
tsconfig.json
1110
jsconfig.json
1211

1312
# Xcode
@@ -49,5 +48,8 @@ buck-out/
4948
android/app/libs
5049
android/keystores/debug.keystore
5150

52-
# Build
53-
dist/
51+
# test
52+
coverage/
53+
54+
# generated by bob
55+
lib/

babel.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* eslint-disable import/no-commonjs */
2+
3+
module.exports = {
4+
presets: ['module:metro-react-native-babel-preset'],
5+
};

example/.eslintrc

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"extends": '../.eslintrc',
33

44
"settings": {
5-
"import/core-modules": [ "expo", "react-navigation-drawer" ]
6-
},
7-
8-
"rules": {
9-
"react/prop-types": "off",
5+
"import/core-modules": [ "react-navigation-drawer", "react-native-gesture-handler", "react-native-vector-icons" ]
106
}
117
}

example/app.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"slug": "react-navigation-drawer-demo",
66
"sdkVersion": "32.0.0",
77
"version": "1.0.0",
8-
"primaryColor": "#2196f3"
8+
"primaryColor": "#2196f3",
9+
"packagerOpts": {
10+
"config": "./metro.config.js",
11+
"projectRoots": ""
12+
}
913
}
1014
}

example/metro.config.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-commonjs */
2+
3+
const path = require('path');
4+
const blacklist = require('metro-config/src/defaults/blacklist');
5+
const project = require('../package.json');
6+
const escape = require('escape-string-regexp');
7+
8+
const projectDependencies = Object.keys({
9+
...project.dependencies,
10+
...project.peerDependencies,
11+
});
12+
13+
module.exports = {
14+
projectRoot: __dirname,
15+
watchFolders: [path.resolve(__dirname, '..')],
16+
17+
resolver: {
18+
blacklistRE: blacklist([
19+
new RegExp(
20+
`^${escape(
21+
path.resolve(__dirname, 'node_modules', project.name)
22+
)}\\/.*$`
23+
),
24+
new RegExp(
25+
`^${escape(path.resolve(__dirname, '..', 'node_modules'))}\\/.*$`
26+
),
27+
]),
28+
29+
providesModuleNodeModules: [
30+
'@expo/vector-icons',
31+
'@babel/runtime',
32+
...projectDependencies,
33+
],
34+
},
35+
};

example/package.json

+10-14
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
"start": "expo start",
88
"android": "expo start --android",
99
"ios": "expo start --ios",
10-
"eject": "expo eject",
11-
"test": "node ./node_modules/jest/bin/jest.js --watchAll",
12-
"postinstall": "rm -rf node_modules/react-navigation-drawer/{.git,node_modules,example}"
10+
"eject": "expo eject"
1311
},
1412
"dependencies": {
13+
"@react-navigation/core": "^3.3.0",
14+
"@react-navigation/native": "^3.3.0",
15+
"expo": "32.0.6",
16+
"hoist-non-react-statics": "^3.3.0",
1517
"react": "16.5.0",
1618
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
17-
"react-native-paper": "^2.2.0",
18-
"react-navigation-stack": "^1.0.0",
19-
"react-navigation-drawer": "../",
20-
"@react-navigation/core": "^3.0.0",
21-
"@react-navigation/native": "^3.1.1",
22-
"expo": "32.0.0",
23-
"hoist-non-react-statics": "^2.5.0",
24-
"prop-types": "^15.6.0"
19+
"react-native-paper": "^2.15.2",
20+
"react-navigation-stack": "^1.2.0"
2521
},
2622
"devDependencies": {
27-
"babel-plugin-module-resolver": "^3.0.0",
28-
"glob-to-regexp": "^0.3.0"
23+
"babel-plugin-module-resolver": "^3.2.0"
2924
},
3025
"resolutions": {
3126
"**/prop-types": "15.6.0",
3227
"**/react-lifecycles-compat": "3.0.4",
33-
"**/hoist-non-react-statics": "2.5.0"
28+
"**/hoist-non-react-statics": "2.5.0",
29+
"**/react-native-screens": "1.0.0-alpha.22"
3430
}
3531
}

example/src/GestureInteraction.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { Button, WebView, View } from 'react-native';
33
import { MapView } from 'expo';
44
import { withNavigation } from '@react-navigation/core';

example/src/ParallaxDrawer.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import {
33
Animated,
44
Button,
@@ -108,18 +108,18 @@ const MyNavScreen = ({ navigation, banner }) => (
108108
);
109109

110110
const InboxScreen = ({ navigation }) => (
111-
<MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
111+
<MyNavScreen banner="Inbox Screen" navigation={navigation} />
112112
);
113113
InboxScreen.navigationOptions = {
114114
headerTitle: 'Inbox',
115115
};
116116

117117
const EmailScreen = ({ navigation }) => (
118-
<MyNavScreen banner={'Email Screen'} navigation={navigation} />
118+
<MyNavScreen banner="Email Screen" navigation={navigation} />
119119
);
120120

121121
const DraftsScreen = ({ navigation }) => (
122-
<MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
122+
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
123123
);
124124
DraftsScreen.navigationOptions = {
125125
headerTitle: 'Drafts',
@@ -177,8 +177,8 @@ const DrawerContents = ({ drawerOpenProgress, navigation }) => {
177177
<Animated.View style={{ transform: [{ translateX }] }}>
178178
<ScrollView>
179179
<SafeAreaView forceInset={{ top: 'always' }}>
180-
<DrawerItem navigation={navigation} item={'Drafts'} />
181-
<DrawerItem navigation={navigation} item={'Email'} />
180+
<DrawerItem navigation={navigation} item="Drafts" />
181+
<DrawerItem navigation={navigation} item="Email" />
182182
</SafeAreaView>
183183
</ScrollView>
184184
</Animated.View>

example/src/RTLDrawer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import * as React from 'react';
22
import {
33
Text,
44
View,
@@ -11,7 +11,7 @@ import {
1111
import { createStackNavigator } from 'react-navigation-stack';
1212
import { createDrawerNavigator } from 'react-navigation-drawer';
1313

14-
class RightDrawer extends Component {
14+
class RightDrawer extends React.Component {
1515
state = {
1616
categories: [{ i: 'c1', n: 'name1' }, { i: 'c2', n: 'name2' }],
1717
};

example/src/SimpleDrawer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import {
33
Button,
44
TextInput,
@@ -105,18 +105,18 @@ const MyNavScreen = ({ navigation, banner }) => (
105105
);
106106

107107
const InboxScreen = ({ navigation }) => (
108-
<MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
108+
<MyNavScreen banner="Inbox Screen" navigation={navigation} />
109109
);
110110
InboxScreen.navigationOptions = {
111111
headerTitle: 'Inbox',
112112
};
113113

114114
const EmailScreen = ({ navigation }) => (
115-
<MyNavScreen banner={'Email Screen'} navigation={navigation} />
115+
<MyNavScreen banner="Email Screen" navigation={navigation} />
116116
);
117117

118118
const DraftsScreen = ({ navigation }) => (
119-
<MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
119+
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
120120
);
121121
DraftsScreen.navigationOptions = {
122122
headerTitle: 'Drafts',

example/src/StyledDrawer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { Button, ScrollView, StatusBar, Text } from 'react-native';
33

44
// eslint-disable-next-line import/named
@@ -26,18 +26,18 @@ const MyNavScreen = ({ navigation, banner }) => (
2626
);
2727

2828
const InboxScreen = ({ navigation }) => (
29-
<MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
29+
<MyNavScreen banner="Inbox Screen" navigation={navigation} />
3030
);
3131
InboxScreen.navigationOptions = {
3232
headerTitle: 'Inbox',
3333
};
3434

3535
const EmailScreen = ({ navigation }) => (
36-
<MyNavScreen banner={'Email Screen'} navigation={navigation} />
36+
<MyNavScreen banner="Email Screen" navigation={navigation} />
3737
);
3838

3939
const DraftsScreen = ({ navigation }) => (
40-
<MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
40+
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
4141
);
4242
DraftsScreen.navigationOptions = {
4343
headerTitle: 'Drafts',

0 commit comments

Comments
 (0)