ONSdigital / design-system

ONS Design System
https://service-manual.ons.gov.uk/design-system
MIT License
28 stars 17 forks source link

Investigate the use of EditorConfig for developer settings and implement code standardisation in the DS #3169

Open rmccar opened 2 months ago

rmccar commented 2 months ago

We should investigate the use of EditorConfig within the team. This would allow us to set some standardised IDE settings for everyone that develops using this repo.

Some suggestions for settings we could look to standardise would be these recommended settings we have in the readme. Another would be to set up indenting with tabs and setting tab width to 4 spaces and automatically adding a blank newline to the end of each file.

We already have an .editorconfig file in the repo, so we should review the contents of that as part of this.

This would allow us to have some standard settings across the dev team which would lead to more a more consistent code style automatically and which would then also cut down some of the time for PRs getting reviewed.

This solution works across all popular IDE so it would even work if we had developers that preferred to use something other than VSCode. It would also still allow devs to still have their own settings for things such as the theme of the IDE, fonts, colours etc. Basically anything we don't want to standardise, we would only look to override certain settings which would be discussed and agreed by the team.

The only slight downside to this is that we would need to make sure the team all have the EditorConfig plugin installed in their VSCode for this to work. But this is very minor easily overcome and is something we could look to document in our Readme.

This ticket would be to investigate the use of this tool in the DS, produce some documentation with the findings and then present them to the dev team for discussion alongside some suggestions for settings we would want to standardise.

rmccar commented 1 week ago

After doing my investigation into EditorConfig and using that to have a discussion with the team about coding standards. We agreed on some rules we would like to follow and I implemented them for all the js, css and md files in the repo and made sure these were automatically being run on the pre commit hook. From this I realised we could use the prettier-plugin-jinja-template plugin to do the same for all our njk and html files. This then lead to a second PR to add that for those files too.