Skip to content

Commit 1d20a2c

Browse files
committed
style: update prettier config
1 parent 2c9d65c commit 1d20a2c

10 files changed

Lines changed: 81 additions & 30 deletions

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": false
3+
}

src/__tests__/makeReactNativeField.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const Input = compose(
3030
describe("makeReactNativeField", () => {
3131
it("sets the input value", () => {
3232
const emailInput = mount(<Input name="email" />);
33-
expect(emailInput.find(TextInput).props().value).toEqual("contact@bam.tech");
33+
expect(emailInput.find(TextInput).props().value).toEqual(
34+
"contact@bam.tech"
35+
);
3436
const otherInput = mount(<Input name="other" />);
3537
expect(otherInput.find(TextInput).props().value).toEqual(undefined);
3638
});

src/__tests__/withError.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ const Input = compose(
2424
describe("withError", () => {
2525
it("sets the error prop", () => {
2626
const erroredInput = mount(<Input name="email" />);
27-
expect(erroredInput.find(TextInput).props().error).toEqual("This is not a valid email.");
27+
expect(erroredInput.find(TextInput).props().error).toEqual(
28+
"This is not a valid email."
29+
);
2830
const validInput = mount(<Input name="valid" />);
2931
expect(validInput.find(TextInput).props().error).toBeFalsy();
3032
});
3133

3234
it("sets the error prop for nested key name", () => {
3335
const emailInput = mount(<Input name="user.password" />);
34-
expect(emailInput.find(TextInput).props().error).toEqual("Password is too short!");
36+
expect(emailInput.find(TextInput).props().error).toEqual(
37+
"Password is too short!"
38+
);
3539
const otherInput = mount(<Input name="user.username" />);
3640
expect(otherInput.find(TextInput).props().error).toEqual(undefined);
3741
});

src/__tests__/withInputTypeProps.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ describe("withInputTypeProps", () => {
1919
expect(withoutType.find(TextInput).props().someProp).toEqual("someValue");
2020
const withType = mount(<Input type="email" someProp="someValue" />);
2121
expect(withType.find(TextInput).props().someProp).toEqual("someValue");
22-
const withUnknownType = mount(<Input type="unknown" someProp="someValue" />);
23-
expect(withUnknownType.find(TextInput).props().someProp).toEqual("someValue");
22+
const withUnknownType = mount(
23+
<Input type="unknown" someProp="someValue" />
24+
);
25+
expect(withUnknownType.find(TextInput).props().someProp).toEqual(
26+
"someValue"
27+
);
2428
});
2529
});

src/__tests__/withNextInputAutoFocus.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ describe("withNextInputAutoFocus", () => {
6565
const onSubmitEditing = jest.fn();
6666
const wrapper = mount(
6767
<Form>
68-
<Input name="first" returnKeyType="correct value" onSubmitEditing={onSubmitEditing} />
68+
<Input
69+
name="first"
70+
returnKeyType="correct value"
71+
onSubmitEditing={onSubmitEditing}
72+
/>
6973
</Form>
7074
);
7175

src/makeReactNativeField.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@ import withFormik from "./withFormik";
55

66
const makeReactNativeField = compose(
77
withFormik,
8-
mapProps(({ formik: { setFieldValue, setFieldTouched, values, isSubmitting }, name, ...props }) => ({
9-
value: _.get(values, name),
10-
...props,
11-
name,
12-
onChangeText: text => {
13-
setFieldValue(name, text);
14-
if (props.onChangeText) props.onChangeText(text);
15-
},
16-
onBlur: () => {
17-
// validate onBlur only while not submitting
18-
// this prevents validating twice in succession when clicking 'done' on keyboard - first onSubmitEditing, then onBlur
19-
setFieldTouched(name, true, !isSubmitting);
20-
if (props.onBlur) props.onBlur();
21-
}
22-
}))
8+
mapProps(
9+
({
10+
formik: { setFieldValue, setFieldTouched, values, isSubmitting },
11+
name,
12+
...props
13+
}) => ({
14+
value: _.get(values, name),
15+
...props,
16+
name,
17+
onChangeText: text => {
18+
setFieldValue(name, text);
19+
if (props.onChangeText) props.onChangeText(text);
20+
},
21+
onBlur: () => {
22+
// validate onBlur only while not submitting
23+
// this prevents validating twice in succession when clicking 'done' on keyboard - first onSubmitEditing, then onBlur
24+
setFieldTouched(name, true, !isSubmitting);
25+
if (props.onBlur) props.onBlur();
26+
}
27+
})
28+
)
2329
);
2430

2531
export default makeReactNativeField;

src/withFocus.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ const withFocusProp = WrappedInput => {
1717
};
1818

1919
render() {
20-
return <WrappedInput focused={this.state.focused} {...this.props} onBlur={this.onBlur} onFocus={this.onFocus} />;
20+
return (
21+
<WrappedInput
22+
focused={this.state.focused}
23+
{...this.props}
24+
onBlur={this.onBlur}
25+
onFocus={this.onFocus}
26+
/>
27+
);
2128
}
2229
};
2330
};

src/withPickerValues/KeyboardModal.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ const renderModal = (props: PropsType, open: ?boolean) => (
1717
position="bottom"
1818
moveAboveKeyboard={false}
1919
isOpen={open}
20-
style={[{ height: 216, backgroundColor: "rgb(200, 203, 211)" }, props.style]}
20+
style={[
21+
{ height: 216, backgroundColor: "rgb(200, 203, 211)" },
22+
props.style
23+
]}
2124
easing={props.easingAnimation}
2225
>
2326
{props.children}
@@ -32,7 +35,8 @@ let currentProps;
3235

3336
const updateKeyboardModalComponent = (props: PropsType, open: ?boolean) => {
3437
if (open) currentProps = props;
35-
if (keyboardModalInstance) keyboardModalInstance.update(renderModal(props, open));
38+
if (keyboardModalInstance)
39+
keyboardModalInstance.update(renderModal(props, open));
3640
};
3741

3842
const open = (keyboardComponent: any) => {
@@ -54,7 +58,10 @@ const createKeyboardModalComponent = (props: PropsType) => {
5458
currentProps = props;
5559

5660
keyboardModalInstance = new RootSiblings(renderModal(props));
57-
keyboardDidShowListener = Keyboard.addListener("keyboardWillShow", keyboardDidShow);
61+
keyboardDidShowListener = Keyboard.addListener(
62+
"keyboardWillShow",
63+
keyboardDidShow
64+
);
5865
};
5966

6067
const removeKeyboardModalComponent = () => {

src/withPickerValues/PickerModal.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class PickerModal extends PureComponent<PropsType> {
3232
values.unshift({ value: "", label: "" });
3333
}
3434
const picker = (
35-
<Picker onValueChange={this.onValueChange} selectedValue={value} prompt={placeholder}>
35+
<Picker
36+
onValueChange={this.onValueChange}
37+
selectedValue={value}
38+
prompt={placeholder}
39+
>
3640
{values.map(item => (
3741
<Picker.Item key={item.value} {...item} />
3842
))}
@@ -66,7 +70,9 @@ class PickerModal extends PureComponent<PropsType> {
6670
render() {
6771
return (
6872
<View>
69-
<DisableKeyboard onPress={this.openPicker}>{this.props.children}</DisableKeyboard>
73+
<DisableKeyboard onPress={this.openPicker}>
74+
{this.props.children}
75+
</DisableKeyboard>
7076
{this.renderPicker()}
7177
</View>
7278
);

src/withPickerValues/withPickerValues.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@ import React from "react";
44
import PickerModal from "./PickerModal";
55

66
const withPickerModal = Component => {
7-
class WithPickerModal extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
7+
class WithPickerModal extends React.Component<
8+
$FlowFixMeProps,
9+
$FlowFixMeState
10+
> {
811
render() {
912
const selectedItem =
1013
this.props.values && this.props.values.length > 0
11-
? this.props.values.find(item => item && item.value === this.props.value)
14+
? this.props.values.find(
15+
item => item && item.value === this.props.value
16+
)
1217
: undefined;
1318
return (
1419
<PickerModal {...this.props}>
15-
<Component {...this.props} value={selectedItem ? selectedItem.label : ""} />
20+
<Component
21+
{...this.props}
22+
value={selectedItem ? selectedItem.label : ""}
23+
/>
1624
</PickerModal>
1725
);
1826
}

0 commit comments

Comments
 (0)