Skip to content

Commit d82e1a0

Browse files
Raúl Gómez Acuñasatya164
Raúl Gómez Acuña
authored andcommitted
chore: fix linting errors + add precommit hook for flow and lint (callstack#114)
1 parent 16c3ea2 commit d82e1a0

23 files changed

+81
-52
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,6 @@
142142
"react-native/no-unused-styles": "error",
143143
"react-native/split-platform-components": "off",
144144

145-
"prettier/prettier": ["error", {"trailingComma": "es5", "singleQuote": true}],
145+
"prettier/prettier": ["error", {"trailingComma": "es5", "singleQuote": true}]
146146
}
147147
}

example/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class App extends Component {
3030
return (
3131
<View style={styles.drawerContent}>
3232
<Drawer.Section label="Subheader">
33-
{DrawerItems.map((props, index) => (
33+
{DrawerItems.map((props, index) =>
3434
<Drawer.Item
3535
{...props}
3636
key={props.key}
3737
active={this.state.drawerItemIndex === index}
3838
onPress={() => this._setDrawerItem(index)}
3939
/>
40-
))}
40+
)}
4141
</Drawer.Section>
4242
</View>
4343
);

example/rn-cli.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ module.exports = {
2323
`^${escape(path.resolve(__dirname, '..', 'node_modules'))}\\/.*$`
2424
),
2525
new RegExp(
26-
`^${escape(path.resolve(__dirname, '..', 'docs', 'node_modules'))}\\/.*$`
26+
`^${escape(
27+
path.resolve(__dirname, '..', 'docs', 'node_modules')
28+
)}\\/.*$`
2729
),
2830
]);
2931
},

