代码规范

    您可以运行 来显示 cpplinteslint 检测到的任何样式问题。

    • 用换行符结束文件。
    • 按照如下顺序排列 node 模块的 require 代码
      • 内置Node模块(如 path
      • 内置Electron模块(如 ipcapp
    • 按照如下顺序排列类的属性
      • Class methods and properties (methods starting with a @)
      • Instance methods and properties
    • 避免与平台相关的代码:
      • 使用 path.join() 来组织文件路径。
      • 请使用os.tmpdir()而不是/tmp来引用临时目录。
    • 使用 return 来明确的结束一个函数
      • 不是return nullreturn undefined,或undefined

    我们现在使用的 Python 版本是 Python 2.7。

    你可以运行 npm run lint-docs 来保证你修改的文档格式正确。

    • 文件名应使用 - 连接而不是 _, 例如. file-name.js 而不是 file_name.js, 因为在 中模块名通常是 module-name 形式. 此规则仅适用于 .js 文件。
    • 酌情使用更新的 ES6 / ES2015 语法
      • const 用于需要的和其他的常数. If the value is a primitive, use uppercase naming (eg const NUMBER_OF_RETRIES = 5).
      • 用于定义变量
      • Arrow functions 代替
      • 而不是使用字符串连接符 +
    • 当模块本身是class时, 比如 BrowserWindow, 使用 CamelCase.
    • 当模块是一组 API 时, 比如 globalShortcut时,使用 mixedCase
    • 当 API 是对象的属性时, 并且它复杂到足以成为一个单独的块, 比如 win.webContents, 使用 mixedCase.

    当创建新的 API 时, 最好使用 getter 和 setter 而不是 jQuery 的一次性函数。 举个例子, .getText().setText(text) 优于 .text([text]). 这是一些相关的 讨论