Skip to content

Latest commit

 

History

History
59 lines (32 loc) · 2.16 KB

coding-standards.md

File metadata and controls

59 lines (32 loc) · 2.16 KB

Coding Standards & Code Linting

Conventions to follow

Style, spelling and grammar

In general, follow the standards set out in the GOV.UK styleguide.

Code indentation and whitespace

2-space, soft-tabs only. No trailing whitespace.

CSS

See our coding standards for CSS and testing.

JavaScript

Javascript is written using StandardJS.

Components and Nunjucks API

See our coding standards for components, coding standards for Nunjucks macros and testing.

Linting

JavaScript

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.

Commit messages

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.