Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate prettier #832

Merged
merged 12 commits into from
Aug 3, 2022
Merged

Integrate prettier #832

merged 12 commits into from
Aug 3, 2022

Conversation

wa-rren-dev
Copy link
Contributor

@wa-rren-dev wa-rren-dev commented Jul 22, 2022

This is a somewhat nuclear operation to completely reformat based on Prettier's defaults.

This enforces tabs across both CSS and JS. Some reading suggests that tabs are more accessible for developers who use assistive tech. There are some thoughts on that here:

There's nothing touching Nunjucks files at present.

JS (Eslint)

  • Removes eslint-config-nhsuk as a dependency. Eslint rules follow airbnb-base (changed from airbnb-base/legacy then prettier/recommended

CSS (Stylelint)

  • Extends stylelint-config-prettier which disables rules that directly interfere with Prettier
  • From the existing rules, removal of one that directly interfere with Pretter

Other files

Formats all other files that fall outside of the prettier ignore, namely

  • node_modules/*
  • dist/*
  • tests/backstop/*
  • .github/*
  • coverage/*

This includes previously untouched files such as:

  • the markdown files
  • the tooling files (jest.config.js, gulpfile.js etc)
  • the tests/ folder
  • the linting configs themselves

- with a cheeky change to tab
@wa-rren-dev wa-rren-dev changed the title Copied in suggested formatting config Integrate prettier Jul 22, 2022
@andymantell
Copy link
Contributor

Good work! A few things though:

  • package.json and package-lock.json shouldn't be formatted by prettier - they should be left alone. They will be rewritten by npm and it'll make for a ton of unnecessary and untidy diffs in these files
  • Prettier really makes a mess of some bits of html, for example:

image
image

Could we see if any of Prettier's config might tidy this up? E.g. https://prettier.io/docs/en/options.html#bracket-line

@wa-rren-dev
Copy link
Contributor Author

Cheers @andymantell - absolutely with you on package.json and package-lock.json.

So setting the following in the Prettier config sort this.

module.exports = {
	bracketSameLine: true,
	htmlWhitespaceSensitivity: "ignore",
};

However, seems like that raises a small risk of issues with HTML whitespace. The rediculous-looking version provides consistency of HTML whitespace.

My angle would be to go with the suggested settings above. I don't personally think whitespace rendering issues are common now outside of JSX but would be interested on other opinions.

I'll push up a version with the config for a gander at how that would look.

@wa-rren-dev
Copy link
Contributor Author

I don't personally think whitespace rendering issues are common now outside of JSX but would be interested on other opinions.

Actually I'll see if backstop agrees with me before saying that.

@wa-rren-dev wa-rren-dev marked this pull request as ready for review August 1, 2022 16:16
@wa-rren-dev wa-rren-dev merged commit 9fe8ab2 into alpha-v7 Aug 3, 2022
@wa-rren-dev wa-rren-dev deleted the alpha/formatting-config branch August 3, 2022 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants