Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

Commit 6994f95

Browse files
committed
Moved to typescript environment
1 parent 092e7ab commit 6994f95

14 files changed

+2093
-2240
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ android/keystores/debug.keystore
5151

5252
# Build
5353
dist/
54+
55+
# Test
56+
coverage/
57+
.jest/

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"trailingComma": "all",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"useTabs": false,
7+
"bracketSpacing": true,
8+
"jsxBracketSameLine": false
9+
}

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};

jest-setup.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { defaults: tsjPreset } = require('ts-jest/presets');
2+
3+
module.exports = {
4+
...tsjPreset,
5+
preset: 'react-native',
6+
transform: {
7+
...tsjPreset.transform,
8+
'\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
9+
},
10+
globals: {
11+
'ts-jest': {
12+
babelConfig: true,
13+
},
14+
},
15+
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
16+
cacheDirectory: '.jest/cache',
17+
};

package.json

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
"version": "1.0.0-alpha.2",
44
"description": "React hooks for convenient react-navigation use",
55
"main": "dist/Hooks.js",
6+
"types": "dist/Hooks.d.ts",
67
"files": [
78
"dist/",
8-
"src/",
9-
"lib/",
109
"LICENSE.md",
1110
"README.md"
1211
],
13-
"react-native": "src/Hooks.js",
1412
"scripts": {
1513
"test": "jest",
16-
"lint": "eslint .",
17-
"format": "eslint . --fix",
18-
"build": "babel --no-babelrc --plugins=transform-es2015-modules-commonjs,transform-react-jsx,transform-class-properties,transform-object-rest-spread,transform-flow-strip-types src --copy-files --out-dir dist --ignore '**/__tests__/**'",
14+
"lint": "tslint --project tsconfig.json",
15+
"build": "tsc --project tsconfig-build.json",
1916
"prepare": "yarn build",
20-
"release": "release-it"
17+
"release": "release-it",
18+
"precommit": "lint-staged"
2119
},
2220
"publishConfig": {
2321
"registry": "https://registry.npmjs.org/"
@@ -34,51 +32,38 @@
3432
"homepage": "https://github.com/react-navigation/react-navigation-hooks#readme",
3533
"dependencies": {},
3634
"devDependencies": {
37-
"babel-cli": "^6.26.0",
38-
"babel-jest": "^22.4.1",
39-
"babel-plugin-transform-class-properties": "^6.13.0",
40-
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
41-
"babel-plugin-transform-flow-strip-types": "^6.22.0",
42-
"babel-plugin-transform-object-rest-spread": "^6.13.0",
43-
"babel-plugin-transform-react-jsx": "^6.18.0",
44-
"babel-preset-react-native": "^4.0.0",
35+
"@react-navigation/core": "^3.0.0",
36+
"@types/jest": "^23.3.9",
37+
"@types/react": "^16.7.7",
38+
"@types/react-native": "^0.57.14",
39+
"@types/react-test-renderer": "^16.0.3",
4540
"conventional-changelog-cli": "^2.0.5",
46-
"eslint": "^4.12.1",
47-
"eslint-config-satya164": "^1.0.1",
48-
"eslint-plugin-react-native-globals": "^0.1.0",
4941
"husky": "^0.14.3",
50-
"jest": "^22.1.3",
51-
"jest-expo": "^30.0.0",
42+
"jest": "^23.6.0",
43+
"lint-staged": "^8.1.0",
5244
"prettier": "^1.8.2",
53-
"react": "16.7.0-alpha.0",
54-
"react-dom": "16.7.0-alpha.0",
55-
"react-native": "^0.55.4",
56-
"react-test-renderer": "16.7.0-alpha.0",
57-
"release-it": "^7.6.1"
45+
"pretty-quick": "^1.8.0",
46+
"react": "^16.7.0-alpha.2",
47+
"react-dom": "^16.7.0-alpha.2",
48+
"react-native": "^0.57.7",
49+
"react-test-renderer": "^16.7.0-alpha.2",
50+
"release-it": "^7.6.1",
51+
"ts-jest": "^23.10.5",
52+
"tslint": "^5.11.0",
53+
"tslint-config-airbnb": "^5.11.1",
54+
"tslint-config-prettier": "^1.16.0",
55+
"tslint-react": "^3.6.0",
56+
"typescript": "^3.1.6"
5857
},
5958
"peerDependencies": {
60-
"react": "^16.7.0-alpha.0",
61-
"react-dom": "^16.7.0-alpha.0",
62-
"@react-navigation/core": "^3.0.0-alpha.17"
59+
"@react-navigation/core": "^3.0.0",
60+
"react": "^16.7.0-alpha.2",
61+
"react-dom": "^16.7.0-alpha.2"
6362
},
64-
"jest": {
65-
"preset": "react-native",
66-
"testRegex": "/__tests__/[^/]+-test\\.js$",
67-
"setupFiles": [
68-
"<rootDir>/jest-setup.js"
69-
],
70-
"coveragePathIgnorePatterns": [
71-
"jest-setup.js"
72-
],
73-
"modulePathIgnorePatterns": [
74-
"<rootDir>/example/"
75-
],
76-
"transformIgnorePatterns": [
77-
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-navigation/core)"
63+
"lint-staged": {
64+
"{src}/**/*.ts*": [
65+
"prettier --write",
66+
"git add"
7867
]
79-
},
80-
"prettier": {
81-
"trailingComma": "es5",
82-
"singleQuote": true
8368
}
8469
}

src/Hooks.js renamed to src/Hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function useNavigationEvents(handleEvt) {
3838
// identifies the nav object, then we should probably pass [navigation.state.key] here, to
3939
// make sure react doesn't needlessly detach and re-attach this effect. In practice this
4040
// seems to cause troubles
41-
undefined
41+
undefined,
4242
// [navigation.state.key]
4343
);
4444
}

0 commit comments

Comments
 (0)