Answer the Review and Merge

Your review is on the turkey pull request, with two unresolved line comments. You also opened that pull request, so the answers are yours to give. On a team, the author is the one who responds to a review and makes the fixes.

In this lesson, you’ll switch sides and answer the review as the author. You’ll push both fixes to the same branch, reply in each thread with what fixed it, check the result once more, and merge the turkey page. Start on your laptop, where npm can remove the package the project doesn’t need.

Push the Fixes to the Same Branch

A review doesn’t need a new pull request. The pull request follows its branch, so your fixes go onto turkey-preorder, and every push updates what the reviewer sees. Check that your laptop is still on that branch:

Language: Shell
$ git status
On branch turkey-preorder
Your branch is up to date with 'origin/turkey-preorder'.

nothing to commit, working tree clean

The first comment asked you to drop moment and use dayjs. Uninstall moment, which removes it from package.json and the lockfile in one step:

Language: Shell
$ npm uninstall moment

removed 1 package, and audited 98 packages in 567ms

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Every package you don’t need is one fewer package to trust. It’s the same habit as checking a package before you install it. The turkey page still imports moment, though. Open src/turkey-page.js and change the import in line 1 and the call in line 8 to dayjs, the way src/lib/badge.js already uses it. The diff shows both lines:

Language: Shell
$ git diff src/turkey-page.js
...
-import moment from "moment";
+import dayjs from "dayjs";
 import { turkey } from "./data/turkey.js";
...
-  item.textContent = moment(day).format("dddd, MMMM D");
+  item.textContent = dayjs(day).format("dddd, MMMM D");
   days.append(item);
 }

The output is shortened here. dayjs understands the same "dddd, MMMM D" format. Run both checks, then commit the three files as one fix:

Language: Shell
$ npm run lint
npm notice run [email protected] lint
npm notice run eslint .
$ npx prettier --check .
npm notice run [email protected] npx
npm notice run 'prettier' --check .
Checking formatting...
All matched files use Prettier code style!
$ git add package.json package-lock.json src/turkey-page.js
$ git commit -m "Use dayjs instead of moment for the pickup days" \
  -m "The project already uses dayjs, so the page doesn't need a second
date library. Uninstalled moment."
[turkey-preorder afb3a34] Use dayjs instead of moment for the pickup days
 3 files changed, 4 insertions(+), 15 deletions(-)

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.