@dhis2/code-styledeprecated

The JavaScript code style for DHIS2.

Usage no npm install needed!

<script type="module">
  import dhis2CodeStyle from 'https://cdn.skypack.dev/@dhis2/code-style';
</script>

README

code-style

Packages Compatible Conventional Commits

DHIS2 JavaScript code style

Applies our configuration for:

  • Git commit messages
  • Prettier
  • Browserslist

Usage

Yarn

yarn add -D @dhis2/code-style

NPM

npm install --save-dev @dhis2/code-style

Add script

Add this to package.json in the script part:

{
    scripts: {
        "format": "code-style"
    }
}

Add pre-commit hook for commit-style

Install Husky or other hook handler:

npm install husky --save-dev

Add prop to package.json:

"husky": {
    "hooks": {
        "commit-msg": "commit-style",
        "pre-commit": "code-style"
    }
}

Run the format script to apply our common JS standards.

Migrating from custom configs

Existing configuration in e.g. .prettierrc, et. al. can be removed as they will be overridden by the configuration bundled with code-style anyway.

Any dependencies to Prettier can also be removed.

Works with CRA (with or without ejecting).