Organization-wide JS styleguide

Hey all,

I was just thinking, do we have a project-wide styleguide that we can apply and consequently fail with CI – so that we don’t deploy code with CI that doesn’t meet those guidelines – in fact we could have a hook that even doesn’t allow people to push their code to github if they don’t meet those guidelines. I wanted to set it up for ID Dashboard, but it could have value across ALL projects, is there a way to do this for all projects?

1 Like

I don’t recall any prior “formal” discussions on JavaScript style conventions beyond discussion on the 2014-06-26 Dev Forum and what is mentioned on the JavaScript Conventions page.

1 Like

I’d like to set up a linter to run in a commit hook which will disallow pushing if there are any style violations…but would rather not just make it up without getting community input :slight_smile: I’d like something formalized – if we set up up CI – I think this should happen as well.

I suggest that you start by trying to set this up for a specific project (e.g. ID Dashboard).

The OpenMRS codebase has lots of existing javascript that follows no particular style guide at all, and people should be able to push changes to existing files without having to rewrite their JS.

Once you have a proposed JS style we can consider whether this makes sense across the rest of the OpenMRS codebase, and whether it’s worth the effort to clean up existing code to be compliant.

(The main point is making sure that we have a style that we agree on. Setting up a trigger to check that style is just an implementation detail.)

2 Likes

Sounds decent :slight_smile:

1 Like

At AMPATH we have adapted This style for our angular JS application. If it is something acceptable, it could be adapted for general JS programming.

2 Likes

Do you have a linter which can enforce this? In addition to this, I have been hesitant to learn angular due to the uncertainty regarding the (lack of) migration path from Angular 1.x to 2.x.

@r0bby sorry for a late response, yes I do use linter to enforce this style even though I am still learning to use it effectively.

Cheers.

1 Like

holy moly, that was a late response :stuck_out_tongue: – it’s all good :slight_smile:

1 Like