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

一些约定的备忘, 待讨论 #18

Closed
2 tasks
atian25 opened this issue Jul 17, 2016 · 14 comments
Closed
2 tasks

一些约定的备忘, 待讨论 #18

atian25 opened this issue Jul 17, 2016 · 14 comments

Comments

@atian25
Copy link
Member

atian25 commented Jul 17, 2016

  • Symbol 的命名规则
  • config.default.js 的 jsdoc 规则
@atian25 atian25 changed the title Symbol 的命名规则是否需要顺便约定下? 一些约定的备忘, 待讨论 Jul 17, 2016
@atian25
Copy link
Member Author

atian25 commented Jul 17, 2016

cc @eggjs/core

@shaoshuai0102
Copy link
Contributor

  • egg 在文档中全部以小写出现?
  • plugin name 即便出现在首行,也都用小写?
  • 写 plugin name 的时候,要不要都带上 egg-?

我的建议是

  • 小写
  • 小写

其他一些遇到的文档细节约定都在这里讨论吧

@fengmk2 @dead-horse @popomore

@fengmk2
Copy link
Member

fengmk2 commented Jul 18, 2016

写 plugin name 的时候,要不要都带上 egg-?

这个不需要吧,模块名称带 egg-,但是插件名称不需要。

@atian25
Copy link
Member Author

atian25 commented Jul 18, 2016

egg 全小写这个之前讨论过的,不能首字母大写和全大写

@dead-horse
Copy link
Member

我们现在有很多插件是 userService 这样命名的。。

@shaoshuai0102
Copy link
Contributor

命名这个讨论过。

  • 最简单的pacakge name: @ali/egg-xx@alipay/egg-xx,pluginName 为全小写 xx
  • 比较长的用中划线package name @ali/egg-foo-bar@alipay/egg-foo-bar,对应的 pluginName 使用小驼峰,小驼峰转换规则以 package name 的中划线为准 fooBar

对于可以中划线也可以不用的情况,不做强制约定,例如 sessiontair(@alipay/egg-sessiontair) 还是 sessionTair(@alipay/egg-session-tair),userservice(@alipay/egg-userservice) 还是 user-service(@ali/egg-user-service)。只要遵循以上规则即可,如果选择用中划线,就要按照小驼峰命名 pluginName。

链接不贴了 issue 188

@atian25
Copy link
Member Author

atian25 commented Jul 18, 2016

这个命名规范回头可以移植到 docs 下

@fengmk2
Copy link
Member

fengmk2 commented Jul 18, 2016

就按 @shaoshuai0102 说的来吧。

@atian25
Copy link
Member Author

atian25 commented Jul 19, 2016

注释和文档里面出现的代码, 建议都在第一行加上文件地址

// {app_root}/config/plugin.js

exports.session = {

};

@popomore
Copy link
Member

popomore commented Aug 3, 2016

其实这个就是约定,社区肯定会存在驼峰党和非驼峰党

@popomore
Copy link
Member

popomore commented Aug 3, 2016

egg 保留的 Symbol 就用全局的,之后可以整理出来

  • Symbol.for('egg#eggPath')
  • Symbol.for('egg#view')

@atian25
Copy link
Member Author

atian25 commented Aug 3, 2016

单元测试

  • before 记得调用 app.ready
let app;
before(function* () {
  app = mm.app({
    baseDir: 'security',
  });
  yield app.ready();
});
  • supertest 2.x 后支持 promise 了, 可以使用:
it('test', function* (){
  const result = yield require(app.callback()).get('/');
  assert(result.text.match(/hi, egg/));
});
  • 使用 power-assert 替换掉 should , 已经内置到 egg-bin
 1) Array #indexOf() should return index when the value is present:
     AssertionError: # path/to/test/mocha_node.js:10

  assert(this.ary.indexOf(zero) === two)
              |   |       |     |   |
              |   |       |     |   2
              |   -1      0     false
              [1,2,3]

  [number] two
  => 2
  [number] this.ary.indexOf(zero)
  => -1

@popomore
Copy link
Member

popomore commented Aug 3, 2016

那可以不用 supertest-as-promise 了?

@atian25
Copy link
Member Author

atian25 commented Aug 3, 2016

不用了

@popomore popomore modified the milestone: v1.x Aug 13, 2016
@fengmk2 fengmk2 closed this as completed Sep 2, 2016
elrrrrrrr pushed a commit to elrrrrrrr/egg that referenced this issue Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants