Skip to content

Commit e4ee2d7

Browse files
committed
chore(eslint): add linter config
1 parent f5e975b commit e4ee2d7

19 files changed

Lines changed: 720 additions & 106 deletions

index.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { compose } from 'recompose';
2-
import setFormikInitialValue from './src/setFormikInitialValue';
3-
import withError from './src/withError';
4-
import withFocus from './src/withFocus';
5-
import withFormik from './src/withFormik';
6-
import withInputTypeProps from './src/withInputTypeProps';
7-
import withTouched from './src/withTouched';
8-
import withPickerValues from './src/withPickerValues';
9-
import KeyboardModal from './src/withPickerValues/KeyboardModal';
10-
import makeReactNativeField from './src/makeReactNativeField';
11-
import {
12-
withNextInputAutoFocusForm,
13-
withNextInputAutoFocusInput,
14-
} from './src/withNextInputAutoFocus';
1+
import { compose } from "recompose";
2+
import setFormikInitialValue from "./src/setFormikInitialValue";
3+
import withError from "./src/withError";
4+
import withFocus from "./src/withFocus";
5+
import withFormik from "./src/withFormik";
6+
import withInputTypeProps from "./src/withInputTypeProps";
7+
import withTouched from "./src/withTouched";
8+
import withPickerValues from "./src/withPickerValues";
9+
import KeyboardModal from "./src/withPickerValues/KeyboardModal";
10+
import makeReactNativeField from "./src/makeReactNativeField";
11+
import { withNextInputAutoFocusForm, withNextInputAutoFocusInput } from "./src/withNextInputAutoFocus";
1512

1613
const makeInputsGreatAgain = compose(
1714
withInputTypeProps,

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"type": "index.d.ts",
77
"scripts": {
8-
"test": "jest --coverage",
8+
"test": "eslint index.js src && jest --coverage",
99
"commitmsg": "validate-commit-msg",
1010
"commit": "git-cz",
1111
"semantic-release": "semantic-release",
@@ -43,9 +43,12 @@
4343
"cz-conventional-changelog": "^2.1.0",
4444
"enzyme": "^3.3.0",
4545
"enzyme-adapter-react-16": "^1.0.0",
46+
"eslint": "^5.2.0",
47+
"eslint-config-bambi": "^1.4.0",
4648
"formik": "^1.0.2",
4749
"husky": "^0.14.3",
4850
"jest": "^22.4.2",
51+
"prettier": "^1.14.0",
4952
"react": "16.2.0",
5053
"react-dom": "16.2.0",
5154
"react-native": "0.53.0",
@@ -60,5 +63,11 @@
6063
},
6164
"peerDependencies": {
6265
"formik": ">= 0.11.x < 2"
66+
},
67+
"eslintConfig": {
68+
"extends": "bambi/native",
69+
"rules": {
70+
"no-unused-vars": "error"
71+
}
6372
}
6473
}

src/__tests__/makeReactNativeField.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import { compose, withContext } from "recompose";
2+
import { compose } from "recompose";
43
import { TextInput } from "react-native";
54
import { mount } from "enzyme";
65

@@ -19,11 +18,14 @@ const formikContext = {
1918
email: "contact@bam.tech",
2019
user: {
2120
username: "bam-dev",
22-
password: 'goodchallenge',
21+
password: "goodchallenge"
2322
}
2423
}
2524
};
26-
const Input = compose(withFormikMock(formikContext), makeReactNativeField)(TextInput);
25+
const Input = compose(
26+
withFormikMock(formikContext),
27+
makeReactNativeField
28+
)(TextInput);
2729

