Parsoid/Style guide

From MediaWiki.org
Jump to: navigation, search

This page documents differences from the MediaWiki JS coding conventions. Our conventions are enforced by jshint.

Indentation[edit]

The team would prefer to use spaces for indentation, but for now we are following the MediaWiki preference for tabs. Our tabs are four chars in width. [1]

Strict mode[edit]

Enable strict mode near the top of all js files:

"use strict";

Conditionals[edit]

if (foo
    && (aReallyLongCondition
        || anotherReallyReallyLongCondition)
    && foo.bat
) {
  ...
}

Notes[edit]

  1. Example .vimrc line for vim users:
    autocmd BufNewFile,BufRead /home/gabriel/src/parsoid/**.js set ts=4 sw=4 noexpandtab