Skip to content

Commit

Permalink
Merge pull request #1099 from bugsnag/rn-test-fixture-linting
Browse files Browse the repository at this point in the history
Resolve ESLint violations in React Native test fixtures
  • Loading branch information
twometresteve authored Oct 15, 2020
2 parents 45e540f + b7fa1a1 commit c5a68da
Show file tree
Hide file tree
Showing 63 changed files with 267 additions and 248 deletions.
7 changes: 5 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
dist
examples
features
**/node_modules/**
fixtures
scratch
coverage
packages/core/types/test/*.js
packages/react-native/android/build/reports
packages/**/features
packages/**/fixtures
test/browser
test/expo
test/node
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ ADD min_packages.tar .
COPY bin ./bin
RUN npx lerna bootstrap --concurrency 1
COPY scripts ./scripts
COPY test ./test
COPY packages ./packages
RUN npm run build
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Scenario from './Scenario'

export class ReactNavigationBreadcrumbsDisabledScenario extends Scenario {
constructor(configuration, extraData, jsConfig) {
constructor (configuration, extraData, jsConfig) {
super()
configuration.enabledBreadcrumbTypes = []
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Scenario from './Scenario'

export class ReactNavigationBreadcrumbsEnabledScenario extends Scenario {}
export class ReactNavigationBreadcrumbsEnabledScenario extends Scenario {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default class Scenario {
constructor(configuration, extraData, jsConfig) {}
run() {}
run () {
}

timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
timeout (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import * as React from 'react';
import {View, Text, Button} from 'react-native';
import {Navigation} from 'react-native-navigation';
import * as React from 'react'
import { View, Text, Button } from 'react-native'
import { Navigation } from 'react-native-navigation'
import Bugsnag from '@bugsnag/react-native'

const DetailsScreen = (props) => {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Details Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() =>
Navigation.pop(props.componentId)
} />
}/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('DetailsNavigationError'))} />
onPress={() => Bugsnag.notify(new Error('DetailsNavigationError'))}/>
<Button title='Notify unhandled error'
accessibilityLabel='sendUnhandled'
onPress={() => { throw new Error('DetailsNavigationUnhandledError') }} />
onPress={() => {
throw new Error('DetailsNavigationUnhandledError')
}}/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('detailsSetContext')} />
onPress={() => Bugsnag.setContext('detailsSetContext')}/>
</View>
);
};
)
}

export default DetailsScreen;
export default DetailsScreen
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import * as React from 'react';
import {View, Button, Text} from 'react-native';
import {Navigation} from 'react-native-navigation';
import Bugsnag from '@bugsnag/react-native';
import * as React from 'react'
import { View, Button, Text } from 'react-native'
import { Navigation } from 'react-native-navigation'
import Bugsnag from '@bugsnag/react-native'

const HomeScreen = (props) => {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={ { flex: 1, alignItems: 'center', justifyContent: 'center' } }>
<Text>Home Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() =>
onPress={ () =>
Navigation.push(props.componentId, {
component: {
name: 'Details'
},
}
})
} />
}/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('HomeNavigationError'))} />
onPress={ () => Bugsnag.notify(new Error('HomeNavigationError')) }/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('homeSetContext')} />
onPress={ () => Bugsnag.setContext('homeSetContext') }/>
</View>
);
};
)
}

