Skip to content

Commit 97caa9c

Browse files
stkevintanjanryWang
authored andcommitted
chore: remove tslint and use typescript-eslint (#159)
* chore: remove tslint and use typescript-eslint feat: remove tslint and eslint to lint typescript chore: better eslint setting * chore: integrate prettier into eslint * chore: downgrade lint-staged version * fix: child.type.isNextCol error * chore: better eslint config
1 parent 9a0025a commit 97caa9c

Some content is hidden

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

94 files changed

+1285
-645
lines changed

.eslintrc

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
{
2-
"parser": "babel-eslint",
3-
"extends": ["standard", "standard-react"],
42
"env": {
5-
"browser": true,
6-
"node": true,
7-
"es6": true,
8-
"jest": true,
9-
"commonjs": true
3+
"node": true
4+
},
5+
"globals": {
6+
"sleep": true,
7+
"prettyFormat": true
108
},
11-
"plugins": ["react", "react-hooks"],
129
"parserOptions": {
13-
"ecmaVersion": 6,
10+
"ecmaVersion": 10,
1411
"sourceType": "module",
1512
"ecmaFeatures": {
1613
"jsx": true
1714
}
18-
},
19-
"globals": {
20-
"sleep": true,
21-
"prettyFormat": true
22-
},
23-
"rules": {
24-
// don't force es6 functions to include space before paren
25-
"space-before-function-paren": 0,
26-
"react/prop-types": 0,
27-
// allow specifying true explicitly for boolean props
28-
"react/jsx-boolean-value": 0,
29-
"react-hooks/rules-of-hooks": "error",
30-
"react/no-did-update-set-state": 0,
31-
"jsx-quotes":"off"
3215
}
33-
}
16+
}

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
semi: false,
3+
tabWidth: 2,
4+
singleQuote: true,
5+
}

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ before_script:
1414

1515
script:
1616
- npm run lint
17-
- npm run tslint:once
1817
- npm run test