2830
describe("makeReactNativeField", () => {
2931
it("sets the input value", () => {
@@ -33,7 +35,7 @@ describe("makeReactNativeField", () => {
3335
expect(otherInput.find(TextInput).props().value).toEqual(undefined);
3436
});
3537

36-
it('sets the input value for nested key name', () => {
38+
it("sets the input value for nested key name", () => {
3739
const emailInput = mount(<Input name="user.username" />);
3840
expect(emailInput.find(TextInput).props().value).toEqual("bam-dev");
3941
const otherInput = mount(<Input name="user.other" />);

src/__tests__/setFormikInitialValue.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import { compose, withContext } from "recompose";
2+
import { compose } from "recompose";
43
import { TextInput } from "react-native";
54
import { mount } from "enzyme";
65

@@ -22,12 +21,15 @@ beforeEach(() => {
2221
}
2322
};
2423

25-
Input = compose(withFormikMock(formikContext), setFormikInitialValue)(TextInput);
24+
Input = compose(
25+
withFormikMock(formikContext),
26+
setFormikInitialValue
27+
)(TextInput);
2628
});
2729

2830
describe("setFormikInitialValue", () => {
2931
it("sets the initial value to ''", () => {
30-
const touchedInput = mount(<Input name="inputName" />);
32+
mount(<Input name="inputName" />);
3133
expect(setFieldValue).toBeCalledWith("inputName", "");
3234
});
3335

@@ -37,7 +39,7 @@ describe("setFormikInitialValue", () => {
3739
});
3840

3941
it("does not set initial value if set by formik, e.g. with initial values", () => {
40-
const wrapper = mount(<Input name="this input has been set by formik" />);
41-
expect(setFieldValue).not.toBeCalled()
42+
mount(<Input name="this input has been set by formik" />);
43+
expect(setFieldValue).not.toBeCalled();
4244
});
4345
});

src/__tests__/withError.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import { compose, withContext } from "recompose";
2+
import { compose } from "recompose";
43
import { TextInput } from "react-native";
54
import { mount } from "enzyme";
65

@@ -17,7 +16,10 @@ const formikContext = {
1716
}
1817
}
1918
};
20-
const Input = compose(withFormikMock(formikContext), withError)(TextInput);
19+
const Input = compose(
20+
withFormikMock(formikContext),
21+
withError
22+
)(TextInput);
2123

2224
describe("withError", () => {
2325
it("sets the error prop", () => {
@@ -27,7 +29,7 @@ describe("withError", () => {
2729
expect(validInput.find(TextInput).props().error).toBeFalsy();
2830
});
2931

30-
it('sets the error prop for nested key name', () => {
32+
it("sets the error prop for nested key name", () => {
3133
const emailInput = mount(<Input name="user.password" />);
3234
expect(emailInput.find(TextInput).props().error).toEqual("Password is too short!");
3335
const otherInput = mount(<Input name="user.username" />);

src/__tests__/withNextInputAutoFocus.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import { compose, withContext } from "recompose";
2+
import { compose } from "recompose";
43
import { Button, View } from "react-native";
54
import { mount } from "enzyme";
65

@@ -9,9 +8,12 @@ import withFormikMock from "../testUtils/withFormikMock";
98

109
const submitForm = jest.fn();
1110

12-
const Form = compose(withFormikMock({
13-
submitForm
14-
}), withNextInputAutoFocusForm)(View);
11+
const Form = compose(
12+
withFormikMock({
13+
submitForm
14+
}),
15+
withNextInputAutoFocusForm
16+
)(View);
1517

1618
const focusInput = jest.fn();
1719
class TextInput extends React.PureComponent {
@@ -63,11 +65,7 @@ describe("withNextInputAutoFocus", () => {
6365
const onSubmitEditing = jest.fn();
6466
const wrapper = mount(
6567
<Form>
66-
<Input
67-
name="first"
68-
returnKeyType="correct value"
69-
onSubmitEditing={onSubmitEditing}
70-
/>
68+
<Input name="first" returnKeyType="correct value" onSubmitEditing={onSubmitEditing} />
7169
</Form>
7270
);
7371

src/__tests__/withTouched.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import { compose, withContext } from "recompose";
2+
import { compose } from "recompose";
43
import { TextInput } from "react-native";
54
import { mount } from "enzyme";
65

src/makeReactNativeField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { compose, mapProps } from "recompose";
2-
import _ from 'lodash';
2+
import _ from "lodash";
33

44
import withFormik from "./withFormik";
55

src/setFormikInitialValue.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { compose, mapProps } from "recompose";
2+
import { compose } from "recompose";
33
import { has } from "lodash";
44
import withFormik from "./withFormik";
55

@@ -20,4 +20,7 @@ const setFormikInitialValue = WrappedInput => {
2020
};
2121
};
2222

23-
export default compose(withFormik, setFormikInitialValue);
23+
export default compose(
24+
withFormik,
25+
setFormikInitialValue
26+
);

src/testUtils/withFormikMock.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from "react";
22
import { FormikProvider } from "formik";
33

4-
export default formikContextValue => Component => props => (
4+
const withFormikMock = formikContextValue => Component => props => (
55
<FormikProvider value={formikContextValue}>
66
<Component {...props} />
77
</FormikProvider>
88
);
9+
10+
export default withFormikMock;

0 commit comments

Comments
 (0)