example/src/ButtonExample.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export default class ButtonExample extends Component {
2121
</View>
2222
<View style={styles.row}>
2323
<Button raised>Raised</Button>
24-
<Button raised primary>Primary</Button>
25-
<Button raised color={Colors.pink500}>Custom</Button>
24+
<Button raised primary>
25+
Primary
26+
</Button>
27+
<Button raised color={Colors.pink500}>
28+
Custom
29+
</Button>
2630
</View>
2731
<View style={styles.row}>
2832
<Button icon="add-a-photo">Icon</Button>
@@ -38,7 +42,9 @@ export default class ButtonExample extends Component {
3842
</Button>
3943
</View>
4044
<View style={styles.row}>
41-
<Button disabled icon="my-location">Disabled</Button>
45+
<Button disabled icon="my-location">
46+
Disabled
47+
</Button>
4248
<Button disabled loading raised>
4349
Loading
4450
</Button>

example/src/CardExample.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export default class CardExample extends Component {
2525
<Card.Content>
2626
<Title>Abandoned Ship</Title>
2727
<Paragraph>
28-
The Abandoned Ship is a wrecked ship located on Route 108 in Hoenn, originally being a ship named the S.S. Cactus. The second part of the ship can only be accessed by using Dive and contains the Scanner.
28+
The Abandoned Ship is a wrecked ship located on Route 108 in
29+
Hoenn, originally being a ship named the S.S. Cactus. The second
30+
part of the ship can only be accessed by using Dive and contains
31+
the Scanner.
2932
</Paragraph>
3033
</Card.Content>
3134
</Card>
@@ -41,7 +44,11 @@ export default class CardExample extends Component {
4144
<Title>Berries</Title>
4245
<Caption>Omega Ruby</Caption>
4346
<Paragraph>
44-
Dotted around the Hoenn region, you will find loamy soil, many of which are housing berries. Once you have picked the berries, then you have the ability to use that loamy soil to grow your own berries. These can be any berry and will require attention to get the best crop.
47+
Dotted around the Hoenn region, you will find loamy soil, many of
48+
which are housing berries. Once you have picked the berries, then
49+
you have the ability to use that loamy soil to grow your own
50+
berries. These can be any berry and will require attention to get
51+
the best crop.
4552
</Paragraph>
4653
</Card.Content>
4754
</Card>

example/src/DividerExample.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ const DividerExample = () => {
1919
<ListView
2020
style={styles.container}
2121
dataSource={dataSource}
22-
renderRow={rowData => (
22+
renderRow={rowData =>
2323
<Subheading style={styles.item}>
2424
{rowData}
25-
</Subheading>
26-
)}
25+
</Subheading>}
2726
renderSeparator={(sectionId, rowId) => <Divider key={rowId} />}
2827
/>
2928
);

example/src/ExampleList.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ export default class ExampleList extends Component {
4242
navigation: PropTypes.object,
4343
};
4444

45-
_renderRow = id => (
45+
_renderRow = id =>
4646
<TouchableRipple
4747
style={styles.item}
4848
onPress={() => this.props.navigation.navigate(id)}
4949
>
50-
<Text style={styles.text}>{examples[id].title}</Text>
51-
</TouchableRipple>
52-
);
50+
<Text style={styles.text}>
51+
{examples[id].title}
52+
</Text>
53+
</TouchableRipple>;
5354

5455
_renderSeparator = (sectionId, rowId) => <Divider key={rowId} />;
5556

example/src/GridViewExample.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export default class GridViewExample extends Component {
4242
return (
4343
<Card style={styles.tile}>
4444
<View style={styles.inner}>
45-
<Text style={styles.text}>{index}</Text>
45+
<Text style={styles.text}>
46+
{index}
47+
</Text>
4648
</View>
4749
</Card>
4850
);

example/src/PaperExample.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default class RipplesExample extends Component {
1616
{[1, 2, 4, 6, 12].map(i => {
1717
return (
1818
<Paper key={i} elevation={i} style={styles.paper}>
19-
<Text>{i}</Text>
19+
<Text>
20+
{i}
21+
</Text>
2022
</Paper>
2123
);
2224
})}

example/src/RootNavigator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export default StackNavigator(
3434
headerStyle: {
3535
backgroundColor: Colors.indigo500,
3636
paddingTop: Expo.Constants.statusBarHeight,
37-
height: (Platform.OS === 'ios' ? 44 : 56) +
38-
Expo.Constants.statusBarHeight,
37+
height:
38+
(Platform.OS === 'ios' ? 44 : 56) + Expo.Constants.statusBarHeight,
3939
},
4040
},
4141
}

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"eslint-plugin-react": "^7.0.0",
3333
"eslint-plugin-react-native": "^2.3.2",
3434
"flow-bin": "~0.40.0",
35+
"husky": "^0.14.2",
3536
"prettier": "^1.3.1",
3637
"react": "16.0.0-alpha.6",
3738
"react-native": "~0.43.2",
@@ -43,6 +44,7 @@
4344
"react-native-drawer": "^2.3.0"
4445
},
4546
"scripts": {
47+
"precommit": "npm run lint && npm run flow",
4648
"flow": "flow",
4749
"lint": "eslint .",
4850
"test": "echo \"Error: no test specified\" && exit 1"

src/components/Button.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ class Button extends PureComponent<void, Props, State> {
162162
if (typeof dark === 'boolean') {
163163
isDark = dark;
164164
} else {
165-
isDark = backgroundColor === 'transparent'
166-
? false
167-
: !color(backgroundColor).light();
165+
isDark =
166+
backgroundColor === 'transparent'
167+
? false
168+
: !color(backgroundColor).light();
168169
}
169170

170171
if (disabled) {

src/components/FAB.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ type Props = {
2727
const FAB = (props: Props) => {
2828
const { small, dark, icon, color: iconColor, onPress, theme, style } = props;
2929
const backgroundColor = theme.colors.accent;
30-
const isDark = typeof dark === 'boolean'
31-
? dark
32-
: !color(backgroundColor).light();
30+
const isDark =
31+
typeof dark === 'boolean' ? dark : !color(backgroundColor).light();
3332
const textColor = iconColor || (isDark ? white : 'rgba(0, 0, 0, .54)');
3433
const rippleColor = color(textColor).alpha(0.32).rgbaString();
3534

src/components/GridView.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ type State = {
3030
layout: Layout,
3131
};
3232

33-
export default class GridView
34-
extends PureComponent<DefaultProps, Props, State> {
33+
export default class GridView extends PureComponent<
34+
DefaultProps,
35+
Props,
36+
State
37+
> {
3538
static propTypes = {
3639
dataSource: PropTypes.instanceOf(ListView.DataSource).isRequired,
3740
spacing: PropTypes.number.isRequired,
@@ -83,7 +86,8 @@ export default class GridView
8386
const containerWidth = this.state.layout.width;
8487
const { getNumberOfColumns, spacing } = this.props;
8588
const style = {
86-
width: (containerWidth - spacing) / getNumberOfColumns(containerWidth) -
89+
width:
90+
(containerWidth - spacing) / getNumberOfColumns(containerWidth) -
8791
spacing,
8892
margin: spacing / 2,
8993
};

src/components/Portal/PortalHost.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ export default class Portals extends PureComponent<void, Props, State> {
100100
return [...acc, group];
101101
}
102102
}, [])
103-
.map(({ position, items }) => (
103+
.map(({ position, items }) =>
104104
<View key={position} style={StyleSheet.absoluteFill}>
105105
{items}
106106
</View>
107-
))}
107+
)}
108108
</View>
109109
);
110110
}

src/components/TouchableRipple/TouchableRipple.android.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ type DefaultProps = {
2020
rippleColor: string,
2121
};
2222

23-
export default class TouchableRipple
24-
extends PureComponent<DefaultProps, Props, void> {
23+
export default class TouchableRipple extends PureComponent<
24+
DefaultProps,
25+
Props,
26+
void
27+
> {
2528
static propTypes = {
2629
children: PropTypes.element.isRequired,
2730
borderless: PropTypes.bool,

src/components/TouchableRipple/TouchableRipple.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ type DefaultProps = {
2121
rippleColor: string,
2222
};
2323

24-
export default class TouchableRipple
25-
extends PureComponent<DefaultProps, Props, void> {
24+
export default class TouchableRipple extends PureComponent<
25+
DefaultProps,
26+
Props,
27+
void
28+
> {
2629
static propTypes = {
2730
borderless: PropTypes.bool,
2831
delayPressIn: PropTypes.number,

src/components/Typography/Caption.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ type Props = {
88
style?: any,
99
};
1010

11-
const Caption = (props: Props) => (
11+
const Caption = (props: Props) =>
1212
<StyledText
1313
{...props}
1414
alpha={0.54}
1515
family="regular"
1616
style={[styles.text, props.style]}
17-
/>
18-
);
17+
/>;
1918

2019
export default Caption;
2120

src/components/Typography/Headline.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ type Props = {
88
style?: any,
99
};
1010

11-
const Headline = (props: Props) => (
11+
const Headline = (props: Props) =>
1212
<StyledText
1313
{...props}
1414
alpha={0.87}
1515
family="regular"
1616
style={[styles.text, props.style]}
17-
/>
18-
);
17+
/>;
1918

2019
export default Headline;
2120

src/components/Typography/Paragraph.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ type Props = {
88
style?: any,
99
};
1010

11-
const Paragraph = (props: Props) => (
11+
const Paragraph = (props: Props) =>
1212
<StyledText
1313
{...props}
1414
alpha={0.87}
1515
family="regular"
1616
style={[styles.text, props.style]}
17-
/>
18-
);
17+
/>;
1918

2019
export default Paragraph;
2120

src/components/Typography/Subheading.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ type Props = {
88
style?: any,
99
};
1010

11-
const Subheading = (props: Props) => (
11+
const Subheading = (props: Props) =>
1212
<StyledText
1313
{...props}
1414
alpha={0.87}
1515
family="regular"
1616
style={[styles.text, props.style]}
17-
/>
18-
);
17+
/>;
1918

2019
export default Subheading;
2120

src/components/Typography/Title.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ type Props = {
88
style?: any,
99
};
1010

11-
const Title = (props: Props) => (
11+
const Title = (props: Props) =>
1212
<StyledText
1313
{...props}
1414
alpha={0.87}
1515
family="medium"
1616
style={[styles.text, props.style]}
17-
/>
18-
);
17+
/>;
1918

2019
export default Title;
2120

src/core/ThemeProvider.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ type Props = {
1616

1717
export const channel = 'react-native-paper$theme';
1818

19-
export default class ThemeProvider
20-
extends PureComponent<DefaultProps, Props, void> {
19+
export default class ThemeProvider extends PureComponent<
20+
DefaultProps,
21+
Props,
22+
void
23+
> {
2124
static propTypes = {
2225
children: PropTypes.element.isRequired,
2326
theme: PropTypes.object,

0 commit comments

Comments
 (0)