Our recommended linter is ESLint. This is what our Stickler configuration uses.

Running ESLint locally

The best time to find out about a code error (or stylistic faux pas) is when you type it out. For this reason, you should run a linter locally.

# Install it through npm:
$ npm install -g eslint

# Try it out locally if you like
$ eslint path/to/file.js


PyCharm has different ways of setting this up depending on the version.

If you get errors you may need to downgrade ESLint to version 5. This appears to be an issue on all versions of PyCharm prior to 2019.1.3.



Install NeoMake if you haven’t already.

let g:neomake_javascript_enabled_makers = ['eslint']


Install syntastic if you haven’t already.

let g:syntastic_javascript_checkers = ['eslint']

Configuring our lint rules

The .eslintrc.js file in the root of the commcare-hq repository defines the rules to check.

While this configuration is fairly stable, see the docs for help should you need to update it.

Looking up rules

Let’s say you ran eslint on this code

var obj = {
    foo: 3,
    foo: 5

You’d probably get an error like:

Duplicate key ‘foo’. (no-dupe-keys)

The rule then is no-dupe-keys. You can look it up on the rules page for a description.

Adding an exception

A foolish consistency is the hobgoblin of simple minds. Sometimes it IS okay to use console.log. Here are a couple ways to say “yes, this IS okay”.

console.log('foo'); // eslint-disable-line no-console

// eslint-disable-next-line no-console

See the docs for more options to disable rules for on a case by case basis.