It can be very helpful to follow the DHIS2 style to ensure that you write clean, readable, and functional code for your DHIS2 applications.
It also installs git hooks with husky which will automatically check your code style before making a
d2-style as a development dependency:
yarn add @dhis2/cli-style --dev
2. Set up a pre-configured project
d2-style comes with code style for a range of presets. The preset
project/react should be a good starting point for a React project, as it adds
Run this command to automatically set up the project to follow the DHIS2 code style:
yarn d2-style install project/react
3. Set up scripts
Then, add the following scripts to
"lint": "d2-style check js && d2-style check text",
"format": "d2-style apply js && d2-style apply text"
Try out your new scripts!