export default HomeScreen;
export default HomeScreen
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import React, { Component } from 'react'
import Bugsnag from '@bugsnag/react-native'
import BugsnagPluginReactNavigation from '@bugsnag/plugin-react-navigation';
import {NavigationContainer} from '@react-navigation/native';
import BugsnagPluginReactNavigation from '@bugsnag/plugin-react-navigation'
import { NavigationContainer } from '@react-navigation/native'
import * as Scenarios from './Scenarios'
import {
View,
Expand All @@ -17,7 +17,7 @@ const defaultJsConfig = () => ({
})

export default class App extends Component {
constructor(props) {
constructor (props) {
super(props)
this.state = {
currentScenario: '',
Expand Down Expand Up @@ -107,11 +107,11 @@ export default class App extends Component {
<TextInput style={styles.textInput}
placeholder='Scenario Name'
accessibilityLabel='scenario_name'
onChangeText={this.setScenario} />
onChangeText={this.setScenario}/>
<TextInput style={styles.textInput}
placeholder='Scenario Metadata'
accessibilityLabel='scenario_metadata'
onChangeText={this.setScenarioMetaData} />
onChangeText={this.setScenarioMetaData}/>

<Button style={styles.clickyButton}
accessibilityLabel='start_bugsnag'
Expand All @@ -127,17 +127,17 @@ export default class App extends Component {
style={styles.textInput}
accessibilityLabel='notify_endpoint'
value={this.state.notifyEndpoint}
onChangeText={this.setNotifyEndpoint} />
onChangeText={this.setNotifyEndpoint}/>
<TextInput placeholder='Sessions endpoint'
style={styles.textInput}
accessibilityLabel='sessions_endpoint'
value={this.state.sessionsEndpoint}
onChangeText={this.setSessionsEndpoint} />
onChangeText={this.setSessionsEndpoint}/>
<TextInput placeholder='API key'
style={styles.textInput}
accessibilityLabel='api_key'
value={this.state.apiKey}
onChangeText={this.setApiKey} />
onChangeText={this.setApiKey}/>
<Button style={styles.clickyButton}
accessibilityLabel='use_dashboard_endpoints'
title='Use dashboard endpoints'
Expand All @@ -148,12 +148,12 @@ export default class App extends Component {
}

ready () {
const BugsnagNavigationContainer = Bugsnag.getPlugin('reactNavigation').createNavigationContainer(NavigationContainer);
const BugsnagNavigationContainer = Bugsnag.getPlugin('reactNavigation').createNavigationContainer(NavigationContainer)
return (
<BugsnagNavigationContainer>
{this.state.scenario.view()}
</BugsnagNavigationContainer>
);
)
}

render () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,68 +1,70 @@
import Scenario from './Scenario'
import Bugsnag from '@bugsnag/react-native'
import * as React from 'react'
import {View, Text, Button} from 'react-native'
import {createStackNavigator} from '@react-navigation/stack';
import { View, Text, Button } from 'react-native'
import { createStackNavigator } from '@react-navigation/stack'

export class ReactNavigationBreadcrumbsDisabledScenario extends Scenario {
constructor(configuration, extraData, jsConfig) {
constructor (configuration, _extraData, _jsConfig) {
super()
configuration.enabledBreadcrumbTypes = []
}

view () {
const Stack = createStackNavigator();
const Stack = createStackNavigator()
return (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
component={ HomeScreen }
/>
<Stack.Screen
name="Details"
component={DetailsScreen}
component={ DetailsScreen }
/>
</Stack.Navigator>
)
}

run() {
run () {
}
}

function HomeScreen({navigation}) {
function HomeScreen ({ navigation }) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={ { flex: 1, alignItems: 'center', justifyContent: 'center' } }>
<Text>Home Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() => navigation.navigate('Details')} />
onPress={ () => navigation.navigate('Details') }/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('HomeNavigationError'))} />
onPress={ () => Bugsnag.notify(new Error('HomeNavigationError')) }/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('homeSetContext')} />
onPress={ () => Bugsnag.setContext('homeSetContext') }/>
</View>
);
)
}

function DetailsScreen({navigation}) {
function DetailsScreen ({ navigation }) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={ { flex: 1, alignItems: 'center', justifyContent: 'center' } }>
<Text>Details Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() => navigation.navigate('Home')} />
onPress={ () => navigation.navigate('Home') }/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('DetailsNavigationError'))} />
onPress={ () => Bugsnag.notify(new Error('DetailsNavigationError')) }/>
<Button title='Notify unhandled error'
accessibilityLabel='sendUnhandled'
onPress={() => { throw new Error('DetailsNavigationUnhandledError') }} />
onPress={ () => {
throw new Error('DetailsNavigationUnhandledError')
} }/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('detailsSetContext')} />
onPress={ () => Bugsnag.setContext('detailsSetContext') }/>
</View>
);
}
)
}
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
import Scenario from './Scenario'
import Bugsnag from '@bugsnag/react-native'
import * as React from 'react'
import {View, Text, Button} from 'react-native'
import {createStackNavigator} from '@react-navigation/stack'
import { View, Text, Button } from 'react-native'
import { createStackNavigator } from '@react-navigation/stack'

export class ReactNavigationBreadcrumbsEnabledScenario extends Scenario {
constructor(configuration, extraData, jsConfig) {
constructor (_configuration, _extraData, _jsConfig) {
super()
}

view () {
const Stack = createStackNavigator();
const Stack = createStackNavigator()
return (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
component={ HomeScreen }
/>
<Stack.Screen
name="Details"
component={DetailsScreen}
component={ DetailsScreen }
/>
</Stack.Navigator>
)
}

run() {
// Bugsnag.notify(new Error('ReactNavigationBreadcrumbsEnabledScenario'))
run () {
}
}

function HomeScreen({navigation}) {
function HomeScreen ({ navigation }) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={ { flex: 1, alignItems: 'center', justifyContent: 'center' } }>
<Text>Home Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() => navigation.navigate('Details')} />
onPress={ () => navigation.navigate('Details') }/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('HomeNavigationError'))} />
onPress={ () => Bugsnag.notify(new Error('HomeNavigationError')) }/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('homeSetContext')} />
onPress={ () => Bugsnag.setContext('homeSetContext') }/>
</View>
);
)
}

function DetailsScreen({navigation}) {
function DetailsScreen ({ navigation }) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View style={ { flex: 1, alignItems: 'center', justifyContent: 'center' } }>
<Text>Details Screen</Text>
<Button title='Navigate'
accessibilityLabel='navigate'
onPress={() => navigation.navigate('Home')} />
onPress={ () => navigation.navigate('Home') }/>
<Button title='Notify handled error'
accessibilityLabel='sendHandled'
onPress={() => Bugsnag.notify(new Error('DetailsNavigationError'))} />
onPress={ () => Bugsnag.notify(new Error('DetailsNavigationError')) }/>
<Button title='Notify unhandled error'
accessibilityLabel='sendUnhandled'
onPress={() => { throw new Error('DetailsNavigationUnhandledError') }} />
onPress={ () => {
throw new Error('DetailsNavigationUnhandledError')
} }/>
<Button title='Set context'
accessibilityLabel='setContext'
onPress={() => Bugsnag.setContext('detailsSetContext')} />
onPress={ () => Bugsnag.setContext('detailsSetContext') }/>
</View>
);
}
)
}
Loading

0 comments on commit c5a68da

Please sign in to comment.