Style guide for contributors

Thanks for your contribution to Appium! Here are the principles we use when writing javascript. Please conform to these so we can merge your pull request without going back and forth about style. The main principle is: make your code look like the surrounding code.


Commits in a pull request should consist of logical changes. If there are multiple authors, make sure each author has their own commit. It's not a good idea to modify author information. Merge commits should be rebased out of pull requests.


All code (except for code in bootstrap.js which uses proprietary Apple methods) must pass JSLint. To check your code, you can simply run grunt lint from the Appium repo dir. If you've created a new .js file, please make sure it is covered by the wildcards in grunt.js or that it is added specifically.

It's easy to have your code linted as you type, which makes the whole process much smoother. We like jshint, which has integrations with a lot of source code editors. The file .jshintrc is checked into the repo, so by adding jshint to your editor, you'll take advantage of the linting.

Since jshint does not enforce code style anymore, we also use jscs, for which it also exists some source editor integrations.

These configuration files define the warnings you will see in your favorite editor. See this page for jshint and this page for jscs to get the list of editors and platforms supported and how setup your editor for automatic linting.

Style notes

We use a future version of JavaScript and take advantage of the Babel transpiler to render it down to what is supported by current versions of Node.js. We use ES2015 (link needed) (formerly called ES6) with some not-yet-standard features, namely async/await (link needed). This style guide must be followed diligently in all Appium contributions!

Test Style:

Keep on the same line if it makes sense semantically and length is not an issue:




Alternatively use extra indents to improve readability:

    .keys("hello world")
    .should.become("hello world")
    .getValue().should.become("hello world")

  .execute("'nan'--")"status: 13")