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

Conversation

stkevintan
Copy link
Contributor

使用typescript-eslint来代替tslint

  1. tslint已停止维护,因为性能问题。
  2. typescript-eslint可以将eslint的rule应用与ts文件中
  3. 项目lint工具统一

PS: 很多还没用ts重构的项目文件被eslint给autofix了,不过应该不影响。

feat: remove tslint and eslint to lint typescript

chore: better eslint setting
package.json Outdated
"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 .js,.ts,.tsx \"packages/!(docs)/**/*.@(ts|tsx|js)\" \"scripts/**/*.@(ts|tsx|js)\"",
Copy link
Contributor

@monkindey monkindey Jul 10, 2019

Choose a reason for hiding this comment

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

要不要结合 lint-staged 只检测修改的文件哦?感觉每次执行 lint 有点慢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,可以加上

"ecmaFeatures": {
"jsx": true
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

这个文件的作用是?还有我的 vscode 显示这个文件 ESLint 有错误

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

多了一个逗号,这个.eslintrc是单独配置这个目录下的eslint规则。因为下面都是一些编译的脚本规则应该是不一样的,比如说允许使用require,env应该是node等

.eslintrc Outdated
// allow specifying true explicitly for boolean props
"react/jsx-boolean-value": 0,
"react-hooks/rules-of-hooks": "error",
"react/no-did-update-set-state": 0,
"jsx-quotes":"off"
// maybe we should no-public
"@typescript-eslint/explicit-member-accessibility": "off",
Copy link
Contributor

Choose a reason for hiding this comment

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

保持队列,用 0 ?

Copy link
Contributor Author

@stkevintan stkevintan Jul 10, 2019

Choose a reason for hiding this comment

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

嗯嗯,还是统一用数字吧

.eslintrc Outdated
// maybe we should no-public
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/indent": ["error", 2],
"@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开头,不关掉就各种错误了

.eslintrc Outdated
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/no-use-before-define": 0,
// "@typescript-eslint/no-var-requires": 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

不要注释吧?直接 remove 掉?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

对。。。

.eslintrc Outdated
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/no-use-before-define": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个为啥要关呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

js文件里面违反这条规则的代码有点多。要不先不管js文件吧。。。

.eslintrc Outdated
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/no-use-before-define": 0,
// "@typescript-eslint/no-var-requires": 1,
"@typescript-eslint/array-type":0,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:加上空格

.eslintrc Outdated
"@typescript-eslint/no-use-before-define": 0,
// "@typescript-eslint/no-var-requires": 1,
"@typescript-eslint/array-type":0,
"@typescript-eslint/class-name-casing": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个为啥要关呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

因为代码里面很多违反这条规则的情况,比如:fileSetting,defaultValueCascader之类的。不过都是js文件。要不我们先不管这些 js文件,因为反正都会用ts重构掉

@@ -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 太随意了,但是又不能去掉

@janryWang janryWang merged commit 97caa9c into alibaba:master Jul 11, 2019
@stkevintan
Copy link
Contributor Author

@janryWang 以后我自己来merge吧,感觉每个pr提交次数太多,squash一下会比较好

@monkindey
Copy link
Contributor

他就是用 squash 的吧

@stkevintan
Copy link
Contributor Author

@monkindey 好吧,merge squash也行

ZirkleTsing pushed a commit that referenced this pull request May 14, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants