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

Upgrade to use Node.js 20 and bump npm dependencies #2517

Merged
merged 16 commits into from
Aug 23, 2024

Conversation

eason9487
Copy link
Member

@eason9487 eason9487 commented Aug 9, 2024

Changes proposed in this Pull Request:

Closes #2002

This PR:

  • Bump npm dependencies and upgrade to use Node.js v20.
  • Fix the build config of Fast Refresh mode.
  • Address Sass deprecation warnings.
  • Turn off a few eslint rules:
    • react/react-in-jsx-scope rule
    • jsdoc/check-line-alignment rule
    • import/no-named-as-default rule
  • Resolve eslint errors: (💡 It would be easier to review the changes by individual commits)
  • Automatically fixed errors by running npm run lint:js -- --fix: c41ef64
  • @wordpress/i18n-text-domain rule: cdd9aab
  • jsdoc/no-undefined-types rule: 67ef0e2
  • import/no-unresolved rule: c4db2a3
  • no-redeclare rule: 6997b6f
  • jsdoc/require-yields-check rule: 47d1f9f
  • @typescript-eslint/no-use-before-define rule: 9886344
  • jsdoc/tag-lines rule: fccc0cd

❗ Since the jest testing requires a lot of adjustments, it will be handled by #2544. Two of the eslint rule errors are highly related to jest and are therefore handled by #2544 as well.

Detailed test instructions:

  1. Set Node.js to v20
  2. Run npm install to see if it can finish without errors
  3. Check if the following scripts work well
  4. Run node ./node_modules/.bin/bundlewatch to check if the check works
  5. Do some smoke testing

Changelog entry

Dev - Upgrade to use Node.js 20 and bump npm dependencies.

@eason9487 eason9487 self-assigned this Aug 9, 2024
@github-actions github-actions bot added the changelog: dev Developer-facing only change. label Aug 9, 2024
@eason9487 eason9487 marked this pull request as ready for review August 19, 2024 11:02
@eason9487 eason9487 requested a review from a team August 19, 2024 11:02
@eason9487 eason9487 linked an issue Aug 19, 2024 that may be closed by this pull request
4 tasks
@puntope
Copy link
Contributor

puntope commented Aug 21, 2024

Address Sass deprecation warnings.

I still see the deprecations in both this PR and in #2544

Screenshot 2024-08-21 at 14 04 13

@eason9487
Copy link
Member Author

eason9487 commented Aug 21, 2024

Hi @puntope

I still see the deprecations in both this PR and in #2544

The SCSS styles that caused deprecations came from @wordpress/base-styles and could not be resolved from this repo.

Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

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

Howdy @eason9487 I tested all the scripts, code and did several smoke testing:

  • Onboarding
  • Edit campaigns
  • Create rules in attribute mapping
  • Campaign assets

Everything is working fine without errors so far.

I just left some comments regarding one CSS and just to be sure dependabot is compatible with the new node version.

Comment on lines -16 to +19
@include placeholder;

display: inline-block;
width: 18em;

@include placeholder;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary? I wonder if placeholder includes display or width props. Then it will be overrided

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this change necessary?

The change fixes a Sass deprecation warning. The explanation can be found in https://sass-lang.com/documentation/breaking-changes/mixed-decls/

image

I wonder if placeholder includes display or width props. Then it will be overrided

They don't have. Please refer to:

@mixin placeholder($lighten-percentage: 30%) {
animation: loading-fade 1.6s ease-in-out infinite;
background-color: $gray-100;
color: transparent;
&::after {
content: "\00a0";
}
@media screen and (prefers-reduced-motion: reduce) {
animation: none;
}
}

@@ -2,6 +2,7 @@
* External dependencies
*/
import { useRef } from '@wordpress/element';
import { Form } from '@woocommerce/components';
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if it's worth it to import the component just for the docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

The main difference is the code editor's reference hints will be better, apart from that there shouldn't be any difference. So it should be worth it.

Without import

image

With import
image

Comment on lines -174 to -175
"node": "^16 || ^18",
"npm": "^8 || ^9"
Copy link
Contributor

Choose a reason for hiding this comment

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

So I assume dependabot now supports

"node": "^20", and "npm": "^10"

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this!

I thought dependabot would use paired node and npm versions. Surprisingly, it's using unpaired Node.js 20 and npm 9. Even the npm version claimed by its error message is incorrect, bringing more confusion.

Dependabot uses Node.js v20.17.0 and NPM 10.8.2. Due to the engine-strict setting, the update will not succeed.

Fixed in b2a3d13

.eslintrc.js Outdated
'jest/expect-expect': [
'warn',
{ assertFunctionNames: [ 'expect', 'expect[A-Z]\\w*' ] },
],
// Turn it off temporarily because it involves a lot of re-alignment. We can revisit it later.
'jsdoc/check-line-alignment': 'off',
// The JS package `tracking-jsdoc` changes the definition of the `@fires` tag.
Copy link
Contributor

@puntope puntope Aug 22, 2024

Choose a reason for hiding this comment

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

Can you elaborate what do you mean by this?

The JS package tracking-jsdoc changes the definition of the @fires tag.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adjusted the code comment in c76514b. Let me know if it's still not clear enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

I will just write "Listing our event names to avoid eslint false alarms"

But not a blocker tho.

@eason9487
Copy link
Member Author

Hi @puntope, thanks for the review! This PR is ready for a new round of code reviews.

@eason9487 eason9487 requested a review from puntope August 23, 2024 04:16
Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

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

✅ LGTM

Thanks for the changes and all your work here

@eason9487 eason9487 merged commit 7316de3 into dev/use-nodejs-20 Aug 23, 2024
3 of 5 checks passed
@eason9487 eason9487 deleted the dev/2002-use-nodejs-20 branch August 23, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: dev Developer-facing only change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Node 20
2 participants