package.json

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
"version:major": "npm run prevesion && lerna version major --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
2626
"release:force": "lerna publish from-package --yes",
2727
"release": "lerna publish",
28-
"lint": "eslint \"packages/!(docs)/**/*.js\" \"scripts/**/*.js\"",
29-
"tslint": "npm run tslint:once && onchange 'packages/**/*.ts' -- npm run tslint:once",
30-
"tslint:once": "tslint --fix --project ./ ",
28+
"lint": "eslint --ext .ts,.tsx,.js \"packages/!(docs)/**/src/**/*.@(ts|tsx)\" \"scripts/**/*.js\" --fix",
3129
"postinstall": "opencollective-postinstall"
3230
},
3331
"devDependencies": {
@@ -44,6 +42,9 @@
4442
"@babel/preset-react": "^7.0.0",
4543
"@babel/register": "^7.0.0",
4644
"@babel/runtime-corejs3": "^7.2.0",
45+
"@testing-library/react": "^8.0.0",
46+
"@typescript-eslint/eslint-plugin": "^1.11.0",
47+
"@typescript-eslint/parser": "^1.11.0",
4748
"all-contributors-cli": "^6.1.2",
4849
"antd": "^3.17.0",
4950
"babel-eslint": "^10.0.1",
@@ -57,14 +58,13 @@
5758
"cz-conventional-changelog": "^2.1.0",
5859
"doc-scripts": "^1.7.24",
5960
"eslint": "^5.16.0",
60-
"eslint-config-standard": "^12.0.0",
61-
"eslint-config-standard-react": "^7.0.2",
61+
"eslint-config-prettier": "^6.0.0",
6262
"eslint-plugin-import": "^2.13.0",
6363
"eslint-plugin-node": "^7.0.1",
64+
"eslint-plugin-prettier": "^3.1.0",
6465
"eslint-plugin-promise": "^4.0.0",
65-
"eslint-plugin-react": "^7.13.0",
66-
"eslint-plugin-react-hooks": "^1.0.2",
67-
"eslint-plugin-standard": "^4.0.0",
66+
"eslint-plugin-react": "^7.14.2",
67+
"eslint-plugin-react-hooks": "^1.6.1",
6868
"execa": "^1.0.0",
6969
"findup": "^0.1.5",
7070
"fs-extra": "^7.0.1",
@@ -79,38 +79,46 @@
7979
"jest-watch-lerna-packages": "^1.1.0",
8080
"json5": "^2.1.0",
8181
"lerna": "^3.10.1",
82+
"lint-staged": "^8.2.1",
8283
"majo": "^0.7.1",
8384
"onchange": "^5.2.0",
84-
"prettier-eslint-cli": "^4.7.1",
85+
"prettier": "^1.18.2",
8586
"pretty-format": "^24.0.0",
8687
"react": "^16.8.3",
8788
"react-dom": "^16.8.3",
88-
"@testing-library/react": "^8.0.0",
8989
"remark-parse": "^6.0.3",
9090
"remark-stringify": "^6.0.4",
9191
"semver-regex": "^2.0.0",
9292
"staged-git-files": "^1.1.2",
9393
"ts-jest": "^24.0.2",
9494
"tsconfig-paths-webpack-plugin": "^3.2.0",
95-
"tslint": "^5.16.0",
96-
"tslint-config-prettier": "^1.18.0",
9795
"typescript": "^3.4.5",
9896
"unified": "^7.1.0",
9997
"user-event": "^1.4.4",
10098
"webpack": "^4.27.1"
10199
},
102100
"config": {
103101
"ghooks": {
104-
"pre-commit": "prettier-eslint \"./(packages|scripts)/**.js\" --write && npm run lint",
102+
"pre-commit": "lint-staged",
105103
"commit-msg": "node ./scripts/validate-commit-msg.js"
106104
},
107105
"commitizen": {
108106
"path": "./node_modules/cz-conventional-changelog"
109107
}
110108
},
109+
"lint-staged": {
110+
"packages/!(docs)/**/*.@(ts|tsx)": [
111+
"eslint --ext .ts,.tsx --fix",
112+
"git add"
113+
],
114+
"scripts/**/*.js": [
115+
"eslint --fix",
116+
"git add"
117+
]
118+
},
111119
"dependencies": {
112-
"opencollective-postinstall": "^2.0.2",
113-
"opencollective": "^1.0.3"
120+
"opencollective": "^1.0.3",
121+
"opencollective-postinstall": "^2.0.2"
114122
},
115123
"collective": {
116124
"type": "opencollective",

packages/.eslintrc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"plugin:react/recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"prettier/@typescript-eslint",
7+
],
8+
"env": {
9+
"browser": true,
10+
"es6": true,
11+
"jest": true,
12+
"commonjs": true
13+
},
14+
"plugins": ["@typescript-eslint", "react", "react-hooks", "prettier"],
15+
"parserOptions": {
16+
"project": "./tsconfig.json",
17+
"sourceType": "module",
18+
"ecmaVersion": 6,
19+
"ecmaFeatures": {
20+
"jsx": true
21+
}
22+
},
23+
"settings": {
24+
"react": {
25+
"version": "detect",
26+
}
27+
},
28+
29+
"rules": {
30+
"prettier/prettier": 2,
31+
32+
// don't force es6 functions to include space before paren
33+
"space-before-function-paren": 0,
34+
"react/prop-types": 0,
35+
"react/no-find-dom-node": 0,
36+
"react/display-name": 0,
37+
// allow specifying true explicitly for boolean props
38+
"react/jsx-boolean-value": 0,
39+
"react-hooks/rules-of-hooks": 2,
40+
"react/no-did-update-set-state": 0,
41+
// maybe we should no-public
42+
"@typescript-eslint/explicit-member-accessibility": 0,
43+
44+
"@typescript-eslint/interface-name-prefix": 0,
45+
"@typescript-eslint/no-explicit-any": 0,
46+
"@typescript-eslint/explicit-function-return-type": 0,
47+
"@typescript-eslint/no-parameter-properties": 0,
48+
"@typescript-eslint/array-type": 0,
49+
"@typescript-eslint/no-object-literal-type-assertion": 0,
50+
"no-console": ["error", { "allow": ["warn", "error", "info"] }]
51+
}
52+
}

packages/antd/src/components/formButtonGroup.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const isElementInViewport = (
3232
offset = 0,
3333
threshold = 0
3434
}: {
35-
offset?: IOffset | number
36-
threshold?: number
35+
offset?: IOffset | number
36+
threshold?: number
3737
} = {}
3838
) => {
3939
const { top, right, bottom, left, width, height } = rect
@@ -50,10 +50,14 @@ const isElementInViewport = (
5050
}
5151

5252
return (
53-
intersection.t >= ((offset as IOffset).top || offset as number + elementThreshold.y) &&
54-
intersection.r >= ((offset as IOffset).right || offset as number + elementThreshold.x) &&
55-
intersection.b >= ((offset as IOffset).bottom || offset as number + elementThreshold.y) &&
56-
intersection.l >= ((offset as IOffset).left || offset as number + elementThreshold.x)
53+
intersection.t >=
54+
((offset as IOffset).top || (offset as number) + elementThreshold.y) &&
55+
intersection.r >=
56+
((offset as IOffset).right || (offset as number) + elementThreshold.x) &&
57+
intersection.b >=
58+
((offset as IOffset).bottom || (offset as number) + elementThreshold.y) &&
59+
intersection.l >=
60+
((offset as IOffset).left || (offset as number) + elementThreshold.x)
5761
)
5862
}
5963

@@ -150,6 +154,7 @@ export const FormButtonGroup = styled(
150154

151155
private getStickyBoundaryHandler(ref) {
152156
return () => {
157+
// eslint-disable-next-line react/no-find-dom-node
153158
this.formNode = this.formNode || ReactDOM.findDOMNode(ref.current)
154159
if (this.formNode) {
155160
return isElementInViewport(this.formNode.getBoundingClientRect())
@@ -159,7 +164,8 @@ export const FormButtonGroup = styled(
159164
}
160165
}
161166
)`
162-
${props => (props.align ? `display:flex;justify-content: ${getAlign(props.align)}` : '')}
167+
${props =>
168+
props.align ? `display:flex;justify-content: ${getAlign(props.align)}` : ''}
163169
&.is-inline {
164170
display: inline-block;
165171
flex-grow: 3;

packages/antd/src/components/grid.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Row extends Component<IRowProps> {
1414
}
1515

1616
public render() {
17-
/* eslint-disable no-unused-vars */
17+
/* eslint-disable @typescript-eslint/no-unused-vars */
1818
const {
1919
prefix,
2020
pure,
@@ -30,7 +30,7 @@ export class Row extends Component<IRowProps> {
3030
children,
3131
...others
3232
} = this.props
33-
/* eslint-enable no-unused-vars */
33+
/* eslint-enable @typescript-eslint/no-unused-vars */
3434

3535
let hiddenClassObj
3636
if (hidden === true) {
@@ -65,8 +65,12 @@ export class Row extends Component<IRowProps> {
6565
...(others.style || {})
6666
}
6767
newChildren = Children.map(children, (child: React.ReactElement) => {
68-
// @ts-ignore
69-
if (child && child.type && typeof child.type === 'function' && child.type.isNextCol) {
68+
if (
69+
child &&
70+
child.type &&
71+
typeof child.type === 'function' &&
72+
(child.type as any).isNextCol
73+
) {
7074
const newChild = cloneElement(child, {
7175
style: {
7276
paddingLeft: halfGutterString,
@@ -131,7 +135,9 @@ export class Col extends Component<IColProps> {
131135
}
132136

133137
ret[`${prefix}col-${point}-${pointProps.span}`] = !!pointProps.span
134-
ret[`${prefix}col-${point}-offset-${pointProps.offset}`] = !!pointProps.offset
138+
ret[
139+
`${prefix}col-${point}-offset-${pointProps.offset}`
140+
] = !!pointProps.offset
135141
return ret
136142
}, {})
137143

0 commit comments

Comments
 (0)