Skip to content

Commit 50770af

Browse files
committed
initial
0 parents  commit 50770af

File tree

10 files changed

+1560
-0
lines changed

10 files changed

+1560
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

.eslintrc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# "off" or 0 - turn the rule off
2+
# "warn" or 1 - turn the rule on as a warning(doesn’ t affect exit code)
3+
# "error" or 2 - turn the rule on as an error(exit code is 1 when triggered)
4+
{
5+
"parser": "babel-eslint",
6+
"env": {
7+
"browser": true
8+
},
9+
"plugins": [
10+
"react",
11+
"react-native"
12+
],
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"extends": ["eslint:recommended", "plugin:react/recommended"],
17+
"rules": {
18+
"react-native/split-platform-components": 2,
19+
"react/no-did-mount-set-state": 2,
20+
"react/no-did-update-set-state": 2,
21+
"react/no-direct-mutation-state": 2,
22+
"react/jsx-uses-vars": 2,
23+
"no-unused-vars": ["error", {
24+
"varsIgnorePattern": "React"
25+
}],
26+
"comma-spacing": ["error", {
27+
"before": false,
28+
"after": true }],
29+
"no-undef": 2,
30+
"semi": 2,
31+
"react/prop-types": 2,
32+
"react/jsx-no-bind": 2,
33+
"react/jsx-no-duplicate-props": 2,
34+
"space-before-blocks": 2,
35+
"space-before-function-paren": 2,
36+
"space-in-parens": 2,
37+
"space-infix-ops": 2,
38+
"space-unary-ops": 2,
39+
"spaced-comment": 2,
40+
"rest-spread-spacing": 2,
41+
"semi-spacing": 2,
42+
"no-unneeded-ternary": 2,
43+
"eqeqeq": 2,
44+
"dot-location": 2,
45+
"no-extra-bind": 2,
46+
"keyword-spacing": 2,
47+
"key-spacing": 2,
48+
"indent": ["error", 2],
49+
"react/jsx-indent": [2, 2],
50+
"func-call-spacing": 2,
51+
"array-bracket-spacing": 2,
52+
"block-spacing": 2,
53+
"brace-style": 2,
54+
"arrow-body-style": 2,
55+
"arrow-parens": 2,
56+
"arrow-spacing": 2,
57+
"react/self-closing-comp": 2,
58+
"jsx-quotes": ["error", "prefer-single"],
59+
"object-curly-spacing": 2,
60+
"quotes": ["error", "single"],
61+
"no-console": 0
62+
},
63+
"globals": {
64+
"global": false,
65+
"it": false,
66+
"xit": false,
67+
"expect": false,
68+
"describe": false,
69+
"require": false,
70+
"module": false,
71+
"Promise": false,
72+
"__DEV__": false
73+
}
74+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.git
3+
cache
4+
npm-debug.log
5+
coverage

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.git

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Max
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# react-native-exception-handler
2+
A react native module to help tackle the exception problem in react native.

errorHandler.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Alert} from 'react-native';
2+
3+
const errorHandler = (e, isFatal) => {
4+
if (isFatal) {
5+
Alert.alert(
6+
'Unexpected error occurred',
7+
`
8+
Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
9+
10+
We will need to restart the app.
11+
`,
12+
[{
13+
text: 'Restart',
14+
onPress: () => {
15+
console.log('test');
16+
}
17+
}]
18+
);
19+
} else {
20+
console.log(e); // So that we can see it in the ADB logs in case of Android if needed
21+
}
22+
};
23+
24+
export default errorHandler;

index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import errorHandler from './errorHandler';
2+
3+
export const handleExceptions = (allowedInDevMode = false) => {
4+
registerErrorHandler(errorHandler, allowedInDevMode);
5+
};
6+
7+
export const registerErrorHandler = (customHandler, allowedInDevMode = false) => {
8+
const allowed = allowedInDevMode ? true : !__DEV__;
9+
if (allowed) {
10+
if (customHandler) {
11+
global.ErrorUtils.setGlobalHandler(customHandler);
12+
} else {
13+
console.log('Custom Error Handler not passed to registerErrorHandler');
14+
}
15+
} else {
16+
console.log('Not registering the error handler since its in dev mode and allowedInDevMode is not true');
17+
}
18+
};

package.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "react-native-exception-handler",
3+
"version": "1.0.0",
4+
"description": "A react native module to help tackle the exception problem in react native.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo no tests && exit 1",
8+
"lint": "eslint app/",
9+
"lint:fix": "eslint app/ --fix"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/master-atul/react-native-exception-handler"
14+
},
15+
"keywords": [
16+
"modal",
17+
"react",
18+
"native",
19+
"exception",
20+
"handler",
21+
"production",
22+
"ios",
23+
"android"
24+
],
25+
"peerDependencies": {
26+
"react": "*",
27+
"react-native": "*"
28+
},
29+
"author": "master-atul",
30+
"license": "MIT",
31+
"bugs": {
32+
"url": "https://github.com/master-atul/react-native-exception-handler/issues"
33+
},
34+
"homepage": "https://atulr.com/react-native-exception-handler",
35+
"bundledDependencies": [
36+
"react-native-restart"
37+
],
38+
"devDependencies": {
39+
"babel-eslint": "^7.1.1",
40+
"babel-polyfill": "^6.22.0",
41+
"babel-preset-react-native": "^1.9.1",
42+
"eslint": "^3.14.1",
43+
"eslint-plugin-react": "^6.9.0",
44+
"eslint-plugin-react-native": "^2.2.1"
45+
}
46+
}

0 commit comments

Comments
 (0)