Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Commit

Permalink
feat(#107): fixed all EsLint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Gasser committed May 8, 2019
1 parent 070ff67 commit b51385f
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 90 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
}
],
"no-underscore-dangle": "off",
"react/destructuring-assignment": "off"
"react/destructuring-assignment": "off",
"eslint/no-plus-plus": "off"
},
"overrides": [
{
Expand Down
16 changes: 10 additions & 6 deletions src/auth/login/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const mapPropsToValues = (obj) => {
};
};

const handleSubmit = (payload, { props }, _, __) => {
const onHandleSubmit = (payload, { props }) => {
props.onSubmit(payload);
};

const formikConfig = {
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
displayName: 'LoginForm',
};

Expand Down Expand Up @@ -118,15 +118,19 @@ const LoginForm = (props) => {

LoginForm.propTypes = {
values: PropTypes.shape({}).isRequired,
touched: PropTypes.bool.isRequired,
touched: PropTypes.shape({}).isRequired,
errors: PropTypes.shape({}).isRequired,
dirty: PropTypes.shape({}).isRequired,
dirty: PropTypes.bool.isRequired,
handleChange: PropTypes.func.isRequired,
handleBlur: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
handleReset: PropTypes.func.isRequired,
submitting: PropTypes.bool.isRequired,
error: PropTypes.string.isRequired,
error: PropTypes.string,
};

LoginForm.defaultProps = {
error: null,
};

const EnhancedLoginForm = formikEnhancer(LoginForm);
Expand All @@ -152,7 +156,7 @@ export const __testables__ = {
formikEnhancer,
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
LoginForm,
};

Expand Down
2 changes: 1 addition & 1 deletion src/auth/login/LoginView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const LoginView = ({
LoginView.propTypes = {
isAuthenticated: PropTypes.bool.isRequired,
loginRequest: HOCRequestPropTypes.isRequired,
logInUser: PropTypes.shape({}).isRequired,
logInUser: PropTypes.func.isRequired,
history: HistoryPropType.isRequired,
};

Expand Down
25 changes: 22 additions & 3 deletions src/auth/register/CheckEmailForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const mapPropsToValues = (obj) => {
};
};

const handleSubmit = (payload, { props }, b, c) => {
const onHandleSubmit = (payload, { props }) => {
props.onSubmit(payload);
};

const formikConfig = {
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
displayName: 'CheckEmailForm',
};

Expand Down Expand Up @@ -95,6 +95,25 @@ const CheckEmailForm = (props) => {
);
};

CheckEmailForm.propTypes = {
error: PropTypes.node,
validEmail: PropTypes.string,
values: PropTypes.shape({}).isRequired,
touched: PropTypes.shape({}).isRequired,
errors: PropTypes.shape({}).isRequired,
dirty: PropTypes.bool.isRequired,
handleChange: PropTypes.func.isRequired,
handleBlur: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
handleReset: PropTypes.func.isRequired,
submitting: PropTypes.bool.isRequired,
};

CheckEmailForm.defaultProps = {
error: null,
validEmail: null,
};

const EnhancedCheckEmailForm = formikEnhancer(CheckEmailForm);

EnhancedCheckEmailForm.propTypes = {
Expand All @@ -118,7 +137,7 @@ export const __testables__ = {
formikEnhancer,
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
CheckEmailForm,
};

Expand Down
17 changes: 10 additions & 7 deletions src/auth/register/RegisterForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const mapPropsToValues = (obj) => {
};
};

const handleSubmit = (payload, { props }) => {
const onHandleSubmit = (payload, { props }) => {
props.onSubmit(payload);
};

const formikConfig = {
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
displayName: 'RegisterForm',
};

Expand Down Expand Up @@ -137,19 +137,22 @@ const RegisterForm = ({
};

RegisterForm.propTypes = {
validEmail: undefined,
error: '',
error: PropTypes.string,
values: PropTypes.shape({}).isRequired,
touched: PropTypes.bool.isRequired,
touched: PropTypes.shape({}).isRequired,
errors: PropTypes.shape({}).isRequired,
dirty: PropTypes.shape({}).isRequired,
handleChange: PropTypes.func.isRequired,
handleBlur: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
handleReset: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
submitting: PropTypes.bool.isRequired,
};

RegisterForm.defaultProps = {
error: '',
};

const EnhancedRegisterForm = formikEnhancer(RegisterForm);

EnhancedRegisterForm.propTypes = {
Expand Down Expand Up @@ -180,7 +183,7 @@ export const __testables__ = {
formikEnhancer,
validationSchema,
mapPropsToValues,
handleSubmit,
handleSubmit: onHandleSubmit,
RegisterForm,
};

Expand Down
3 changes: 2 additions & 1 deletion src/auth/register/RegisterView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import View from '../../ui/View';
import { createUseIsAuthenticatedHistoryPush } from '../../ui/hooks/auth';

import * as Paths from '../../paths';
import { HOCRequestPropTypes } from '../../util/PropTypes';
import { HOCRequestPropTypes, HistoryPropType } from '../../util/PropTypes';
import { Colors } from '../../styles';

// creat hook
Expand Down Expand Up @@ -92,6 +92,7 @@ RegisterView.propTypes = {
isAuthenticated: PropTypes.bool.isRequired,
signupRequest: HOCRequestPropTypes.isRequired,
checkEmailRequest: HOCRequestPropTypes.isRequired,
history: HistoryPropType.isRequired,
validEmail: PropTypes.bool,
signupUser: PropTypes.func.isRequired,
checkEmail: PropTypes.func.isRequired,
Expand Down
20 changes: 2 additions & 18 deletions src/auth/register/__tests__/CheckEmailForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import { mount } from 'enzyme';

import { TextInput, CheckBox, Field } from '../../../ui/form/Form';
import { TextInput, Field } from '../../../ui/form/Form';
import Message from '../../../ui/form/Message';
import Button from '../../../ui/form/Button';

Expand All @@ -17,29 +17,13 @@ describe('Register form test suite', () => {
describe('Register test suite', () => {
const inputFields = ['email'];

const getFormProps = (values) => {
const getFormProps = () => {
// create basic formit state
const props = testUtils.createFormitState(inputFields);

return props;
// // enhance and modify for local usage
// return {
// ...props,
// error: null,
// values: {
// ...props.values,
// 'remember': false,
// ...values,
// },
// };
};

// const disabledFilter = (a) => {
// const { disabled } = a.props();

// return !disabled;
// }

it('should render', () => {
const props = getFormProps();
const wrapper = mount(<CheckEmailForm {...props} />);
Expand Down
5 changes: 2 additions & 3 deletions src/images/AddImageButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import AddImageMessage from './AddImageMessage';

import Button from '../ui/form/Button';

import { addImage } from '../redux/images';
import * as reduxImages from '../redux/images';
import { addImageIsLoading } from '../redux/images/selectors';

import { Colors, MediaSize } from '../styles';
Expand Down Expand Up @@ -43,7 +43,6 @@ const AddImageButton = ({
loading,
addImage,
afterOnClick,
children,
...props
}) => {
const [state, setState] = useState(initialState);
Expand Down Expand Up @@ -146,7 +145,7 @@ const select = state => ({
});

const mapDispatchToProps = ({
addImage,
addImage: reduxImages.addImage,
});

export const __testables__ = {
Expand Down
31 changes: 16 additions & 15 deletions src/images/__tests__/AddImageButton.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
import { mount } from 'enzyme';
import toJson from 'enzyme-to-json';
import 'jest-styled-components';

Expand Down Expand Up @@ -49,20 +49,21 @@ describe('AddImageButton test suite', () => {
});

describe('AddImageButton component test suite', () => {
const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPUYPg/EwADQQHCL18ShQAAAABJRU5ErkJggg==';

const getImageBlock = (imageString) => {
const byteCharacters = atob(imageString);
// byte values array creation
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);

// create blob
return new Blob([byteArray], { type: 'image/png' });
};
// eslint-disable-next-line max-len
// const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPUYPg/EwADQQHCL18ShQAAAABJRU5ErkJggg==';

// const getImageBlock = (imageString) => {
// const byteCharacters = atob(imageString);
// // byte values array creation
// const byteNumbers = new Array(byteCharacters.length);
// for (let i = 0; i < byteCharacters.length; i++) {
// byteNumbers[i] = byteCharacters.charCodeAt(i);
// }
// const byteArray = new Uint8Array(byteNumbers);

// // create blob
// return new Blob([byteArray], { type: 'image/png' });
// };

it('should render', () => {
const wrapper = getAddImageButton(initialProps);
Expand Down
2 changes: 0 additions & 2 deletions src/images/__tests__/AddImageMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ describe('AddImageMessage test suite', () => {
onHandleOpenImageDialog: jest.fn(),
};

const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPUYPg/EwADQQHCL18ShQAAAABJRU5ErkJggg==';

beforeEach(() => {
global.URL.createObjectURL = jest.fn(() => '');
});
Expand Down
17 changes: 9 additions & 8 deletions src/images/detail/DetailView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import View from '../../ui/View';
import AsyncContainer from '../../ui/async/AsyncContainer';

import { getImageCreationDateTime, getFormattedFileSize } from '../../util/util';
import { HOCRequestPropTypes } from '../../util/PropTypes';
import { HOCRequestPropTypes, HistoryPropType } from '../../util/PropTypes';

import * as Paths from '../../paths';
import { Colors, MediaSize, Sizes } from '../../styles';
Expand Down Expand Up @@ -161,6 +161,13 @@ const DetailView = ({
// generate meta render array
const metaValues = useMemo(() => convertMetaToAttributes(meta), [meta]);

const setBrowserParams = (params) => {
const { key, value } = params;

const path = `${Paths.GET_IMAGES_DETAIL(imageId)}?${key}=${value}`;
history.push(path);
};

// url handlers
const handleFaceClick = (face) => {
const { id } = face;
Expand All @@ -172,13 +179,6 @@ const DetailView = ({
setBrowserParams({ key: 'label', value: id });
};

const setBrowserParams = (params) => {
const { key, value } = params;

const path = `${Paths.GET_IMAGES_DETAIL(imageId)}?${key}=${value}`;
history.push(path);
};

return (
<StyledView>
<AddImageButton afterOnClick={() => history.push(Paths.HOME)} />
Expand Down Expand Up @@ -226,6 +226,7 @@ Faces (
};

DetailView.propTypes = {
history: HistoryPropType.isRequired,
image: PropTypes.shape({
id: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
Expand Down
6 changes: 5 additions & 1 deletion src/images/detail/Faces.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ Face.propTypes = {
attributes: PropTypes.arrayOf(AttributePropType).isRequired,
}).isRequired,
number: PropTypes.number.isRequired,
selected: PropTypes.bool.isRequired,
selected: PropTypes.bool,
onClick: PropTypes.func.isRequired,
};

Face.defaultProps = {
selected: false,
};

// faces wrapper component
const StyledFaces = styled(Box)``;

Expand Down
Loading

0 comments on commit b51385f

Please sign in to comment.