diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index e69de29bb..000000000
diff --git a/DemoApp/.eslintignore b/DemoApp/.eslintignore
new file mode 100644
index 000000000..b55590862
--- /dev/null
+++ b/DemoApp/.eslintignore
@@ -0,0 +1,2 @@
+node_modules/*
+__tests__/*
diff --git a/DemoApp/.eslintrc b/DemoApp/.eslintrc
new file mode 100644
index 000000000..5bff4f84d
--- /dev/null
+++ b/DemoApp/.eslintrc
@@ -0,0 +1,34 @@
+{
+ "parser": "babel-eslint",
+ "env": {
+ "es6": true
+ },
+ "plugins": [
+ "react"
+ ],
+ "extends": "airbnb",
+ "rules": {
+ "comma-dangle": 0,
+ "react/prop-types": 0,
+ "no-use-before-define": 0,
+ "radix": 0,
+ "no-param-reassign": 0,
+ "react/jsx-filename-extension": 0,
+ "no-mixed-operators": 0,
+ "import/prefer-default-export": 0,
+ "import/no-extraneous-dependencies": 0,
+ "no-plusplus": 0,
+ "react/prefer-stateless-function": 0,
+ "class-methods-use-this": 0,
+ "max-len": 0,
+ "jsx-a11y/href-no-hash": 0,
+ "indent": 0,
+ "import/no-unresolved": 0,
+ "no-console": 0,
+ "no-multi-spaces": [2, { "ignoreEOLComments": true }],
+ "func-names": 0,
+ "no-useless-escape": 0,
+ "import/no-dynamic-require": 0,
+ "react/sort-comp": 0
+ }
+}
\ No newline at end of file
diff --git a/DemoApp/AnalyticsScreen.js b/DemoApp/AnalyticsScreen.js
index 70fca5761..90ee86e8d 100644
--- a/DemoApp/AnalyticsScreen.js
+++ b/DemoApp/AnalyticsScreen.js
@@ -4,16 +4,12 @@
* @flow
*/
-import React, { Component } from 'react';
+import React from 'react';
import {
- Alert,
- AppRegistry,
- StyleSheet,
Text,
View,
ScrollView,
- TouchableOpacity,
- NativeModules
+ TouchableOpacity
} from 'react-native';
import Analytics from 'mobile-center-analytics';
@@ -25,23 +21,24 @@ export default class AnalyticsScreen extends React.Component {
this.state = {
analyticsEnabled: false
};
+ this.toggleEnabled = this.toggleEnabled.bind(this);
}
async componentDidMount() {
- let status = "";
const component = this;
const analyticsEnabled = await Analytics.isEnabled();
- component.setState({ analyticsEnabled: analyticsEnabled });
+ component.setState({ analyticsEnabled });
}
async toggleEnabled() {
await Analytics.setEnabled(!this.state.analyticsEnabled);
const analyticsEnabled = await Analytics.isEnabled();
- this.setState({ analyticsEnabled: analyticsEnabled });
+ this.setState({ analyticsEnabled });
}
+ /* eslint-disable no-undef */
render() {
return (
@@ -51,29 +48,29 @@ export default class AnalyticsScreen extends React.Component {
- Analytics enabled: {this.state.analyticsEnabled ? "yes" : "no"}
+ Analytics enabled: {this.state.analyticsEnabled ? 'yes' : 'no'}
-
+
toggle
- Analytics.trackEvent("Button press", { page: "Home page" })}>
+ Analytics.trackEvent('Button press', { page: 'Home page' })}>
Track Event
- Analytics.trackEvent("Button press", { propertyValueTooLong: "12345678901234567890123456789012345678901234567890123456789012345" })}>
+ Analytics.trackEvent('Button press', { propertyValueTooLong: '12345678901234567890123456789012345678901234567890123456789012345' })}>
Track Event - event property value truncated after 64 characters
- Analytics.trackEvent("Button press", data)}>
+ Analytics.trackEvent('Button press', data)}>
- Track Event badly (Don't do this, only strings are supported)
+ Track Event badly (Do not do this, only strings are supported)
@@ -81,4 +78,5 @@ export default class AnalyticsScreen extends React.Component {
);
}
+ /* eslint-enable no-undef */
}
diff --git a/DemoApp/CrashesScreen.js b/DemoApp/CrashesScreen.js
index 7cce2a52b..3d97ddd90 100644
--- a/DemoApp/CrashesScreen.js
+++ b/DemoApp/CrashesScreen.js
@@ -7,16 +7,13 @@
import React, { Component } from 'react';
import {
Alert,
- Button,
StyleSheet,
Text,
View,
- Switch,
ScrollView,
TouchableOpacity
} from 'react-native';
-import { StackNavigator } from 'react-navigation';
import Crashes from 'mobile-center-crashes';
import { FooClass } from './js/FooClass';
import SharedStyles from './SharedStyles';
@@ -26,25 +23,29 @@ export default class CrashesScreen extends Component {
super();
this.state = {
crashesEnabled: false,
- lastSessionStatus: "",
- sendStatus: ""
+ lastSessionStatus: '',
+ sendStatus: ''
};
+ this.toggleEnabled = this.toggleEnabled.bind(this);
+ this.jsCrash = this.jsCrash.bind(this);
+ this.nativeCrash = this.nativeCrash.bind(this);
+ this.sendCrashes = this.sendCrashes.bind(this);
}
async componentDidMount() {
- let status = "";
+ let status = '';
const component = this;
const crashesEnabled = await Crashes.isEnabled();
- component.setState({ crashesEnabled: crashesEnabled });
+ component.setState({ crashesEnabled });
const crashedInLastSession = await Crashes.hasCrashedInLastSession();
- status += `Crashed: ${crashedInLastSession ? "yes" : "no"}\n\n`;
+ status += `Crashed: ${crashedInLastSession ? 'yes' : 'no'}\n\n`;
component.setState({ lastSessionStatus: status });
if (crashedInLastSession) {
- const crashReport = await Crashes.lastSessionCrashReport()
+ const crashReport = await Crashes.lastSessionCrashReport();
status += JSON.stringify(crashReport, null, 4);
component.setState({ lastSessionStatus: status });
@@ -55,11 +56,11 @@ export default class CrashesScreen extends Component {
await Crashes.setEnabled(!this.state.crashesEnabled);
const crashesEnabled = await Crashes.isEnabled();
- this.setState({ crashesEnabled: crashesEnabled });
+ this.setState({ crashesEnabled });
}
jsCrash() {
- var foo = new FooClass();
+ const foo = new FooClass();
foo.method1();
}
@@ -69,39 +70,39 @@ export default class CrashesScreen extends Component {
sendCrashes() {
const component = this;
- Crashes.process(function (reports, send) {
- let status = "";
+ Crashes.process((reports, send) => {
+ let status = '';
if (reports.length === 0) {
- status += `Nothing to send\n`;
+ status += 'Nothing to send\n';
component.setState({ sendStatus: status });
return;
}
Crashes.setEventListener({
- willSendCrash: function () {
- status += `Will send crash\n`;
+ willSendCrash() {
+ status += 'Will send crash\n';
component.setState({ sendStatus: status });
},
- didSendCrash: function () {
- status += `Did send crash\n`;
+ didSendCrash() {
+ status += 'Did send crash\n';
component.setState({ sendStatus: status });
},
- failedSendingCrash: function () {
- status += `Failed sending crash\n`;
+ failedSendingCrash() {
+ status += 'Failed sending crash\n';
component.setState({ sendStatus: status });
}
});
- let crashes = "";
- for (const report of reports) {
+ let crashes = '';
+ reports.forEach((report) => {
if (crashes.length > 0) {
- crashes += "\n\n";
+ crashes += '\n\n';
}
crashes += report.exceptionReason;
- report.addTextAttachment("Hello attachment!", "hello.txt");
- report.addBinaryAttachment(testIcon, "logo.png", "image/png");
- }
+ report.addTextAttachment('Hello attachment!', 'hello.txt');
+ report.addBinaryAttachment(testIcon, 'logo.png', 'image/png');
+ });
Alert.alert(
`Send ${reports.length} crash(es)?`,
@@ -111,7 +112,7 @@ export default class CrashesScreen extends Component {
{ text: 'Ignore', onPress: () => send(false), style: 'cancel' },
]
);
- }).then(() => console.log("Crashes were processed"));
+ }).then(() => console.log('Crashes were processed'));
}
render() {
@@ -123,26 +124,26 @@ export default class CrashesScreen extends Component {
- Crashes enabled: {this.state.crashesEnabled ? "yes" : "no"}
+ Crashes enabled: {this.state.crashesEnabled ? 'yes' : 'no'}
-
+
toggle
-
+
Crash JavaScript
-
+
Crash native code
-
+
Send crashes
diff --git a/DemoApp/MainScreen.js b/DemoApp/MainScreen.js
index 9fc7ebdd8..c161b6558 100644
--- a/DemoApp/MainScreen.js
+++ b/DemoApp/MainScreen.js
@@ -5,19 +5,15 @@
*/
import React, { Component } from 'react';
-import { AppState, Alert, Button, Text, View, Platform, ToastAndroid } from 'react-native';
-import SharedStyles from './SharedStyles';
+import { AppState, Alert, Button, View, Platform, ToastAndroid } from 'react-native';
import Push from 'mobile-center-push';
+import SharedStyles from './SharedStyles';
export default class MainScreen extends Component {
static navigationOptions = {
title: 'DemoApp',
};
- constructor() {
- super();
- }
-
render() {
const { navigate } = this.props.navigation;
@@ -45,7 +41,7 @@ export default class MainScreen extends Component {
}
/>
-