8000 vue pr Code Style · Issue #17 · songhlc/blog · GitHub
[go: up one dir, main page]

Skip to content

vue pr Code Style #17

Open
Open

Description

@songhlc

一入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的时候以上的代码风格都是需要遵循的,所以这里看完后并没有太多严格的地方,最严格的在最后一句,读源代码,参考它原有的方式

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0