# JavaScript Style Guide

**URL:** https://talk.openmrs.org/t/javascript-style-guide/5507
**Category:** Development
**Tags:** javascript, styleguides
**Created:** [March 24, 2016, 7:26pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507 "2016-03-24T19:26:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)
#### Post date: [March 24, 2016, 7:26pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/1 "2016-03-24T19:26:23Z")

</div>

For Angular we are already using [this style guide](https://github.com/rkorytkowski/angular-styleguide/blob/master/a1/README.md) (for which I’ve create [this](https://gist.github.com/psbrandt/ef876a756adb933a864e) eslint config). We should publish this as a package on `npm` and include it with the generator if the user chooses to install Angular as a dependency.

For plain JavaScript I was considering asking for suggestions and then creating a poll, but in an attempt to avoid _groupthink_, I’m going to propose that we use the [Airbnb style guide](https://github.com/airbnb/javascript). This guide well reasoned and is currently actively maintained and widely used.

Also, it includes [packages](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb), which make it easy to use and to override specific rules if we don’t like them.

If anyone has any objections, let’s discuss them here.

![](https://omrs-shields.psbrandt.io/custom/js/linting/009384?logo=openmrs)

---

<div class="post-metadata">

### Author: ![r0bby](https://talk.openmrs.org/user_avatar/talk.openmrs.org/r0bby/32/6479_2.png) [@r0bby](https://talk.openmrs.org/u/r0bby)
#### Post date: [March 24, 2016, 8:42pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/2 "2016-03-24T20:42:18Z")

</div>

We should standardize on airbnb’s style guide (I’m gonna work on bringing dashboard’s codebase in line with it) – as well as post GSoC, migrating us away from ES5.

---

<div class="post-metadata">

### Author: ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)
#### Post date: [March 24, 2016, 9:19pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/3 "2016-03-24T21:19:10Z")

</div>

From peeking at the airbnb style guide I think that some of its recommendations require ES6. Is that correct, and is that something we want?

I guess that for OWAs that we start writing now, the answer can be yes, but that implies it would be difficult to apply this to our existing javascript codebase, e.g. in the uicommons module.

---

<div class="post-metadata">

### Author: ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)
#### Post date: [March 24, 2016, 9:21pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/4 "2016-03-24T21:21:57Z")

</div>

They do have an [ES5 version](https://github.com/airbnb/javascript/tree/master/es5) and [legacy package](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).

---

<div class="post-metadata">

### Author: ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)
#### Post date: [March 24, 2016, 9:57pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/5 "2016-03-24T21:57:23Z")

</div>

I found [this eslint plugin](https://www.npmjs.com/package/eslint-plugin-angular) that implements the Angular style guide we are using. I’ll add it to [the concept dictionary OWA](https://github.com/rkorytkowski/openmrs-owa-conceptdictionary) so we can try it out.

---

<div class="post-metadata">

### Author: ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)
#### Post date: [April 1, 2016, 8:55pm UTC](https://talk.openmrs.org/t/javascript-style-guide/5507/6 "2016-04-01T20:55:41Z")

</div>

I took the liberty of documenting (my proposal for) the style recommendations on [this wiki page](https://wiki.openmrs.org/display/projects/JavaScript+Ecosystem#JavaScriptEcosystem-StyleGuide). Everyone is free to edit the page or discuss here.
