There is nothing more annoying than trying to understand code that is impossible to read. Different developers have different ways of writing code and these differences cost time when new developers to a project need to understand whats going on.

One practice that I push developers on my teams to follow is to write code so that it seems like one developer wrote it. I have come across a best practice document, idiomatic, that many developers and myself use.

To add this to your Eclipse environment:

  1. Go to Windows -> Preferences -> JavaScript -> Code Style -> Formatter
  2. Click Import and navigate to the idiomatic.xml file (attached in email)
  3. Click Apply then Ok

To apply the filter on your page you can press Ctrl+Shift+F. You can also set it up so that the filtering happens automatically on save. To do this:

  1. Go to Windows -> Preferences -> JavaScript -> Code Style -> Editor -> Save Actions
  2. Check the first 2 checkboxes

You can download it here: idiomatic.xml

5 Comments

  1. Please could i get a copy of “idiomatic.xml”. I would like to use it in Eclipse. Thanks.

  2. Anish – I just uploaded my version of idiomatic.xml. Though I thought you should be able download it from the Git website.

  3. I looked for it on github, but there is only practices documentation, no xml file.

    • Please click the link in this post for idiomatic.xml to get my version. I don’t know why the link on GitHub doesn’t have the xml file anymore

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>