Skip to content

Commit 8da0c84

Browse files
TCA-647 #comment This commit updates rules so that we can remove tslint #time 30m
1 parent 46e431a commit 8da0c84

File tree

22 files changed

+53
-101
lines changed

22 files changed

+53
-101
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ save_cache_settings: &save_cache_settings
4141
paths:
4242
- node_modules
4343

44-
running_yarn_tslint: &running_yarn_tslint
45-
name: Running Yarn tslint
44+
running_yarn_eslint: &running_yarn_eslint
45+
name: Running Yarn eslint
4646
command: |
47-
yarn add tslint -g
47+
yarn add eslint -g
4848
yarn lint
4949
5050
running_yarn_build: &running_yarn_build
@@ -81,7 +81,7 @@ lint_steps: &lint_steps
8181
# Initialization.
8282
- checkout
8383
- setup_remote_docker
84-
- run: *running_yarn_tslint
84+
- run: *running_yarn_eslint
8585

8686
build_steps: &build_steps
8787
# Initialization.
@@ -239,4 +239,4 @@ workflows:
239239
- master
240240

241241
- test-dev:
242-
context : org-global
242+
context : org-global

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ Each [Tool](#tools) can have its own setup requirements. Please see each tool's
190190
| `yarn start:<dev>` | Serve dev mode build with dev's personal config |
191191
| `yarn build` | Build dev mode build with the default config and outputs static files in /builds |
192192
| `yarn build:prod` | Build prod mode build with the prod config and outputs static files in /builds |
193-
| `yarn lint` | Run tslint against ts/x files and outputs report |
194-
| `yarn lint:fix` | Run tslint against ts/x files, fixes auto-fixable issues, and outputs report |
195-
| `yarn eslint` | Run eslint against js/x files and outputs report |
196-
| `yarn eslint:fix` | Run eslint against js/x files, fixes auto-fixable issues, and outputs report |
193+
| `yarn lint:ts` | Run eslint against ts/x files and outputs report |
194+
| `yarn lint:ts:fix` | Run eslint against ts/x files, fixes auto-fixable issues, and outputs report |
195+
| `yarn lint:js` | Run eslint against js/x files and outputs report |
196+
| `yarn lint:js:fix` | Run eslint against js/x files, fixes auto-fixable issues, and outputs report |
197+
| `yarn lint` | Run eslint against js/x and ts/x files and outputs report |
198+
| `yarn lint:fix` | Run eslint against js/x and ts/x files, fixes auto-fixable issues, and outputs report |
197199
| `yarn test` | Run unit tests, watching for changes and re-running per your specifications |
198200
| `yarn test:no-watch` | Run unit tests once, without watching for changes or re-running |
199201
| `yarn cy:run` | Run e2e tests once in local command with the site is running |
@@ -370,11 +372,11 @@ The PlatformRoute model has several useful options:
370372
## Linting
371373

372374
### Rules
373-
While [TSLint](https://palantir.github.io/tslint/) is technically deprecated in favor of [Typescript ESLint](https://typescript-eslint.io/), TSLint is still far better at linting Typescript files than ESLint. So, for the time being, TSLint will be the primary linter, but ESLint remains configured for JS/X files.
374375

375-
The following command will install TSLint globally:
376+
Javascript rules: [src/.eslintrc.js](src/.eslintrc.js)
377+
378+
Typescript rules: [src-ts/.eslintrc.js](src-ts/.eslintrc.js)
376379

377-
>% yarn global add tslint typescript
378380

379381
### Command Line
380382

@@ -386,9 +388,7 @@ The following command will install TSLint globally:
386388

387389
>% yarn lint:fix
388390
389-
OR
390-
391-
>% yarn eslint:fix
391+
See the [yarn commmands](#yarn-commands) for further options.
392392

393393
### VS Code
394394

@@ -411,16 +411,16 @@ The most useful feature is to automatically apply all lint rules any time you sa
411411
...
412412
"editor.formatOnSave": true,
413413
"editor.codeActionsOnSave": {
414-
"source.fixAll.tslint": true,
414+
"source.fixAll.eslint": true,
415415
},
416416
}
417417
```
418418
419-
#### TSLint Plugin
419+
#### ESLint Plugin
420420
421421
Created by Microsoft, this plugin will allow you to see lint errors in the Problems panel.
422422
423-
>**WARNING:** Other lint plugins can interfere with TSLint, so it is recommended that you uninstall/disable all other lint plugins (e.g. ESLint, Prettier, etc).
423+
>**WARNING:** Other lint plugins can interfere with ESLint, so it is recommended that you uninstall/disable all other lint plugins (e.g. TSLint, Prettier, etc).
424424
425425
## Styling
426426

cypress.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable-next-line: no-submodule-imports This is the way cypress does it
21
import task from '@cypress/code-coverage/task'
32
import { defineConfig } from 'cypress'
43

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"eslint-plugin-cypress": "^2.12.1",
124124
"eslint-plugin-import": "^2.25.3",
125125
"eslint-plugin-jsx-a11y": "^6.5.1",
126+
"eslint-plugin-no-null": "^1.0.2",
126127
"eslint-plugin-ordered-imports": "^0.6.0",
127128
"eslint-plugin-react": "^7.28.0",
128129
"eslint-plugin-react-hooks": "^4.3.0",
@@ -143,7 +144,6 @@
143144
"start-server-and-test": "^1.14.0",
144145
"style-loader": "^3.3.1",
145146
"systemjs-webpack-interop": "^2.3.7",
146-
"tslint": "^6.1.3",
147147
"webpack": "^4.41.2",
148148
"webpack-cli": "^4.10.0",
149149
"webpack-config-single-spa-react": "^4.0.3",

src-ts/.eslintrc.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ module.exports = {
2020
sourceType: 'module',
2121
},
2222
plugins: [
23-
'react',
2423
'@typescript-eslint',
24+
'no-null',
2525
'ordered-imports',
26-
'react-hooks',
26+
'react',
27+
'react-hooks'
2728
],
2829
settings: {
2930
react: {
@@ -47,6 +48,7 @@ module.exports = {
4748
'@typescript-eslint/no-explicit-any': 'error',
4849
'@typescript-eslint/no-inferrable-types': 'off',
4950
'@typescript-eslint/no-shadow': 'error',
51+
'@typescript-eslint/no-unused-vars': 'error',
5052
'@typescript-eslint/strict-boolean-expressions': [
5153
'error',
5254
{
@@ -60,6 +62,10 @@ module.exports = {
6062
"error",
6163
"as-needed"
6264
],
65+
'complexity': [
66+
'error',
67+
7
68+
],
6369
'import/extensions': 'off',
6470
'import/prefer-default-export': 'off',
6571
'indent': [
@@ -77,6 +83,7 @@ module.exports = {
7783
'warn'
7884
],
7985
'no-extra-boolean-cast': "off",
86+
"no-null/no-null": "error",
8087
'no-plusplus': [
8188
'error',
8289
{
@@ -197,5 +204,6 @@ module.exports = {
197204
'error',
198205
'never',
199206
],
207+
'sort-keys': 'error'
200208
},
201209
};

src-ts/lib/button/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
export { default as Button } from './Button'
22
export { type ButtonProps } from './Button'
3-
export
4-
// tslint:disable-next-line: no-unused-expression
5-
type { ButtonSize } from './Button'
6-
export
7-
// tslint:disable-next-line: no-unused-expression
8-
type { ButtonStyle } from './Button'
9-
export
10-
// tslint:disable-next-line: no-unused-expression
11-
type { ButtonType } from './Button'
3+
export { type ButtonSize } from './Button'
4+
export { type ButtonStyle } from './Button'
5+
export { type ButtonType } from './Button'

src-ts/lib/form/form-groups/FormGroups.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const FormGroups: (props: FormGroupsProps) => JSX.Element = (props: FormGroupsPr
3535

3636
let inputElement: JSX.Element
3737

38-
/* tslint:disable:cyclomatic-complexity */
3938
switch (input.type) {
4039

4140
case 'rating':

src-ts/lib/form/form-groups/form-input/input-file-picker/InputFilePicker.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable:no-null-keyword
21
import { createRef, Dispatch, FC, RefObject, SetStateAction, useEffect, useState } from 'react'
32

43
import { Button, useCheckIsMobile } from '../../../..'
@@ -22,8 +21,10 @@ const InputFilePicker: FC<InputFilePickerProps> = (props: InputFilePickerProps)
2221

2322
const fileInputRef: RefObject<HTMLInputElement> = createRef<HTMLInputElement>()
2423

24+
// eslint-disable-next-line no-null/no-null
2525
const [files, setFiles]: [FileList | null, Dispatch<SetStateAction<FileList | null>>] = useState<FileList | null>(null)
26-
const [fileName, setFileName]: [string | undefined, Dispatch<SetStateAction<string | undefined>>] = useState<string | undefined>()
26+
const [fileName, setFileName]: [string | undefined, Dispatch<SetStateAction<string | undefined>>]
27+
= useState<string | undefined>()
2728

2829
useEffect(() => {
2930
if (files && files.length) {

src-ts/lib/form/form-groups/form-input/input-image-picker/InputImagePicker.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const InputImagePicker: FC<InputImagePickerProps> = (props: InputImagePickerProp
1919

2020
const fileInputRef: RefObject<HTMLInputElement> = createRef<HTMLInputElement>()
2121

22-
// tslint:disable-next-line:no-null-keyword
2322
const [files, setFiles]: [FileList | null, Dispatch<SetStateAction<FileList | null>>] = useState<FileList | null>(null)
2423
const [fileDataURL, setFileDataURL]: [string | undefined, Dispatch<SetStateAction<string | undefined>>] = useState<string | undefined>()
2524

src-ts/lib/form/validator-functions/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ export {
77
requiredIfOther as validatorRequiredIfOther,
88
sslUrl as validatorSslUrl,
99
} from './validator.functions'
10-
export
11-
// tslint:disable-next-line: no-unused-expression
12-
type { ValidatorFn } from './validator.functions'
10+
export { type ValidatorFn } from './validator.functions'
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
export { patchAsync as userPatchAsync } from './user-xhr.store'
2-
export
3-
// tslint:disable-next-line: no-unused-expression
4-
type { UserPatchRequest } from './user-xhr.store'
2+
export { type UserPatchRequest } from './user-xhr.store'

src-ts/lib/hooks/use-storage.hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function useStorage<T>(
4444
})
4545
} catch (error) {
4646
// A more advanced implementation would handle the error case
47-
// tslint:disable-next-line:no-console
47+
// eslint-disable-next-line no-console
4848
console.error(error)
4949
}
5050
}, [storage, storageKey]) as Dispatch<SetStateAction<T>>

src-ts/lib/member-autocomplete/InputHandleAutocomplete.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { FC, FocusEvent } from 'react'
22
import { MultiValue, StylesConfig } from 'react-select'
3-
// tslint:disable-next-line: no-submodule-imports
43
import AsyncSelect from 'react-select/async'
54

65
import { InputWrapper } from '../form/form-groups/form-input/input-wrapper'

src-ts/lib/pagination/use-infinite-page.hook.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { flatten, map } from 'lodash'
2-
// tslint:disable-next-line: no-submodule-imports
32
import useSWRInfinite, { SWRInfiniteResponse } from 'swr/infinite'
43

54
import { InfinitePageDao } from './infinite-page-dao.model'

src-ts/tools/dev-center/dev-center-lib/MarkdownDoc/MarkdownCode.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const MarkdownCode: React.FC<MarkdownCodeProps> = props => {
1818
boolean,
1919
React.Dispatch<React.SetStateAction<boolean>>
2020
] = React.useState(!isTerminal)
21-
// tslint:disable-next-line no-null-keyword
2221
const ref: React.RefObject<HTMLDivElement> = React.useRef<HTMLDivElement>(null)
2322

2423
const handleLineNumberVisibilityChange: (visibility: boolean) => void
@@ -113,7 +112,6 @@ const LineNumbers = (props: LineNumbersProps): React.ReactElement | null => {
113112
}, [size.width, onVisibilityChange, codeRef])
114113

115114
if (!showLineNumbers) {
116-
// tslint:disable-next-line no-null-keyword
117115
return null
118116
}
119117

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable-next-line: no-submodule-imports
21
import * as React from 'react'
32
import { marked, Renderer as MarkedRenderer } from 'marked'
43
import _ from 'lodash'
@@ -100,8 +99,6 @@ export class Renderer implements MarkdownRenderer {
10099
)
101100
}
102101

103-
// Hard to avoid due to the complexity of group by
104-
// tslint:disable-next-line: cyclomatic-complexity
105102
private groupBy(
106103
nodes: Array<React.ReactNode>,
107104
options?: MarkdownRenderOptions,
@@ -167,8 +164,6 @@ export class Renderer implements MarkdownRenderer {
167164
return result
168165
}
169166

170-
// Hard to avoid due to the complexity of parsing markdown token.
171-
// tslint:disable-next-line: cyclomatic-complexity
172167
private parseToken(
173168
token: marked.Token,
174169
index: number,

src-ts/tools/gamification-admin/pages/badge-detail/BadgeDetailPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { ChangeEvent, createRef, Dispatch, FC, KeyboardEvent, RefObject, SetStat
33
import { Params, useLocation, useParams } from 'react-router-dom'
44
import { toast } from 'react-toastify'
55
import { KeyedMutator, useSWRConfig } from 'swr'
6+
import { FullConfiguration } from 'swr/dist/types'
67
import ContentEditable from 'react-contenteditable'
78
import MarkdownIt from 'markdown-it'
89
import sanitizeHtml from 'sanitize-html'
9-
// tslint:disable-next-line: no-submodule-imports
10-
import { FullConfiguration } from 'swr/dist/types'
1110

1211
import { Breadcrumb, BreadcrumbItemModel, Button, ButtonProps, ContentLayout, IconOutline, IconSolid, LoadingSpinner, PageDivider, Sort, tableGetDefaultSort, TabsNavbar, TabsNavItem } from '../../../../lib'
1312
import { GamificationConfig } from '../../game-config'
@@ -29,7 +28,6 @@ const md: MarkdownIt = new MarkdownIt({
2928
// typographer: true,
3029
})
3130

32-
/* tslint:disable:cyclomatic-complexity */
3331
const BadgeDetailPage: FC = () => {
3432
const [headerButtonConfig, setHeaderButtonConfig]: [
3533
ButtonProps | undefined,
@@ -66,7 +64,7 @@ const BadgeDetailPage: FC = () => {
6664

6765
const fileInputRef: RefObject<HTMLInputElement> = createRef<HTMLInputElement>()
6866

69-
// tslint:disable-next-line:no-null-keyword
67+
// eslint-disable-next-line no-null/no-null
7068
const [newImageFile, setNewImageFile]: [FileList | null, Dispatch<SetStateAction<FileList | null>>] = useState<FileList | null>(null)
7169

7270
const [fileDataURL, setFileDataURL]: [string | undefined, Dispatch<SetStateAction<string | undefined>>] = useState<string | undefined>()

src-ts/tools/gamification-admin/pages/badge-detail/BatchAwardTab/BatchAwardTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable:no-null-keyword
21
import { Dispatch, FC, SetStateAction, useState } from 'react'
32

43
import { Button, IconSolid, InputFilePicker } from '../../../../../lib'
@@ -17,6 +16,7 @@ const BatchAwardTab: FC<BatchAwardTabProps> = (props: BatchAwardTabProps) => {
1716

1817
const [showBadgeAssigned, setShowBadgeAssigned]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
1918

19+
// eslint-disable-next-line no-null/no-null
2020
const [files, setFiles]: [FileList | null, Dispatch<SetStateAction<FileList | null>>] = useState<FileList | null>(null)
2121

2222
const [errorText, setErrorText]: [string, Dispatch<SetStateAction<string>>] = useState<string>('')

src-ts/tools/learn/course-completed/CourseCompletedPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const CourseCompletedPage: FC<{}> = () => {
5656
enabled: progressReady && !!progress,
5757
})
5858

59-
/* tslint:disable:cyclomatic-complexity */
6059
const isLoggedIn: boolean = profileReady && !!profile
6160
const certificatesDataReady: boolean = progressReady && certifReady
6261
const ready: boolean = profileReady && courseDataReady && (!isLoggedIn || certificatesDataReady)

src-ts/tools/learn/course-details/CourseDetailsPage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ const CourseDetailsPage: FC<{}> = () => {
5959
enabled: courseReady,
6060
})
6161

62-
// this looks better than finding workarounds for cyclomatic-complexity
63-
/* tslint:disable:cyclomatic-complexity */
6462
const ready: boolean = profileReady && courseReady && certificateReady && (!profile || progressReady)
6563

6664
const breadcrumb: Array<BreadcrumbItemModel> = useLearnBreadcrumb([

src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ function buildFormDataDesign(formData: any): ReadonlyArray<FormDetail> {
331331
const styleInfo: {} = {
332332
Like: formData.likedStyles?.value?.join(', '),
333333
// Disabling lint error to maintain order for display
334-
// tslint:disable-next-line: object-literal-sort-keys
334+
/* eslint-disable sort-keys */
335335
Dislike: formData.dislikedStyles?.value?.join(', '),
336336
'Additional Details': formData.stylePreferences?.value,
337337
'Color Selections': formData.colorOption?.value.join(', '),
338338
'Specific Colors': formData.specificColor?.value,
339+
/* eslint-enable sort-keys */
339340
}
340341

341342
return [

0 commit comments

Comments
 (0)