Skip to content

Commit

Permalink
Update to latest Flow version and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
julianguyen committed Apr 14, 2022
1 parent c1aca12 commit b0f5a4d
Show file tree
Hide file tree
Showing 64 changed files with 284 additions and 316 deletions.
1 change: 1 addition & 0 deletions client/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.*/__tests__/.*
.*/node_modules/draft-js/.*
.*/node_modules/radium/.*
.*/node_modules/resolve/.*

[include]

Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Accordion/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import { Utils } from 'utils';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCaretDown, faCaretUp } from '@fortawesome/free-solid-svg-icons';
Expand All @@ -26,7 +27,7 @@ export const Accordion = ({
dark,
large,
open: openProp,
}: Props) => {
}: Props): Node => {
const [open, setOpen] = useState(!!openProp);

const displayContent = () => (
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Avatar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import LazyLoad from 'react-lazyload';
import React from 'react';
import type { Node } from 'react';
import css from './Avatar.scss';

export type Props = {
Expand All @@ -25,7 +26,7 @@ const getHeight = (small: ?boolean, large: ?boolean) => {
return 100;
};

export const Avatar = (props: Props) => {
export const Avatar = (props: Props): Node => {
const {
name, alt, src, small, large,
} = props;
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/BaseContainer/StoryContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import { Story } from 'components/Story';
import type { Props as StoryProps } from 'components/Story';

export type Props = {
data: StoryProps[],
};

const StoryContainer = ({ data }: Props) => (
const StoryContainer = ({ data }: Props): Node => (
<div className="gridTwo">
{data.map((storyProps) => (
<div className="gridTwoItemBoxLight" key={storyProps.link}>
Expand Down
5 changes: 3 additions & 2 deletions client/app/components/BaseContainer/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import axios from 'axios';
import { Utils } from 'utils';
import StoryContainer from 'components/BaseContainer/StoryContainer';
Expand All @@ -23,7 +24,7 @@ export const BaseContainerComponent = ({
data: dataProps,
fetchUrl: fetchUrlProps,
lastPage: lastPageProps,
}: Props) => {
}: Props): Node => {
const [page, setpage] = useState(1);
const [lastPage, setlastPage] = useState(!!lastPageProps);
const [data, setdata] = useState(dataProps);
Expand Down Expand Up @@ -59,7 +60,7 @@ export const BaseContainerComponent = ({

export default ({
container, data, fetchUrl, lastPage,
}: Props) => (
}: Props): Node => (
<BaseContainerComponent
container={container}
data={data}
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Blockquote/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import css from './Blockquote.scss';

export type Props = {
text?: string,
author?: string,
};

export const Blockquote = (props: Props) => {
export const Blockquote = (props: Props): Node => {
const { text, author } = props;
const textClassNames = `${css.text}`;
const authorClassNames = `${css.author}`;
Expand Down
5 changes: 3 additions & 2 deletions client/app/components/Chart/ChartControl.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import { I18n } from 'libs/i18n';
import globalCss from 'styles/_global.scss';
import { Chart } from 'components/Chart';
Expand Down Expand Up @@ -30,8 +31,8 @@ const ChartControlButton = ({ type, onClick }: ChartControlButtonProps) => (
export const ChartControl = ({
types,
initialParams: { type: initialType, data },
}: chartControlProps) => {
const [type: string, setType] = useState(initialType);
}: chartControlProps): Node => {
const [type, setType]: [string, Function] = useState(initialType);

const onSelectType = (value: string) => () => {
setType(value);
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Chart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint react/jsx-props-no-spreading: 0 */
import { Chart as ChartJS } from 'chart.js';
import React from 'react';
import type { Node } from 'react';
import { AreaChart, LineChart } from 'react-chartkick';

ChartJS.defaults.global.defaultFontFamily = 'Lato';
Expand All @@ -15,7 +16,7 @@ type chartShape = {

const colorSchemes = ['#6D0839', '#66118', '#7F503F', '#775577', '#CCAADD'];

export function Chart({ chartType, ...props }: chartShape) {
export function Chart({ chartType, ...props }: chartShape): Node {
return chartType === 'Line' ? (
<LineChart {...props} colors={colorSchemes} />
) : (
Expand Down
8 changes: 5 additions & 3 deletions client/app/components/Form/DynamicForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @flow
/* eslint-disable max-len */
import React, { useState } from 'react';
import type { Node } from 'react';
import axios from 'axios';
import Input from 'components/Input';
import { TYPES as INPUT_TYPES } from 'components/Input/utils';
Expand Down Expand Up @@ -52,14 +54,14 @@ const getParams = (inputs: MyInputProps[], myRefs: Object) => {
return params;
};

export const hasErrors = (errors: Errors) => Object.values(errors).filter((key) => key).length;
export const hasErrors = (errors: Errors): number => Object.values(errors).filter((key) => key).length;

export const DynamicForm = ({
nameValue,
formProps,
onSubmit,
type,
}: Props) => {
}: Props): Node => {
const [inputs, setInputs] = useState<MyInputProps[]>(
getInputsInitialState(formProps, nameValue),
);
Expand Down Expand Up @@ -147,7 +149,7 @@ export const DynamicForm = ({

export default ({
nameValue, formProps, onSubmit, type,
}: Props) => (
}: Props): Node => (
<DynamicForm
nameValue={nameValue}
formProps={formProps}
Expand Down
7 changes: 4 additions & 3 deletions client/app/components/Form/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
/* eslint-disable max-len */
import React, { useState, type Node } from 'react';
import Input from 'components/Input';
import { TYPES as INPUT_TYPES } from 'components/Input/utils';
Expand All @@ -13,11 +14,11 @@ export type State = {
errors: Errors,
};

export const hasErrors = (errors: Errors) => Object.values(errors).filter((key) => key).length;
export const hasErrors = (errors: Errors): number => Object.values(errors).filter((key) => key).length;

const getInputsInitialState = (inputs: MyInputProps[]) => inputs.filter((input) => input !== {});

export const Form = ({ action, inputs: inputsProps }: Props) => {
export const Form = ({ action, inputs: inputsProps }: Props): Node => {
const [inputs, setInputs] = useState<MyInputProps[]>(
getInputsInitialState(inputsProps),
);
Expand Down Expand Up @@ -142,6 +143,6 @@ export const Form = ({ action, inputs: inputsProps }: Props) => {
);
};

export default ({ action, inputs }: Props) => (
export default ({ action, inputs }: Props): Node => (
<Form action={action} inputs={inputs} />
);
3 changes: 2 additions & 1 deletion client/app/components/Header/HeaderProfile.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBell } from '@fortawesome/free-solid-svg-icons';
import { Utils } from 'utils';
Expand Down Expand Up @@ -43,7 +44,7 @@ const displayInfoLinks = (headerProfile: Profile) => {
);
};

export const HeaderProfile = (props: Props) => {
export const HeaderProfile = (props: Props): Node => {
const { profile } = props;
return (
<div className={css.headerProfile}>
Expand Down
4 changes: 2 additions & 2 deletions client/app/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type State = {

export const Header = ({
home, links, mobileOnly, profile,
}: Props) => {
}: Props): Node => {
const [mobileNavOpen, setMobileNavOpen] = useState(false);
const [toggled, setToggled] = useState(true);

Expand Down Expand Up @@ -108,6 +108,6 @@ export const Header = ({

export default ({
home, links, mobileOnly, profile,
}: Props) => (
}: Props): Node => (
<Header home={home} links={links} mobileOnly={mobileOnly} profile={profile} />
);
3 changes: 2 additions & 1 deletion client/app/components/Input/InputCheckbox.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import renderHTML from 'react-render-html';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
Expand Down Expand Up @@ -46,7 +47,7 @@ const displayCheckbox = (id, name, value, checked, onChange, label) => (
/>
);

export const InputCheckbox = (props: Props) => {
export const InputCheckbox = (props: Props): Node => {
const {
id,
name,
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputCheckboxGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import { InputCheckbox } from 'components/Input/InputCheckbox';
import type { Checkbox } from './utils';

Expand All @@ -13,7 +14,7 @@ export function InputCheckboxGroup({
hasError,
required,
checkboxes: defaultCheckboxes,
}: Props) {
}: Props): Node {
const [checkboxes, setCheckboxes] = useState<Checkbox[]>(defaultCheckboxes);

const handleOnChange = (checkbox: { checked: boolean, id: string }) => {
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import css from './Input.scss';

export const REQUIRES_DEFAULT = [
Expand Down Expand Up @@ -68,7 +69,7 @@ const onBlur = (
}
};

export const InputDefault = (props: Props) => {
export const InputDefault = (props: Props): Node => {
const {
id,
type,
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputError.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faExclamation } from '@fortawesome/free-solid-svg-icons';
import { I18n } from 'libs/i18n';
Expand All @@ -9,7 +10,7 @@ export type Props = {
error?: boolean,
};

export const InputError = (props: Props) => {
export const InputError = (props: Props): Node => {
const { error } = props;
if (!error) return null;
return (
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputLabel.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAsterisk, faQuestion } from '@fortawesome/free-solid-svg-icons';
import globalCss from 'styles/_global.scss';
Expand Down Expand Up @@ -37,7 +38,7 @@ const displayLabel = (label: string, error: ?boolean) => (
<div className={`${error ? css.error : ''} ${css.labelText}`}>{label}</div>
);

export const InputLabel = (props: Props) => {
export const InputLabel = (props: Props): Node => {
const {
error, label, required, info, htmlFor,
} = props;
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputLocation.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import LocationAutocomplete from 'location-autocomplete';
import css from './Input.scss';

Expand All @@ -17,7 +18,7 @@ export function InputLocation({
id,
name,
value: defaultAddress,
}: Props) {
}: Props): Node {
const [address, setAddress] = useState<string>(defaultAddress || '');

const handleChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputPassword.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons';
import { I18n } from 'libs/i18n';
Expand Down Expand Up @@ -43,7 +44,7 @@ export function InputPassword({
required,
label,
hasError,
}: Props) {
}: Props): Node {
const [showText, setShowText] = useState<boolean>(false);

const toggleShow = () => {
Expand Down
7 changes: 6 additions & 1 deletion client/app/components/Input/InputRadioGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import css from './InputRadioGroup.scss';
import type { Option } from './utils';

Expand All @@ -9,7 +10,11 @@ export type Props = {
value?: any,
};

export function InputRadioGroup({ name, options, value: propValue }: Props) {
export function InputRadioGroup({
name,
options,
value: propValue,
}: Props): Node {
return (
<div role="radiogroup" className={css.wrapper}>
{options.map((option: Option) => (
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputSelect.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { useState } from 'react';
import type { Node } from 'react';
import renderHTML from 'react-render-html';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCaretDown } from '@fortawesome/free-solid-svg-icons';
Expand All @@ -24,7 +25,7 @@ export function InputSelect({
label,
onChange,
value: propValue,
}: Props) {
}: Props): Node {
const [value, setValue] = useState<any>(propValue);

const toggleValue = (e: SyntheticEvent<HTMLInputElement>) => {
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/Input/InputSubmit.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import globalCss from 'styles/_global.scss';

export type Props = {
Expand Down Expand Up @@ -31,7 +32,7 @@ export const InputSubmit = ({
value,
disabled,
formNoValidate,
}: Props) => (
}: Props): Node => (
<input
id={id}
type="submit"
Expand Down
Loading

0 comments on commit b0f5a4d

Please sign in to comment.