Skip to content

Commit f3a958d

Browse files
Adam Miskiewiczskevy
Adam Miskiewicz
authored andcommitted
Update/Fix Prettier + Eslint config for codebase
Run Prettier/Eslint on entire codebase, fix issues
1 parent a301b41 commit f3a958d

File tree

94 files changed

+3583
-3799
lines changed

Some content is hidden

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

94 files changed

+3583
-3799
lines changed

.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flow-typed
2+
node_modules
3+
lib*
4+
5+
## Temporary
6+
examples

.eslintrc

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"extends": [
3-
"airbnb",
3+
"plugin:flowtype/recommended",
4+
"plugin:react/recommended",
5+
"plugin:import/errors",
6+
"plugin:import/warnings",
47
"prettier",
58
"prettier/flowtype",
69
"prettier/react"
710
],
811
"parser": "babel-eslint",
912
"plugins": [
13+
"react",
1014
"flowtype",
1115
"prettier"
1216
],
@@ -18,7 +22,7 @@
1822
},
1923
"rules": {
2024
"prettier/prettier": ["error", {
21-
"trailingComma": "all",
25+
"trailingComma": "es5",
2226
"singleQuote": true
2327
}],
2428

@@ -65,7 +69,7 @@
6569
},
6670
"settings": {
6771
"flowtype": {
68-
"onlyFilesWithFlowAnnotation": false
72+
"onlyFilesWithFlowAnnotation": true
6973
}
7074
}
7175
}

.flowconfig

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<PROJECT_ROOT>/website/node_modules/react-native/.*
2020
<PROJECT_ROOT>/website/node_modules/fbjs/.*
2121

22+
; Ignore misc packages
23+
.*/node_modules/eslint-.*
24+
2225
; Ignore duplicate module providers
2326
; For RN Apps installed via npm, "Libraries" folder is inside
2427
; "node_modules/react-native" but in the source repo it is in the root
@@ -55,6 +58,3 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
5558
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
5659

5760
unsafe.enable_getters_and_setters=true
58-
59-
[version]
60-
^0.40.0

examples/NavigationPlayground/__exponent/rn-cli.config.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ const path = require('path');
99
const config = require('../../../rn-cli.config');
1010

1111
config.getBlacklist = () => [
12-
new RegExp(`${path.resolve(__dirname, '../../..')}/node_modules/react-native/(.*)`),
12+
new RegExp(
13+
`${path.resolve(__dirname, '../../..')}/node_modules/react-native/(.*)`
14+
),
1315
new RegExp(`${path.resolve(__dirname, '../../..')}/node_modules/react/(.*)`),
1416
...config.getBlacklistForExample('NavigationPlayground'),
1517
new RegExp(`^${path.resolve(__dirname, '..')}/package.json$`),
1618
];
1719

18-
config.getTransformModulePath = () => path.resolve(__dirname, './transformer.js');
20+
config.getTransformModulePath = () =>
21+
path.resolve(__dirname, './transformer.js');
1922

