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
根据 2.x 规则和 Airbnb base 规则进行修改,规范规则 #11
Conversation
@@ -18,7 +18,7 @@ | |||
"homepage": "https://github.com/egg-express/eslint-config-egg", | |||
"author": "popomore <sakura9515@gmail.com>", | |||
"scripts": { | |||
"lint": "eslint test index.js", | |||
"lint": "eslint test -c index.js index.js legacy.js rules/*.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.js 重复了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一开始没用 .eslintrc
,就直接拿 index.js
当配置了…
好详细 |
airbnb 的解释很详细,我基本上就是批量整理 |
* 条件判断最多允许 11 条路径 | ||
* @see http://eslint.org/docs/rules/complexity | ||
*/ | ||
complexity: [0, 11], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11 的由来?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有的规则第一位是 0,代表关闭,airbnb 和原来的规则都这样写,我就照搬了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只是想知道为何是 11, 不是10, 不是12
跑下 egg 和 nut 的 core 代码看看? (test 里面应该可以稍微放松) |
试过 egg,能通过 |
@eggjs/contributor 大家看看这套规则怎么样, 如果 OK 的话, 后面插件开源时就顺便搞搞 |
* // 正确 | ||
* function doSomething(condition) { | ||
* if (condition) { | ||
* return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
例子不太好吧,如果返回是 true,那么我们还是希望返回值是 boolean 的,而不是 undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function doSomething(condition) {
if (condition) {
return;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重点在于有没有 return
,至于 return
什么类型这个依情况而定。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fengmk2 我觉得这个应该打开,避免方法执行结果不一的情况。并且打开 treatUndefinedAsUnspecified
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这条规则我记得打开过,怎么又被关掉了?
chair/chair#662
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修订时的 eslint-config-egg 是关闭的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geekdada 就按你的来 'consistent-return': 0
a940755
to
25bc00b
Compare
@fengmk2 我已经全部改完了 |
注释还是用中文? |
我觉得中英文混合可能会更好 |
按昨天的讨论, 全英文~ 中英文混合的话, 担心同步问题. @geekdada 加油~ |
81a5afd
to
d5b4a81
Compare
所有的注释都已经有英文版本了 |
中文去掉好了?别中英混了。。 |
@atian25 天猪说中文可以保留…好的,我去掉… |
…es, and classify them by category.
@dead-horse @fengmk2 @popomore 麻烦最后检查一下 |
+1 |
发 minor 还是 major 呢? |
如果 minor 会挂一大片的… |
👍 |
@geekdada egg 很多项目都得改? |
major 吧
|
规则和原来比肯定有变动的,而且个别规则可能跟某些人习惯不一样 On Jul 8, 2016 8:48 AM, "Haoliang Gao" notifications@github.com wrote:
|
可以先在几个库试一下
|
我们这边几个库都挂了 2016-07-08 9:00 GMT+08:00 Haoliang Gao notifications@github.com:
李一航 |
我发 3.0 |
@popomore 好吧,忘记了,只有你能发,我已经 push 到 master 了
|
加你了
|
对规则增加了注释,
@since 3.0.0
代表原来未定义或者定义有修改的规则。在规则修改上较尊重 Airbnb 的规则,不过在有差异的地方会根据现有 egg 的代码进行权衡。