-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[RFC] egg-bin check #2088
Comments
😂 看你回复都很无奈了 |
哈哈 ➜ egg-showcase git:(repl) ✗ n eslint . --fix
/Users/tz/Workspaces/coding/github.com/atian25/egg-showcase/config/config.default.js
25:1 error Don't use `exports` after `module.exports` eggache/no-override-exports
✖ 1 problem (1 error, 0 warnings) |
还有个提议,可以根据开发着的开发机的语言配置,来设置提示语言为英文还是中文。我遇到的有相当一部分开发者,看到英文的提示是直接不读的,然后截图丢过来,让你解决。这种非常无奈,英文的写的再直白,开发者不看,也没有办法。 |
https://github.com/eggjs/eslint-plugin-eggache 已经实现了 2 个规则,下一步集成到 @ngot 你这个在做 另外, |
@ngot 中文的话,有些人的终端还没法显示。。。 是否可以检查一下 module.exports[key] 和 exports[key] 是否相同?如果不是,直接在 dev 阶段报错,prod 阶段警告? |
嗯,也是考虑到这个...
这个要看定位了,我现在是独立了一个规则库,然后放到了 2 个地方:
而你提的 dev 和 prod,也可以做,就看有没有必要,要做也是在 egg-bin 和 egg-scripts 这一层,而不是 egg 那里,相当于 bin 强制做了一次 lint 了。
|
|
19 |
Nodejs的这个设计很不好(错的人多只能说明设计的错误),没有必要在文档中沿用这些混乱的写法。别说从其他语言转过来的,我写了七八年js,babel,webpack,eslint,tslint,metro的配置里从来没见过exports和module.exports的混写,所以我也不知道这些,也不会去记这些特定环境里的设定。 @atian25 |
背景
这种低级错误,在日常解答中出现过很多次,甚至集团内部都有,有时候真会让我有点怀疑人生。
累计到昨天光我自己就解答了 18 次了,不自觉的总会带有一点怒气的去回复,但这样怼人其实真的不好。
如何能帮助开发者避免低级错误,又能保持好维护者的答疑心情呢?
思路
需要引入静态代码检查,但能遇到这类问题的大部分是初级开发者,很少会使用 eslint 。
一种思路是:
eslint-config-egg-badsmell
(最终使用eslint-plugin-eggache
)egg-bin check
方法来检查,维护者怀疑是低级错误时,让开发者先执行命令,避免无谓的沟通。可以将内部的 stc 库一并考虑。cc @jtyjty99999规则库
no-override-exports
config/config.*.js
,禁止覆盖 exportsplugin-property
config/plugin.*.js
,禁止多余的 key,目前仅支持enable/package/path/env
实现
i18nThe text was updated successfully, but these errors were encountered: