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

Update dependencies + fix breaking changes #2937

Merged
merged 11 commits into from
Oct 24, 2022
Merged

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Oct 21, 2022

The following package updates have been applied:

Breaking changes

Cheerio no longer encodes non-ASCII characters so .html() is now true to the HTML source. You'll see various test changes for ', ", £ etc replaced with ', ", £ as Nunjucks renders them

cheerio^1.0.0-rc.12

Major but compatible

No breaking changes

glob^8.0.3
jest-axe^6.0.0
puppeteer^19.1.0
yargs^17.6.0

Compatible

Minor and patch semver-compatible changes

@babel/core^7.19.6
@percy/cli^1.12.0
babel-jest^29.2.1
cookie-parser^1.4.6
eslint-plugin-jsdoc^39.3.14
eslint-plugin-promise^6.1.1
express^4.18.2
express-validator^6.14.2
govuk_frontend_toolkit^9.0.1
gulp-task-listing^1.1.1
jest^29.2.1
jest-environment-jsdom^29.2.1
map-stream^0.0.7
marked^4.1.1
nodemon^2.0.20
outdent^0.8.0
stylelint^14.14.0
undici^5.11.0
ws^8.9.0

Incompatible

Intentionally pinned back to older (not latest) minor/patch versions

html-validate7.5.0
rollup0.56.5

Intentionally ignored until we use ESM by default

del^7.0.0 – ESM export only, we need CommonJS
slash^5.0.0 – ESM export only, we need CommonJS

Intentionally ignored due to other major breaking changes

autoprefixer^10.4.12 – Breaks IE8 PostCSS plugins
cssnano^5.1.13 – Breaks IE8 PostCSS plugins
jquery^3.6.1 – Breaks IE8 support, required by legacy toolkits
gulp-better-rollup^4.0.1Incompatible rollup peerDependency

Added

Previously missing and only available as a child dependency

nunjucks^3.2.3

govuk-frontend-repository@ /path/to/project/govuk-frontend
└─┬ sassdoc@2.7.4
  └─┬ sassdoc-theme-default@2.8.3
    └── nunjucks@3.2.2

Removed

These packages were either unused or not needed

@percy/logger
expect-puppeteer
gulp-eol
fsevents

@colinrotherham colinrotherham requested a review from a team as a code owner October 21, 2022 16:22
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 21, 2022 16:22 Inactive
@colinrotherham colinrotherham added dependencies Pull requests that update a dependency file Frontend squad labels Oct 21, 2022
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 21, 2022 16:33 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we capture a bit more info (or the failing test output?) in the commit message for 9ab8926? I didn't really understand what the problem was until I tried to install 7.6.0 locally.

@@ -100,7 +100,7 @@ const getComponentData = async (componentName) => {
/**
* Load all components' data
*
* @returns {Promise<ComponentData>[]} Components' data
* @returns {Promise<ComponentData[]>} Components' data
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an array of promises, it's a promise that resolves to an array

@@ -73,7 +73,7 @@ function callMacro (macroName, macroPath, params = [], callBlock = false) {
* @param {object} options - options to pass to the component macro
* @param {string} [callBlock] - if provided, the macro is called using the
* Nunjucks call tag, with the callBlock passed as the contents of the block
* @returns {import('cheerio')} a jQuery-like representation of the macro output
* @returns {import('cheerio').CheerioAPI} a jQuery-like representation of the macro output
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They've shuffled their types around in the latest update

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 21, 2022 16:43 Inactive
@@ -120,7 +120,7 @@ examples:
hidden: true
data:
titleText: There is a problem
descriptionText: See errors below ()
descriptionText: See errors below (>)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this character > as it wasn't actually something that Nunjucks would escape. We'll now see >&gt; which asserts that HTML is escaped

@@ -310,23 +310,23 @@ describe('Input', () => {

const $prefix = $('.govuk-form-group > .govuk-input__wrapper > .govuk-input__prefix')

expect($prefix.html()).toEqual('&#xA3;')
expect($prefix.html()).toEqual('£')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely didn't have £ as &#xA3; in the HTML

(Confirmation that it was cheerio@1.0.0-rc.3 encoding things it shouldn't)

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 21, 2022 16:56 Inactive
Base automatically changed from postcss-config-remove-oldie to main October 21, 2022 16:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 21, 2022 17:16 Inactive
@domoscargin domoscargin self-requested a review October 24, 2022 10:45
Includes `nunjucks` as strangely we never installed it
Ensures that `.html()` now contains the original HTML rather than incorrectly-encoded safe text that differed to the source

Fix made in https://github.com/cheeriojs/cheerio/releases/tag/v1.0.0-rc.4

“We will no longer encode non-ASCII characters by default.”
Avoids issue where Cookie Banner “full banner hidden” example fails HTML validation for:

1. Rule: empty-heading
https://html-validate.org/rules/empty-heading.html
“<h2> cannot be empty, must have text content”

2. Rule: wcag/h30
https://html-validate.org/rules/wcag/h30.html
“Anchor link must have a text describing its purpose”

Both issues appear to be because `html-validate@7.6.0` thinks we’ve hidden the heading and link text in a non-accessible way:

https://gitlab.com/html-validate/html-validate/-/commit/41ba7f9c4bb25bc543d66010331a0577d4c8f534
Due to package updates `rollup@0.56.5` can now be hoisted
We’re not using any of the Jest assertions
Primarily used to add new lines to HTML in #106 but isn’t needed anymore
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 24, 2022 12:58 Inactive
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Oct 24, 2022

Can we capture a bit more info (or the failing test output?) in the commit message for 9ab8926? I didn't really understand what the problem was until I tried to install 7.6.0 locally.

Thanks @36degrees, mind having a look now? 6d144b0

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 24, 2022 13:13 Inactive
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Oct 24, 2022

We had another dependency update to eslint-plugin-jsdoc:
https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.24

It now understands @returns {undefined | boolean} union types etc

This means we no longer need JSDoc @returns code changes

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 24, 2022 13:50 Inactive
@domoscargin
Copy link
Contributor

domoscargin commented Oct 24, 2022

Ignore me - was comparing the wrong things

@36degrees
Copy link
Contributor

Are the last two commits (1ed6172, aa59153) what you intended?

They have very similar commit messages and your last comment suggests you might have intended to remove the changes in 1ed6172.

@@ -60,7 +60,6 @@
"govuk-elements-sass": "3.1.3",
"gulp": "^4.0.2",
"gulp-better-rollup": "3.1.0",
"gulp-eol": "^0.2.0",
Copy link
Contributor

@domoscargin domoscargin Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, the changes from #106 for HTML files no longer happen, and the existing use of this just adds a line to some JS files (like dist/assets/govuk-frontend-4.3.1.min.js, for example), correct? In which case, our .gitattributes settings make this redundant, hence the removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was primarily whether we're still worried if a final line ending is missing or not?

I didn't think it was worth keeping an old Gulp package around

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree!

@domoscargin
Copy link
Contributor

If I run npm-check-updates, there's some compatible changes:

 body-parser           ^1.18.3  →   ^1.20.1
 eslint                ^8.25.0  →   ^8.26.0
 eslint-plugin-jsdoc  ^39.3.14  →  ^39.3.24

Are there reasons not to include these?

Latest ESLint plugin understands `@returns {undefined | false}` union types etc
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2937 October 24, 2022 14:43 Inactive
@colinrotherham
Copy link
Contributor Author

@domoscargin Yeah we have those ones already

npm ls body-parser
npm ls eslint
npm ls eslint-plugin-jsdoc

They got picked up by npm update so the semver range hasn't updated

Shall I update them if it helps explain that an update has gone in?

@colinrotherham
Copy link
Contributor Author

Are the last two commits (1ed6172, aa59153) what you intended?

They have very similar commit messages and your last comment suggests you might have intended to remove the changes in 1ed6172.

@36degrees Ah thanks no. I've dropped the commit—it wasn't needed after all.

There was a momentary panic + git dance after yesterday's eslint-plugin-jsdoc@39.3.23 breaking changes were then fixed by eslint-plugin-jsdoc@39.3.24. Landed just as I'd changed some code 🙈

Conditional undefined returns are detected once more via gajus/eslint-plugin-jsdoc#925

@domoscargin
Copy link
Contributor

@domoscargin Yeah we have those ones already

npm ls body-parser
npm ls eslint
npm ls eslint-plugin-jsdoc

They got picked up by npm update so the semver range hasn't updated

Shall I update them if it helps explain that an update has gone in?

Might be neatness for neatness sake, but I wouldn't mind them being updated.

@colinrotherham
Copy link
Contributor Author

@domoscargin All sorted 👍

Running npm outdated now gives:

Package             Current  Wanted   Latest  Location                         Depended by
autoprefixer          9.8.8   9.8.8  10.4.12  node_modules/autoprefixer        govuk-frontend
cssnano              4.1.11  4.1.11   5.1.13  node_modules/cssnano             govuk-frontend
del                   6.1.1   6.1.1    7.0.0  node_modules/del                 govuk-frontend
gulp-better-rollup    3.1.0   3.1.0    4.0.1  node_modules/gulp-better-rollup  govuk-frontend
html-validate         7.5.0   7.5.0    7.7.0  node_modules/html-validate       govuk-frontend
jquery               1.12.4  1.12.4    3.6.1  node_modules/jquery              govuk-frontend
rollup               0.56.5  0.56.5    3.2.3  node_modules/rollup              govuk-frontend
slash                 3.0.0   3.0.0    5.0.0  node_modules/slash               govuk-frontend

I've updated the PR description to explain the other ignored major packages: #2937 (comment)

Most interesting are del and slash which we could use if we default task scripts to ESM

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we capture a bit more info (or the failing test output?) in the commit message for 9ab8926? I didn't really understand what the problem was until I tried to install 7.6.0 locally.

Thanks @36degrees, mind having a look now? 6d144b0

Thanks, that's great 👍🏻 Changes all look good to me, but I would like @domoscargin to approve as well before this is merged, given he's also flagged a few things.

Copy link
Contributor

@domoscargin domoscargin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good for me locally on this. No obvious diff oddities, the scripts seem to run fine.

Nice!

@colinrotherham
Copy link
Contributor Author

Fab, thanks @domoscargin + @36degrees

Wonder if configuring dependabot.yaml allow: all would help keep us up to date?

Rather than just the default security updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
Development

Successfully merging this pull request may close these issues.

4 participants