x-govuk/govuk-form-builder

Idea: Provide a set of custom linters for Rubocop

Opened this issue · 1 comments

On Apply, we’re looking to implement a number of custom linters for Rubocop to check for standard Rails helpers being used instead of GOV.UK specific ones, i.e. here’s one to check that we’re using f.govuk_submit instead of f.submit: DFE-Digital/apply-for-teacher-training@a21ba48

Given this project supersedes a number of rails form helpers, was wondering whether it might be a good idea for it to supply a set of similar cops to lint against forms that don’t use the correct form helpers?

This is an interesting idea and definitely worth consideration. There are some things, like link_errors that would really benefit from linting, loads of people forget it.

I have no experience in writing or modifying cops and I suspect it gets quite complicated once you go beyond the basic "don't use that method, use this one" variety. Also disabling overbearing ones within template files is cumbersome - in places where you might want a particular form to have a different non-GOV.UK style one, like for a search box or filter.

I'll have a think about how best to approach it and will keep an eye on the cops I your project which will probably form the basis of anything that 's added. Thanks for the suggestion.