Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove tslint and use typescript-eslint #159

Merged
merged 5 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"parser": "babel-eslint",
"extends": ["standard", "standard-react"],
"root": true,
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
],
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true,
"commonjs": true
},
"plugins": ["react", "react-hooks"],
"plugins": ["@typescript-eslint", "react", "react-hooks", "prettier"],
"parserOptions": {
"ecmaVersion": 6,
"project": "./tsconfig.json",
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
}
Expand All @@ -20,14 +25,33 @@
"sleep": true,
"prettyFormat": true
},
"settings": {
"react": {
"version": "detect",
}
},

"rules": {
"prettier/prettier": 2,

// don't force es6 functions to include space before paren
"space-before-function-paren": 0,
"react/prop-types": 0,
"react/no-find-dom-node": 0,
"react/display-name": 0,
// allow specifying true explicitly for boolean props
"react/jsx-boolean-value": 0,
"react-hooks/rules-of-hooks": "error",
"react-hooks/rules-of-hooks": 2,
"react/no-did-update-set-state": 0,
"jsx-quotes":"off"
// maybe we should no-public
"@typescript-eslint/explicit-member-accessibility": 0,

"@typescript-eslint/interface-name-prefix": 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要关掉?好像很多都是 I 开头的哈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这条规则的意思是接口不能以I开头,不关掉就各种错误了

"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/array-type": 0,
"@typescript-eslint/no-object-literal-type-assertion": 0,
"no-console": ["error", { "allow": ["warn", "error", "info"] }]
}
}
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
semi: false,
tabWidth: 2,
singleQuote: true,
}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ before_script:

