In my last article I talked about ESLint, why to use it, and how to set it up for your project. I am going to focus now specifically on OpenStack and the ESLint style guidelines that have been created by the community under the project name eslint-config-openstack with the vision of maintaining consistent code across OpenStack as a whole.

OpenStack is a very large code base, spanning dozens of git trees, with over a thousand developers contributing every 6 months. As such, common style helps developers understand code in reviews, move between projects smoothly, and overall make the code more maintainable.

One of the beauties of ESLint is that, despite there being one standardised set of rules created for OpenStack, ESLint permits the overriding of these rules on a per-project basis to ensure that no project is hindered by a generalised decision and projects do not have to forgo the use of eslint-config-openstack due to fears of these restrictions. Saying this however, the point of having these standardisations may be slightly defeated if the aim is not to stay as close to the common guidelines as possible.

Installing eslint-config-openstack in your project

To add these rules to your project, follow these steps.

1. Install the npm package to your project:

npm install --save-dev eslint eslint-config-openstack

2. Add extends: "openstack" to your ‘.eslintrc’ yaml file. If your project is using ES2015, add extends: openstack/es2015" instead.

…And that’s it! You are all set up to use ESLint in your project. If you want to be a bigger part of the decisions that are made to eslint-config-openstack rather than having to customise the rules to your project locally, the project can always have new patches submitted and feedback on existing changes that are in review to become part of the main project.

For more information see:
https://github.com/openstack/eslint-config-openstack
https://review.openstack.org/#/q/project:openstack/eslint-config-openstack+status:open

Connect ESLint to your project - photo credit: https://pixabay.com/en/t-for-two-together-partnership-1723941/

Pin It on Pinterest

Share This