2023
config.getTransformOptions = () => ({
2124
reactNativePath: path.resolve(__dirname, '../node_modules/react-native/'),

examples/NavigationPlayground/__exponent/transformer.js

+32-18
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ const reactTransformPlugin = require('babel-plugin-react-transform').default;
1919
const hmrTransform = 'react-transform-hmr/lib/index.js';
2020
const transformPath = require.resolve(hmrTransform);
2121

22-
const makeHMRConfig = function(options, filename) {
23-
const transform = filename ?
24-
'./' + path.relative(path.dirname(filename), transformPath) : // packager can't handle absolute paths
25-
hmrTransform;
22+
const makeHMRConfig = function(options, filename) {
23+
const transform = filename
24+
? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
25+
: hmrTransform;
2626

2727
return {
2828
plugins: [
2929
[
3030
reactTransformPlugin,
3131
{
32-
transforms: [{
33-
transform,
34-
imports: ['react-native'],
35-
locals: ['module'],
36-
}],
32+
transforms: [
33+
{
34+
transform,
35+
imports: ['react-native'],
36+
locals: ['module'],
37+
},
38+
],
3739
},
3840
],
3941
],
@@ -42,13 +44,22 @@ const makeHMRConfig = function(options, filename) {
4244

4345
const buildAliasPreset = (reactNativePath, reactPath) => ({
4446
plugins: [
45-
[require('babel-plugin-module-resolver').default, {
46-
alias: Object.assign({}, {
47-
'react-native': path.resolve(`${reactNativePath || './node_modules/react-native'}`),
48-
react: path.resolve(`${reactPath || './node_modules/react'}`),
49-
}, require('babel-preset-exponent').plugins[0][1].alias),
50-
cwd: path.resolve(__dirname, '..'),
51-
}],
47+
[
48+
require('babel-plugin-module-resolver').default,
49+
{
50+
alias: Object.assign(
51+
{},
52+
{
53+
'react-native': path.resolve(
54+
`${reactNativePath || './node_modules/react-native'}`
55+
),
56+
react: path.resolve(`${reactPath || './node_modules/react'}`),
57+
},
58+
require('babel-preset-exponent').plugins[0][1].alias
59+
),
60+
cwd: path.resolve(__dirname, '..'),
61+
},
62+
],
5263
],
5364
});
5465

@@ -59,7 +70,10 @@ const buildAliasPreset = (reactNativePath, reactPath) => ({
5970
function buildBabelConfig(filename, options) {
6071
const exponentBabelPreset = require('babel-preset-exponent');
6172
const babelConfig = {
62-
presets: [...exponentBabelPreset.presets, buildAliasPreset(options.reactNativePath, options.reactPath)],
73+
presets: [
74+
...exponentBabelPreset.presets,
75+
buildAliasPreset(options.reactNativePath, options.reactPath),
76+
],
6377
plugins: [],
6478
};
6579

@@ -97,7 +111,7 @@ function transform(src, filename, options) {
97111
};
98112
}
99113

100-
module.exports = function (data, callback) {
114+
module.exports = function(data, callback) {
101115
let result;
102116
try {
103117
result = transform(data.sourceCode, data.filename, data.options);

examples/NavigationPlayground/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import {
2-
AppRegistry,
3-
} from 'react-native';
1+
import { AppRegistry } from 'react-native';
42

53
import App from './js/App';
64

examples/NavigationPlayground/js/App.js

+24-15
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ const ExampleRoutes = {
4949
screen: CustomTabs,
5050
},
5151
ModalStack: {
52-
name: Platform.OS === 'ios' ? 'Modal Stack Example' : 'Stack with Dynamic Header',
53-
description: Platform.OS === 'ios' ? 'Stack navigation with modals' : 'Dynamically showing and hiding the header',
52+
name: Platform.OS === 'ios'
53+
? 'Modal Stack Example'
54+
: 'Stack with Dynamic Header',
55+
description: Platform.OS === 'ios'
56+
? 'Stack navigation with modals'
57+
: 'Dynamically showing and hiding the header',
5458
screen: ModalStack,
5559
},
5660
StacksInTabs: {
@@ -80,7 +84,7 @@ const ExampleRoutes = {
8084
const MainScreen = ({ navigation }) => (
8185
<ScrollView>
8286
<Banner />
83-
{Object.keys(ExampleRoutes).map((routeName: string) =>
87+
{Object.keys(ExampleRoutes).map((routeName: string) => (
8488
<TouchableOpacity
8589
key={routeName}
8690
onPress={() => {
@@ -92,28 +96,33 @@ const MainScreen = ({ navigation }) => (
9296
>
9397
<View style={styles.item}>
9498
<Text style={styles.title}>{ExampleRoutes[routeName].name}</Text>
95-
<Text style={styles.description}>{ExampleRoutes[routeName].description}</Text>
99+
<Text style={styles.description}>
100+
{ExampleRoutes[routeName].description}
101+
</Text>
96102
</View>
97103
</TouchableOpacity>
98-
)}
104+
))}
99105
</ScrollView>
100106
);
101107

102-
const AppNavigator = StackNavigator({
103-
...ExampleRoutes,
104-
Index: {
105-
screen: MainScreen,
108+
const AppNavigator = StackNavigator(
109+
{
110+
...ExampleRoutes,
111+
Index: {
112+
screen: MainScreen,
113+
},
106114
},
107-
}, {
108-
initialRouteName: 'Index',
109-
headerMode: 'none',
115+
{
116+
initialRouteName: 'Index',
117+
headerMode: 'none',
110118

111-
/*
119+
/*
112120
* Use modal on iOS because the card mode comes from the right,
113121
* which conflicts with the drawer example gesture
114122
*/
115-
mode: Platform.OS === 'ios' ? 'modal' : 'card',
116-
});
123+
mode: Platform.OS === 'ios' ? 'modal' : 'card',
124+
}
125+
);
117126

118127
export default () => <AppNavigator />;
119128

examples/NavigationPlayground/js/Banner.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22

33
import React from 'react';
44

5-
import {
6-
Image,
7-
Platform,
8-
StyleSheet,
9-
Text,
10-
View,
11-
} from 'react-native';
5+
import { Image, Platform, StyleSheet, Text, View } from 'react-native';
126

137
const Banner = () => (
148
<View style={styles.banner}>
15-
<Image
16-
source={require('./assets/NavLogo.png')}
17-
style={styles.image}
18-
/>
9+
<Image source={require('./assets/NavLogo.png')} style={styles.image} />
1910
<Text style={styles.title}>React Navigation Examples</Text>
2011
</View>
2112
);

examples/NavigationPlayground/js/CustomTabs.js

+29-38
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,18 @@ const MyNavScreen = ({ navigation, banner }) => (
3333
);
3434

3535
const MyHomeScreen = ({ navigation }) => (
36-
<MyNavScreen
37-
banner="Home Screen"
38-
navigation={navigation}
39-
/>
36+
<MyNavScreen banner="Home Screen" navigation={navigation} />
4037
);
4138

4239
const MyNotificationsScreen = ({ navigation }) => (
43-
<MyNavScreen
44-
banner="Notifications Screen"
45-
navigation={navigation}
46-
/>
40+
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
4741
);
4842

4943
const MySettingsScreen = ({ navigation }) => (
50-
<MyNavScreen
51-
banner="Settings Screen"
52-
navigation={navigation}
53-
/>
44+
<MyNavScreen banner="Settings Screen" navigation={navigation} />
5445
);
5546

56-
const CustomTabBar = ({
57-
navigation,
58-
}) => {
47+
const CustomTabBar = ({ navigation }) => {
5948
const { routes } = navigation.state;
6049
return (
6150
<View style={styles.tabContainer}>
@@ -70,12 +59,9 @@ const CustomTabBar = ({
7059
))}
7160
</View>
7261
);
73-
}
62+
};
7463

75-
const CustomTabView = ({
76-
router,
77-
navigation,
78-
}) => {
64+
const CustomTabView = ({ router, navigation }) => {
7965
const { routes, index } = navigation.state;
8066
const ActiveScreen = router.getComponentForState(navigation.state);
8167
return (
@@ -91,25 +77,30 @@ const CustomTabView = ({
9177
);
9278
};
9379

94-
const CustomTabRouter = TabRouter({
95-
Home: {
96-
screen: MyHomeScreen,
97-
path: '',
98-
},
99-
Notifications: {
100-
screen: MyNotificationsScreen,
101-
path: 'notifications',
102-
},
103-
Settings: {
104-
screen: MySettingsScreen,
105-
path: 'settings',
80+
const CustomTabRouter = TabRouter(
81+
{
82+
Home: {
83+
screen: MyHomeScreen,
84+
path: '',
85+
},
86+
Notifications: {
87+
screen: MyNotificationsScreen,
88+
path: 'notifications',
89+
},
90+
Settings: {
91+
screen: MySettingsScreen,
92+
path: 'settings',
93+
},
10694
},
107-
}, {
108-
// Change this to start on a different tab
109-
initialRouteName: 'Home',
110-
});
95+
{
96+
// Change this to start on a different tab
97+
initialRouteName: 'Home',
98+
}
99+
);
111100

112-
const CustomTabs = createNavigationContainer(createNavigator(CustomTabRouter)(CustomTabView));
101+
const CustomTabs = createNavigationContainer(
102+
createNavigator(CustomTabRouter)(CustomTabView)
103+
);
113104

114105
const styles = StyleSheet.create({
115106
container: {
@@ -127,7 +118,7 @@ const styles = StyleSheet.create({
127118
borderWidth: 1,
128119
borderColor: '#ddd',
129120
borderRadius: 4,
130-
}
121+
},
131122
});
132123

133124
export default CustomTabs;

0 commit comments

Comments
 (0)