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'

0 commit comments

Comments
 (0)