script:
- npm run lint
- npm run tslint:once
- npm run test
38 changes: 23 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
"version:major": "npm run prevesion && lerna version major --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
"release:force": "lerna publish from-package --yes",
"release": "lerna publish",
"lint": "eslint \"packages/!(docs)/**/*.js\" \"scripts/**/*.js\"",
"tslint": "npm run tslint:once && onchange 'packages/**/*.ts' -- npm run tslint:once",
"tslint:once": "tslint --fix --project ./ ",
"lint": "eslint --ext .ts,.tsx,.js \"packages/!(docs)/**/*.@(ts|tsx)\" \"scripts/**/*.js\" --fix",
"postinstall": "opencollective-postinstall"
},
"devDependencies": {
Expand All @@ -44,6 +42,9 @@
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime-corejs3": "^7.2.0",
"@testing-library/react": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"all-contributors-cli": "^6.1.2",
"antd": "^3.17.0",
"babel-eslint": "^10.0.1",
Expand All @@ -57,14 +58,13 @@
"cz-conventional-changelog": "^2.1.0",
"doc-scripts": "^1.7.24",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-config-standard-react": "^7.0.2",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.0.2",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-react-hooks": "^1.6.1",
"execa": "^1.0.0",
"findup": "^0.1.5",
"fs-extra": "^7.0.1",
Expand All @@ -79,38 +79,46 @@
"jest-watch-lerna-packages": "^1.1.0",
"json5": "^2.1.0",
"lerna": "^3.10.1",
"lint-staged": "^9.1.0",
"majo": "^0.7.1",
"onchange": "^5.2.0",
"prettier-eslint-cli": "^4.7.1",
"prettier": "^1.18.2",
"pretty-format": "^24.0.0",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"@testing-library/react": "^8.0.0",
"remark-parse": "^6.0.3",
"remark-stringify": "^6.0.4",
"semver-regex": "^2.0.0",
"staged-git-files": "^1.1.2",
"ts-jest": "^24.0.2",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.4.5",
"unified": "^7.1.0",
"user-event": "^1.4.4",
"webpack": "^4.27.1"
},
"config": {
"ghooks": {
"pre-commit": "prettier-eslint \"./(packages|scripts)/**.js\" --write && npm run lint",
"pre-commit": "lint-staged",
"commit-msg": "node ./scripts/validate-commit-msg.js"
},
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"lint-staged": {
"packages/!(docs)/**/*.@(ts|tsx)": [
"eslint --ext .ts,.tsx --fix",
"git add"
],
"scripts/**/*.js": [
"eslint --fix",
"git add"
]
},
"dependencies": {
"opencollective-postinstall": "^2.0.2",
"opencollective": "^1.0.3"
"opencollective": "^1.0.3",
"opencollective-postinstall": "^2.0.2"
},
"collective": {
"type": "opencollective",
Expand Down
20 changes: 13 additions & 7 deletions packages/antd/src/components/formButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const isElementInViewport = (
offset = 0,
threshold = 0
}: {
offset?: IOffset | number
threshold?: number
offset?: IOffset | number
threshold?: number
} = {}
) => {
const { top, right, bottom, left, width, height } = rect
Expand All @@ -50,10 +50,14 @@ const isElementInViewport = (
}

return (
intersection.t >= ((offset as IOffset).top || offset as number + elementThreshold.y) &&
intersection.r >= ((offset as IOffset).right || offset as number + elementThreshold.x) &&
intersection.b >= ((offset as IOffset).bottom || offset as number + elementThreshold.y) &&
intersection.l >= ((offset as IOffset).left || offset as number + elementThreshold.x)
intersection.t >=
((offset as IOffset).top || (offset as number) + elementThreshold.y) &&
intersection.r >=
((offset as IOffset).right || (offset as number) + elementThreshold.x) &&
intersection.b >=
((offset as IOffset).bottom || (offset as number) + elementThreshold.y) &&
intersection.l >=
((offset as IOffset).left || (offset as number) + elementThreshold.x)
)
}

Expand Down Expand Up @@ -150,6 +154,7 @@ export const FormButtonGroup = styled(

private getStickyBoundaryHandler(ref) {
return () => {
// eslint-disable-next-line react/no-find-dom-node
this.formNode = this.formNode || ReactDOM.findDOMNode(ref.current)
if (this.formNode) {
return isElementInViewport(this.formNode.getBoundingClientRect())
Expand All @@ -159,7 +164,8 @@ export const FormButtonGroup = styled(
}
}
)`
${props => (props.align ? `display:flex;justify-content: ${getAlign(props.align)}` : '')}
${props =>
props.align ? `display:flex;justify-content: ${getAlign(props.align)}` : ''}
&.is-inline {
display: inline-block;
flex-grow: 3;
Expand Down
16 changes: 11 additions & 5 deletions packages/antd/src/components/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Row extends Component<IRowProps> {
}

public render() {
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
const {
prefix,
pure,
Expand All @@ -30,7 +30,7 @@ export class Row extends Component<IRowProps> {
children,
...others
} = this.props
/* eslint-enable no-unused-vars */
/* eslint-enable @typescript-eslint/no-unused-vars */

let hiddenClassObj
if (hidden === true) {
Expand Down Expand Up @@ -65,8 +65,12 @@ export class Row extends Component<IRowProps> {
...(others.style || {})
}
newChildren = Children.map(children, (child: React.ReactElement) => {
// @ts-ignore
if (child && child.type && typeof child.type === 'function' && child.type.isNextCol) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动好像会报 typescript 错误吧?因为这个 isNextCol 太随意了,但是又不能去掉

if (
child &&
child.type &&
typeof child.type === 'function' &&
child.type['isNextCol']
) {
const newChild = cloneElement(child, {
style: {
paddingLeft: halfGutterString,
Expand Down Expand Up @@ -131,7 +135,9 @@ export class Col extends Component<IColProps> {
}

ret[`${prefix}col-${point}-${pointProps.span}`] = !!pointProps.span
ret[`${prefix}col-${point}-offset-${pointProps.offset}`] = !!pointProps.offset
ret[
`${prefix}col-${point}-offset-${pointProps.offset}`
] = !!pointProps.offset
return ret
}, {})

Expand Down
Loading