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

vue pr Code Style #17

Open
songhlc opened this issue Aug 12, 2016 · 0 comments
Open

vue pr Code Style #17

songhlc opened this issue Aug 12, 2016 · 0 comments

Comments

@songhlc
Copy link
Owner

songhlc commented Aug 12, 2016

一入vue 终身脑残粉

vue pull request code style

持续关注vue 2.0(github vue-next 分支下的内容)

于是关注到 readme 中的 Pull Request Guidelines中关于代码风格的描述,原文如下:

  • No semicolons unless necessary.
  • Follow JSDoc.
  • 2 spaces indentation.
  • multiple var declarations.
  • 1 space after function and function names.
  • 1 space between arguments, but not between parentheses.
  • Break long ternary conditionals like this:

翻译如下:

  • 尽量不使用分号
  • 遵循JSDoc规范
  • 使用两个空格做为字符缩进
  • (我不太确定这里的意思,是否是如下代码的意思,将变量分开定义)
// good way
var variable1 = "Hello World!";
var variable2 = "Testing...";
var variable3 = 42;
// not recommend way
var variable1 = "Hello World!",
    variable2 = "Testing...",
    variable3 = 42;
  • 再function和函数名之间使用一个空格
  • 参数与参数之间使用一个空格(不包括圆括号)
  • 如下使用三目运算符
var a = superLongConditionalStatement
  ? 'yep'
  : 'nope'
  • 遇到疑惑时,读一下源代码

总结启示再使用eslint的时候以上的代码风格都是需要遵循的,所以这里看完后并没有太多严格的地方,最严格的在最后一句,读源代码,参考它原有的方式

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

No branches or pull requests

1 participant