In general, follow the standards set out in the GOV.UK styleguide.
2-space, soft-tabs only. No trailing whitespace.
See our coding standards for CSS and testing.
Javascript is written using StandardJS.
See our coding standards for components, coding standards for Nunjucks macros and testing.
ESLint is used to lint JavaScript code and keep a consistent standard in the way it is written within this project.
The config uses the StandardJS style as a base with some custom tweaks.
Prettier is also used to extend eslint to add some extra rules around how files are formatted. It can be integrated to many popular editors to help with formatting on save.
To check linting results run:
npm run lint
EditorConfig is also used help IDEs apply consistent formatting. There is no equivalent npm
task for this, as these issues would normally be picked up by the existing linting tasks.
Commitlint is used to lint commit messages to ensure they conform to conventional convention.
This requires commit messages of the format:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
This convention is required to automate the generation of changelogs and release notes on GitHub during the release process.
This also means that smaller atomic commits are preferred wherever possible to one large commit with a lot of changes.