Skip to content

Commit 46a6b44

Browse files
Merge pull request #411 from topcoder-platform/TCA-499_break-chain
TCA-499 eslint Add Line Breaks Before Chained Methods -> TCA-499_eslint
2 parents 58c027d + 7d9ef5e commit 46a6b44

File tree

30 files changed

+171
-109
lines changed

30 files changed

+171
-109
lines changed

src-ts/.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ 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,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
5656
return contactSupportSubmitRequestAsync(request)
5757
.then(() => {
5858
setSaveOnSuccess(true)
59-
}).finally(() => setLoading(false))
59+
})
60+
.finally(() => setLoading(false))
6061
}, [])
6162

6263
const emailElement: JSX.Element | undefined = !!profile?.email

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/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

src-ts/tools/learn/learn-lib/data-providers/all-certifications-provider/all-certifications.provider.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable default-param-last */
12
import useSWR, { SWRConfiguration, SWRResponse } from 'swr'
23

34
import { learnUrlGet } from '../../functions'
@@ -11,16 +12,16 @@ interface CertificationsAllProviderOptions {
1112

1213
export function useGetAllCertifications(
1314
providerName: string = 'freeCodeCamp',
14-
options?: CertificationsAllProviderOptions
15+
options?: CertificationsAllProviderOptions,
1516
): AllCertificationsProviderData {
1617

1718
const url: string = learnUrlGet(
1819
'certifications',
19-
`?providerName=${providerName}`
20+
`?providerName=${providerName}`,
2021
)
2122
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
2223

23-
const {data, error}: SWRResponse = useSWR(url, {
24+
const { data, error }: SWRResponse = useSWR(url, {
2425
...swrCacheConfig,
2526
isPaused: () => options?.enabled === false,
2627
})
@@ -36,16 +37,16 @@ export function useGetAllCertifications(
3637
export function useGetCertification(
3738
providerName: string = 'freeCodeCamp',
3839
certificationId: string,
39-
options?: CertificationsAllProviderOptions
40+
options?: CertificationsAllProviderOptions,
4041
): AllCertificationsProviderData {
4142

4243
const url: string = learnUrlGet(
4344
'certifications',
4445
certificationId,
45-
`?providerName=${providerName}`
46+
`?providerName=${providerName}`,
4647
)
4748

48-
const {data, error}: SWRResponse = useSWR(url, {
49+
const { data, error }: SWRResponse = useSWR(url, {
4950
isPaused: () => options?.enabled === false,
5051
})
5152
return {

src-ts/tools/learn/learn-lib/data-providers/courses-provider/courses.provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LearnCourse } from './learn-course.model'
99

1010
export function useGetCourses(
1111
provider: string,
12-
certification?: string
12+
certification?: string,
1313
): CoursesProviderData {
1414

1515
const params: string = [
@@ -22,7 +22,7 @@ export function useGetCourses(
2222
const url: string = learnUrlGet('courses', `?${params}`)
2323
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
2424

25-
const {data, error}: SWRResponse<ReadonlyArray<LearnCourse>> = useSWR(url, swrCacheConfig)
25+
const { data, error }: SWRResponse<ReadonlyArray<LearnCourse>> = useSWR(url, swrCacheConfig)
2626

2727
return {
2828
course: get(data, [0]),

src-ts/tools/learn/learn-lib/data-providers/lesson-provider/lesson.provider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export function useGetLesson(
2121
courseData?.key ?? course,
2222
module,
2323
lesson,
24-
].filter(Boolean).join('/')
24+
]
25+
.filter(Boolean)
26+
.join('/')
2527

2628
return {
2729
lesson: !lessonData ? undefined : {

src-ts/tools/learn/learn-lib/data-providers/resource-provider-provider/resource-provider.provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export function useGetResourceProvider(providerName?: string): ResourceProviderD
1212
const url: string = learnUrlGet('providers')
1313
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
1414

15-
const {data, error}: SWRResponse<ReadonlyArray<ResourceProvider>> = useSWR(url, swrCacheConfig)
15+
const { data, error }: SWRResponse<ReadonlyArray<ResourceProvider>> = useSWR(url, swrCacheConfig)
1616

1717
return {
1818
loading: !data && !error,
19-
provider: find(data, {name: providerName}),
19+
provider: find(data, { name: providerName }),
2020
ready: !!data || !!error,
2121
}
2222
}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certification-progress.provider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LearnUserCertificationProgress } from './user-certifications-functions'
99
export function useGetUserCertificationProgress(
1010
userId?: number,
1111
provider?: string,
12-
certification?: string
12+
certification?: string,
1313
):
1414
UserCertificationProgressProviderData {
1515

@@ -28,10 +28,10 @@ export function useGetUserCertificationProgress(
2828
})
2929

3030
return {
31-
certificationProgress: find(data, {certification}),
31+
certificationProgress: find(data, { certification }),
3232
loading: !!userId && !data && !error,
3333
ready: !userId || data || error,
3434
refetch: () => mutate(),
35-
setCertificateProgress: (progress) => mutate([progress]),
35+
setCertificateProgress: progress => mutate([progress]),
3636
}
3737
}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certifications.provider.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,25 @@ export function useGetUserCertifications(
2929
})
3030
const loading: boolean = !data && !error
3131

32-
const completed: ReadonlyArray<UserCertificationCompleted> = useMemo(() => data
33-
?.filter(c => c.status === UserCertificationProgressStatus.completed)
34-
.map(c => c as UserCertificationCompleted)
35-
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) ?? []
36-
, [data])
37-
38-
const inProgress: ReadonlyArray<UserCertificationInProgress> = useMemo(() => data
39-
?.filter(c => c.status === UserCertificationProgressStatus.inProgress)
40-
.map(c => c as UserCertificationInProgress)
41-
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) ?? []
42-
, [data])
32+
const completed: ReadonlyArray<UserCertificationCompleted> = useMemo(
33+
() => data
34+
?.filter(c => c.status === UserCertificationProgressStatus.completed)
35+
.map(c => c as UserCertificationCompleted)
36+
.sort((a, b) => new Date(b.updatedAt)
37+
.getTime() - new Date(a.updatedAt)
38+
.getTime()) ?? [],
39+
[data],
40+
)
41+
42+
const inProgress: ReadonlyArray<UserCertificationInProgress> = useMemo(
43+
() => data
44+
?.filter(c => c.status === UserCertificationProgressStatus.inProgress)
45+
.map(c => c as UserCertificationInProgress)
46+
.sort((a, b) => new Date(b.updatedAt)
47+
.getTime() - new Date(a.updatedAt)
48+
.getTime()) ?? [],
49+
[data],
50+
)
4351

4452
if (error) {
4553
errorHandle(error, 'There was an error getting your course progress.')

src-ts/tools/learn/learn-lib/data-providers/user-completed-certifications-provider/user-completed-certifications.provider.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import { UserCompletedCertificationsProviderData } from './user-completed-certif
88
export function useGetUserCompletedCertifications(
99
userId?: number,
1010
provider?: string,
11-
certification?: string
11+
certification?: string,
1212
): UserCompletedCertificationsProviderData {
1313

1414
const url: string = learnUrlGet('completed-certifications', `${userId}`)
1515

16-
const {data, error}: SWRResponse<ReadonlyArray<LearnUserCompletedCertification>> = useSWR(url)
16+
const { data, error }: SWRResponse<ReadonlyArray<LearnUserCompletedCertification>> = useSWR(url)
1717

1818
let certifications: ReadonlyArray<LearnUserCompletedCertification> = data ?? []
1919

2020
if (provider || certification) {
21-
certifications = certifications.filter((c) => {
22-
return (!provider || c.provider === provider) &&
23-
(!certification || c.certification === certification)
24-
})
21+
certifications = certifications
22+
.filter(c => (!provider || c.provider === provider)
23+
&& (!certification || c.certification === certification))
2524
}
2625

2726
return {

0 commit comments

Comments
 (0)