Skip to content

Commit 1224d85

Browse files
Merge branch 'TCA-499_eslint' into TCA-560_line-breaks
2 parents eb50c51 + aed04fc commit 1224d85

File tree

124 files changed

+2838
-2882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2838
-2882
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ install_dependency: &install_dependency
2828
install_deploysuite: &install_deploysuite
2929
name: Installation of install_deploysuite.
3030
command: |
31-
git clone --branch v1.4.6 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
31+
git clone --branch v1.4.11 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
3232
cp ./../buildscript/master_deploy.sh .
3333
cp ./../buildscript/buildenv.sh .
3434
cp ./../buildscript/awsconfiguration.sh .

src-ts/.eslintrc.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = {
8383
],
8484
'complexity': [
8585
'error',
86-
7
86+
11
8787
],
8888
'import/extensions': 'off',
8989
'import/prefer-default-export': 'off',
@@ -101,8 +101,24 @@ module.exports = {
101101
'jsx-a11y/tabindex-no-positive': [
102102
'warn'
103103
],
104+
'newline-per-chained-call': [
105+
'error',
106+
{
107+
ignoreChainWithDepth: 1,
108+
}
109+
],
110+
'max-len': [
111+
'error',
112+
120,
113+
],
104114
'no-extra-boolean-cast': 'off',
105115
'no-null/no-null': 'error',
116+
'no-param-reassign': [
117+
'error',
118+
{
119+
props: false
120+
}
121+
],
106122
'no-plusplus': [
107123
'error',
108124
{

src-ts/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ declare module '*.md' {
2424
const value: string
2525
export default value
2626
}
27+
28+
declare module '*.txt' {
29+
const value: string
30+
export default value
31+
}

src-ts/header/utility-selectors/UtilitySelector/ProfileSelector/profile-not-logged-in/ProfileNotLoggedIn.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useContext } from 'react'
1+
import { FC, useCallback, useContext } from 'react'
22
import { Location, useLocation } from 'react-router-dom'
33

44
import {
@@ -14,10 +14,13 @@ const ProfileNotLoggedIn: FC<{}> = () => {
1414
const routeData: RouteContextData = useContext(routeContext)
1515
const location: Location = useLocation()
1616

17-
function signUp(): void {
17+
const signUpHandler: () => void = useCallback(() => {
1818
const signupUrl: string = routeData.getSignupUrl(location.pathname, routeData.toolsRoutes)
1919
window.location.href = signupUrl
20-
}
20+
}, [
21+
location.pathname,
22+
routeData,
23+
])
2124

2225
return (
2326
<>
@@ -34,7 +37,7 @@ const ProfileNotLoggedIn: FC<{}> = () => {
3437
label='Sign Up'
3538
size='md'
3639
tabIndex={-1}
37-
onClick={() => signUp()}
40+
onClick={signUpHandler}
3841
/>
3942
</>
4043
)

src-ts/lib/contact-support-form/ContactSupportForm.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, FC, SetStateAction, useContext, useEffect, useState } from 'react'
1+
import { Dispatch, FC, SetStateAction, useCallback, useContext, useEffect, useState } from 'react'
22

33
import { Form, FormDefinition, formGetInputModel, FormInputModel } from '../form'
44
import { LoadingSpinner } from '../loading-spinner'
@@ -19,20 +19,28 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
1919

2020
const { profile }: ProfileContextData = useContext(profileContext)
2121

22-
const [loading, setLoading]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
23-
const [saveOnSuccess, setSaveOnSuccess]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
22+
const [loading, setLoading]: [boolean, Dispatch<SetStateAction<boolean>>]
23+
= useState<boolean>(false)
24+
const [saveOnSuccess, setSaveOnSuccess]: [boolean, Dispatch<SetStateAction<boolean>>]
25+
= useState<boolean>(false)
2426

2527
useEffect(() => {
2628
if (!loading && saveOnSuccess) {
2729
props.onSave()
2830
}
29-
}, [loading, saveOnSuccess])
31+
}, [loading, saveOnSuccess, props.onSave])
3032

31-
function generateRequest(inputs: ReadonlyArray<FormInputModel>): ContactSupportRequest {
32-
const firstName: string = formGetInputModel(inputs, ContactSupportFormField.first).value as string
33-
const lastName: string = formGetInputModel(inputs, ContactSupportFormField.last).value as string
34-
const email: string = formGetInputModel(inputs, ContactSupportFormField.email).value as string
35-
const question: string = formGetInputModel(inputs, ContactSupportFormField.question).value as string
33+
const generateRequest = useCallback((
34+
inputs: ReadonlyArray<FormInputModel>,
35+
): ContactSupportRequest => {
36+
const firstName: string
37+
= formGetInputModel(inputs, ContactSupportFormField.first).value as string
38+
const lastName: string
39+
= formGetInputModel(inputs, ContactSupportFormField.last).value as string
40+
const email: string
41+
= formGetInputModel(inputs, ContactSupportFormField.email).value as string
42+
const question: string
43+
= formGetInputModel(inputs, ContactSupportFormField.question).value as string
3644
return {
3745
challengeId: props.workId,
3846
email,
@@ -41,15 +49,16 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
4149
lastName,
4250
question,
4351
}
44-
}
52+
}, [props.workId])
4553

46-
async function saveAsync(request: ContactSupportRequest): Promise<void> {
54+
const saveAsync = useCallback(async (request: ContactSupportRequest): Promise<void> => {
4755
setLoading(true)
4856
return contactSupportSubmitRequestAsync(request)
4957
.then(() => {
5058
setSaveOnSuccess(true)
51-
}).finally(() => setLoading(false))
52-
}
59+
})
60+
.finally(() => setLoading(false))
61+
}, [])
5362

5463
const emailElement: JSX.Element | undefined = !!profile?.email
5564
? (
@@ -69,10 +78,10 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
6978
Hi
7079
{' '}
7180
{profile?.firstName || 'there'}
72-
, we're here to help.
81+
, we&apos;re here to help.
7382
</p>
7483
<p>
75-
Please describe what you'd like to discuss, and a
84+
Please describe what you&apos;d like to discuss, and a
7685
Topcoder Solutions Expert will email you back
7786
{emailElement}
7887
&nbsp;within one business day.

src-ts/lib/form/form-groups/form-card-set/FormCardSet.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const FormCardSet: React.FC<FormCardSetProps> = (props: FormCardSetProps) => {
2727
return <></>
2828
}
2929

30-
const iconName: string = `${icon.split('-').map((chunk: string) => chunk.charAt(0).toUpperCase() + chunk.slice(1)).join('')}Icon`
30+
const iconName: string = `${icon.split('-')
31+
.map((chunk: string) => chunk.charAt(0)
32+
.toUpperCase() + chunk.slice(1))
33+
.join('')}Icon`
3134
const IconComponent: React.FC<SVGProps<SVGSVGElement>> = IconOutline[iconName as keyof typeof IconOutline]
3235
return <IconComponent className={styles['card-row-icon']} />
3336
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export {
22
dateLocaleShortString as textFormatDateLocaleShortString,
3+
getSafeString as textFormatGetSafeString,
34
moneyLocaleString as textFormatMoneyLocaleString,
45
} from './text-format.functions'

src-ts/lib/functions/text-format-functions/text-format.functions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export function dateLocaleShortString(date?: Date): string | undefined {
99
)
1010
}
1111

12+
export function getSafeString(param?: string): string {
13+
return param ?? ''
14+
}
15+
1216
export function moneyLocaleString(amount?: number): string | undefined {
1317
return amount?.toLocaleString('en-US', {
1418
currency: 'USD', // TODO: handle other currencies

src-ts/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export {
1919
logInfo,
2020
logInitialize,
2121
textFormatDateLocaleShortString,
22+
textFormatGetSafeString,
2223
textFormatMoneyLocaleString,
2324
xhrCreateInstance,
2425
xhrDeleteAsync,

src-ts/lib/modals/base-modal/BaseModal.module.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
@import '../../styles/includes';
22
@import '../../styles/typography';
33

4+
:global(.react-responsive-modal-root) {
5+
:global(.react-responsive-modal-overlay),
6+
:global(.react-responsive-modal-modal) {
7+
animation-fill-mode:forwards !important;
8+
}
9+
10+
}
11+
412
.modal-header {
513
padding: 5px 0 0;
614
}
@@ -14,7 +22,7 @@
1422
overflow: auto;
1523
margin: 0 -1*$space-xxxxl -1*$space-xxxxl;
1624
padding: 0 $space-xxxxl $space-xxxxl;
17-
25+
1826
display: flex;
1927
flex-direction: column;
2028

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,59 @@
1-
import { FC } from 'react'
1+
import { FC, ReactNode } from 'react'
22
import Modal, { ModalProps } from 'react-responsive-modal'
33
import classNames from 'classnames'
44

5+
import { LoadingSpinner } from '../../loading-spinner'
56
import { IconOutline } from '../../svgs'
67

8+
import { ModalContentResponse, useFetchModalContent } from './use-fetch-modal-content'
79
import styles from './BaseModal.module.scss'
810

911
export interface BaseModalProps extends ModalProps {
12+
contentClassName?: string
13+
contentUrl?: string
1014
size?: 'lg' | 'md'
1115
title: string
1216
}
1317

14-
const BaseModal: FC<BaseModalProps> = ({
15-
children,
16-
title,
17-
...props
18-
}: BaseModalProps) => (
19-
<Modal
20-
{...props}
21-
classNames={{ modal: `modal-${props.size || 'md'}` }}
22-
closeIcon={<IconOutline.XIcon width={28} height={28} />}
23-
>
24-
<div className={styles['modal-header']}>
25-
<h3>{title}</h3>
26-
</div>
27-
28-
<hr className={styles.spacer} />
29-
30-
<div className={classNames(styles['modal-body'], 'modal-body')}>
31-
{children}
32-
</div>
33-
</Modal>
34-
)
18+
const BaseModal: FC<BaseModalProps> = (props: BaseModalProps) => {
19+
20+
const { content }: ModalContentResponse = useFetchModalContent(props.contentUrl, props.open)
21+
22+
const renterContent: () => ReactNode = () => {
23+
if (props.children || !props.contentUrl) {
24+
return undefined
25+
}
26+
27+
if (!content) {
28+
return <LoadingSpinner />
29+
}
30+
31+
return (
32+
<div
33+
className={props.contentClassName}
34+
dangerouslySetInnerHTML={{ __html: content }}
35+
/>
36+
)
37+
}
38+
39+
return (
40+
<Modal
41+
{...props}
42+
classNames={{ modal: `modal-${props.size || 'md'}` }}
43+
closeIcon={<IconOutline.XIcon width={28} height={28} />}
44+
>
45+
<div className={styles['modal-header']}>
46+
<h3>{props.title}</h3>
47+
</div>
48+
49+
<hr className={styles.spacer} />
50+
51+
<div className={classNames(styles['modal-body'], 'modal-body')}>
52+
{renterContent()}
53+
{props.children}
54+
</div>
55+
</Modal>
56+
)
57+
}
3558

3659
export default BaseModal
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
2+
3+
import { xhrGetAsync } from '../../functions'
4+
5+
export interface ModalContentResponse {
6+
content: string | undefined
7+
}
8+
9+
export function useFetchModalContent(contentUrl?: string, enabled?: boolean): ModalContentResponse {
10+
const [content, setContent]: [string|undefined, Dispatch<SetStateAction<string|undefined>>] = useState()
11+
12+
useEffect(() => {
13+
if (!contentUrl || !enabled) {
14+
return
15+
}
16+
17+
if (!content) {
18+
xhrGetAsync<string>(contentUrl)
19+
.then(setContent)
20+
}
21+
}, [contentUrl, content, enabled])
22+
23+
return { content }
24+
}

src-ts/lib/modals/order-contract-modal/OrderContractModal.module.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
p {
1414
margin-bottom: 20px;
1515

16-
&.sm {
16+
&:global(.sm) {
1717
font-size: 14px;
1818
}
1919
}
2020
}
21-
22-
.topCoderLink {
23-
text-decoration: underline;
24-
color: $link-blue-light;
25-
}

0 commit comments

Comments
 (0)