Mr.doob’s Code Style™

I wrote a gist describing a little of mrdoob’s code conventions (as some have referred to the MDCS) and included a jscs rules for code style enforcing.

Not everyone is familiar or used to MDCS so @WestLangley asked if there’s a script which can “mrdoobify” the rest of our codebase which has not conformed to that standard.

So some objectives I hope to archive are:

  1. Have some documentation on mrdoob’s code style (perhaps on the wiki pages?)
  2. Add jscs rules so contributors can use it for validating code via pre-commit hook or editor’s linting (sublime / vim) or just part of the build tools.
  3. Try some code transformation tools to make existing code more mrdoob style compliant.

For 2, there are a couple more features in the JSCS I’m waiting to get implemented or merged before it could really enforce MDCS. In particular, jscs-dev/node-jscs#371 jscs-dev/node-jscs#333 possibly jscs-dev/node-jscs#244 and jscs-dev/node-jscs#126 (comment) too.

As for 3, I could try out codepainter ( and see how well it works for this.

Author: Fantashit

1 thought on “Mr.doob’s Code Style™

  1. I finally got codepainter working, its cli commands are pretty sensitive so it wouldn’t work if some flags are wrong.

    first create a json eg. mrdoob_codepainter.json

        "indent_style": "tab",
        "indent_size": "tab",
        "insert_final_newline": true,
        "quote_type": "auto",
        "space_after_anonymous_functions": true,
        "space_after_control_statements": true,
        "spaces_around_operators": true,
        "trim_trailing_whitespace": true,
        "spaces_in_brackets": "hybrid",
        "end_of_line": "lf"


    codepainter xform -j ../utils/codestyle/mrdoob_codepainter.json  "*/*.js"

    The nice thing is that it transform a whole bunch of js files. The bad thing is that it doesn’t really conforms to MDCS. In particularly, the “hybrid” mode for spaces_in_brackets follows the idiomatic js style.

Comments are closed.