Giter Site home page Giter Site logo

一些约定的备忘, 待讨论 about egg HOT 14 CLOSED

eggjs avatar eggjs commented on April 19, 2024
一些约定的备忘, 待讨论

from egg.

Comments (14)

atian25 avatar atian25 commented on April 19, 2024

cc @eggjs/core

from egg.

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

我的建议是

  • 小写
  • 小写

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

@fengmk2 @dead-horse @popomore

from egg.

fengmk2 avatar fengmk2 commented on April 19, 2024

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

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

from egg.

atian25 avatar atian25 commented on April 19, 2024

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

from egg.

dead-horse avatar dead-horse commented on April 19, 2024

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

from egg.

shaoshuai0102 avatar shaoshuai0102 commented on April 19, 2024

命名这个讨论过。

  • 最简单的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

from egg.

atian25 avatar atian25 commented on April 19, 2024

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

from egg.

fengmk2 avatar fengmk2 commented on April 19, 2024

就按 @shaoshuai0102 说的来吧。

from egg.

atian25 avatar atian25 commented on April 19, 2024

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

// {app_root}/config/plugin.js

exports.session = {

};

from egg.

popomore avatar popomore commented on April 19, 2024

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

from egg.

popomore avatar popomore commented on April 19, 2024

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

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

from egg.

atian25 avatar atian25 commented on April 19, 2024

单元测试

  • 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

from egg.

popomore avatar popomore commented on April 19, 2024

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

from egg.

atian25 avatar atian25 commented on April 19, 2024

不用了

from egg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.