Skip to content

Commit aed04fc

Browse files
Merge pull request #410 from topcoder-platform/TCA-499_eslint_fix-linting
Tca 499 eslint fix linting
2 parents c845574 + afc6010 commit aed04fc

File tree

48 files changed

+430
-272
lines changed

Some content is hidden

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

48 files changed

+430
-272
lines changed

src-ts/.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,24 @@ module.exports = {
8383
'jsx-a11y/tabindex-no-positive': [
8484
'warn'
8585
],
86+
'newline-per-chained-call': [
87+
'error',
88+
{
89+
ignoreChainWithDepth: 1,
90+
}
91+
],
8692
'max-len': [
8793
'error',
8894
120,
8995
],
9096
'no-extra-boolean-cast': 'off',
9197
'no-null/no-null': 'error',
98+
'no-param-reassign': [
99+
'error',
100+
{
101+
props: false
102+
}
103+
],
92104
'no-plusplus': [
93105
'error',
94106
{

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
}

src-ts/lib/modals/base-modal/use-fetch-modal-content.tsx

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

33
import { xhrGetAsync } from '../../functions'
44

@@ -15,7 +15,8 @@ export function useFetchModalContent(contentUrl?: string, enabled?: boolean): Mo
1515
}
1616

1717
if (!content) {
18-
xhrGetAsync<string>(contentUrl).then(setContent)
18+
xhrGetAsync<string>(contentUrl)
19+
.then(setContent)
1920
}
2021
}, [contentUrl, content, enabled])
2122

src-ts/lib/page-footer/PageFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const PageFooter: FC<{}> = () => {
4848
<div>
4949
<span>
5050
©
51-
{(new Date()).getFullYear()}
51+
{(new Date())
52+
.getFullYear()}
5253
{' '}
5354
Topcoder
5455
</span>

src-ts/lib/route-provider/router.utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export type LazyLoadType = (
1414
* (while react's `lazy` method only allows to import default exports)
1515
*/
1616
export const lazyLoad: LazyLoadType = (moduleImport: () => Promise<any>, namedExport: string = 'default') => (
17-
lazy(() => moduleImport().then(m => ({ default: get(m, namedExport) })))
17+
lazy(() => moduleImport()
18+
.then(m => ({ default: get(m, namedExport) })))
1819
)

src-ts/tools/dev-center/dev-center-lib/MarkdownDoc/markdownRenderer/renderer.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@ export class Renderer implements MarkdownRenderer {
8080
const children: ReturnType<typeof this.groupBy> = this.groupBy(
8181
nodes,
8282
options,
83-
).map(node => {
84-
if (Array.isArray(node)) {
85-
return (
86-
<MarkdownAccordion>
87-
{React.Children.map(node, child => child)}
88-
</MarkdownAccordion>
89-
)
90-
}
83+
)
84+
.map(node => {
85+
if (Array.isArray(node)) {
86+
return (
87+
<MarkdownAccordion>
88+
{React.Children.map(node, child => child)}
89+
</MarkdownAccordion>
90+
)
91+
}
9192

92-
return node
93-
})
93+
return node
94+
})
9495

9596
return (
9697
<div className={styles['markdown-doc']}>
@@ -287,7 +288,8 @@ export class Renderer implements MarkdownRenderer {
287288
const h: string = marked.parser([token], parserOptions)
288289
const level: number = token.depth
289290
const title: string = removeLineBreak(stripTag(h, `h${level}`))
290-
const headingId: string = extractId(h, `h${level}`, index).trim()
291+
const headingId: string = extractId(h, `h${level}`, index)
292+
.trim()
291293

292294
options.toc.push({
293295
headingId,
@@ -351,12 +353,14 @@ export class Renderer implements MarkdownRenderer {
351353
const tag: string = extractTag(html)
352354
if (tag) {
353355
const isParagraphTag: boolean = tag === MarkdownParagraphTag.p
354-
const isHeaderTag: boolean = Object.values(MarkdownHeaderTag).indexOf(tag as MarkdownHeaderTag) !== -1
356+
const isHeaderTag: boolean = Object.values(MarkdownHeaderTag)
357+
.indexOf(tag as MarkdownHeaderTag) !== -1
355358
if (isParagraphTag || isHeaderTag) {
356359
let id: string | undefined
357360
if (isHeaderTag) {
358361
token = token as marked.Tokens.Heading
359-
id = extractId(html, `h${token.depth}`, index).trim()
362+
id = extractId(html, `h${token.depth}`, index)
363+
.trim()
360364
}
361365

362366
return React.createElement(tag, {

src-ts/tools/dev-center/dev-center-lib/MarkdownDoc/markdownRenderer/util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export function renderMarkdown(
3030
const matchStr: string = matches ? matches[0] : ''
3131
return matchStr
3232
? {
33-
s: fromStr.replace(matchStr, '').trimStart(),
34-
title: matchStr.replace(/^#/, '').replace(/`/g, '').trim(),
33+
s: fromStr.replace(matchStr, '')
34+
.trimStart(),
35+
title: matchStr.replace(/^#/, '')
36+
.replace(/`/g, '')
37+
.trim(),
3538
}
3639
: { title, s }
3740
}

src-ts/tools/dev-center/dev-center-pages/community-app/landing-page/dev-center-articles-section/CardSection/CardSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const CardSection: FC = () => {
3333
return blog
3434
}
3535
}),
36-
).then(arr => setArticles(arr))
36+
)
37+
.then(arr => setArticles(arr))
3738
}, [])
3839

3940
const articleStyles: Array<any> = [

src-ts/tools/gamification-admin/pages/badge-detail/AwardedMembersTab/awarded-members-table/member-awardedAt-renderer/MemberAwaredAtRenderer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const MemberAwaredAtRenderer = (memberAward: MemberBadgeAward): JSX.Element => {
1212
}
1313

1414
return (
15-
<div className={styles.memberAwardedAt}>{new Date(memberAward.awarded_at).toLocaleString(undefined, dateFormat)}</div>
15+
<div className={styles.memberAwardedAt}>
16+
{new Date(memberAward.awarded_at)
17+
.toLocaleString(undefined, dateFormat)}
18+
</div>
1619
)
1720
}
1821

src-ts/tools/gamification-admin/pages/badge-detail/badge-details.functions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export async function submitRequestAsync(request: UpdateBadgeRequest): Promise<G
1313
export function generateCSV(input: Array<Array<string | number>>): string {
1414
input.unshift(GamificationConfig.CSV_HEADER)
1515

16-
return input.map(row => row.join(',')).join('\n')
16+
return input.map(row => row.join(','))
17+
.join('\n')
1718
}
1819

1920
export async function manualAssignRequestAsync(csv: string): Promise<any> {

src-ts/tools/learn/course-certificate/certificate-view/CertificateView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps)
4646
const certificateWrapRef: MutableRefObject<HTMLDivElement | any> = useRef()
4747

4848
const userName: string = useMemo(() => (
49-
[props.profile.firstName, props.profile.lastName].filter(Boolean).join(' ')
49+
[props.profile.firstName, props.profile.lastName].filter(Boolean)
50+
.join(' ')
5051
|| props.profile.handle
5152
), [props.profile.firstName, props.profile.handle, props.profile.lastName])
5253

src-ts/tools/learn/course-certificate/certificate-view/certificate/course-card/CourseCard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ const CourseCard: FC<CourseCardProps> = (props: CourseCardProps) => (
2626
<IconOutline.CalendarIcon />
2727
<span className='large-subtitle'>
2828
<span>Completed</span>
29-
<span>{props.completedDate && textFormatDateLocaleShortString(new Date(props.completedDate))}</span>
29+
<span>
30+
{
31+
props.completedDate && (
32+
textFormatDateLocaleShortString(new Date(props.completedDate))
33+
)
34+
}
35+
</span>
3036
</span>
3137
</div>
3238
</div>

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ const FreeCodeCamp: FC<{}> = () => {
157157

158158
function handleFccLessonReady(lessonPath: string): void {
159159

160-
const [nLessonPath, modulePath, coursePath]: Array<string> = lessonPath.replace(/\/$/, '').split('/').reverse()
160+
const [nLessonPath, modulePath, coursePath]: Array<string> = lessonPath.replace(/\/$/, '')
161+
.split('/')
162+
.reverse()
161163
updatePath(nLessonPath, modulePath, coursePath)
162164

163165
const currentLesson: { [key: string]: string } = {
@@ -206,7 +208,8 @@ const FreeCodeCamp: FC<{}> = () => {
206208
certificateProgress.id,
207209
UserCertificationUpdateProgressActions.completeLesson,
208210
currentLesson,
209-
).then(setCertificateProgress)
211+
)
212+
.then(setCertificateProgress)
210213
}
211214
}
212215

0 commit comments

Comments
 (0)