Code review comments

I enjoy code reviews, especially if it's with colleagues I've been a mentor to. This is a list of linkable comments for past, present or feature mentees.

Note - Our team works asynchronously in very different time zones, so the comments are more detailed. In distributed teams, I've found that targeted over-sharing can be productive.



There is a TypeScript string enum in the codebase that houses various attribute selectors used for Cypress tests:

export enum DataCySelectors {
  modal_title = 'modal-title'

and the author creates a new property, submit_button_modal.


Change submit_button_modal to modal_button_submit. Some reasons why we have this convention (largest context to smallest, left to right) are:

DRY integration tests


The author creates a generically named utility function that is called in more than one test in an effort to make tests more DRY.


Consider how to improve the ergonomics of these test utility functions. For example, the name of this function is selectProduction but looking at the function declaration, it can/should only be used in the dashboard. A couple options for how to do this:

export const CyDashboardUtil = {

and use it l like:

import { CyDashboardUtil } from '../utils';

it('should do something', () => {
  // The rest of your test

For clarity, I think a healthy convention for us is to think of custom Cypress commands as fragments of functionality that can be used in all tests, whereas these utils are fragments of functionality that can be used in a subsection of tests.

Before creating either a custom command or a util, it's a good idea to carefully consider the tradeoffs (which I think you've done a good job of in these later commits). For example, if (and when) this test breaks:

If after all these considerations you think it's still worth it, then go ahead. Keep in mind though that the best tests are easy to read with no prior context and quick to fix, so extracting stuff out can easily throw a wrench in those goals.



After a series of reviews that require changes, the author has added multiple commits and merged another branch into his.


Can you rebase your branch on canary please, it's hard to see which changes are yours.

You may know how to do this already, but just in case here are the steps:

  1. git checkout master, then git pull to get the latest master changes
  2. git checkout [your-branch-name], then git rebase -i master and follow the prompts
  3. When done, git branch to make sure you're still on your branch, then git push -f to overwrite your old remote branch history with your newly squashed branch history

When rebasing you should:

If you screw up in the middle of it (we all do this), you can close the terminal, open a new one and git rebase --abort to undo everything. If you're especially worried you can always make a local duplicate of your branch before rebasing as backup (your history will still be on your remote branch until you force push but sometimes its helpful to have insurance).

You can also do this whole process with whatever git client you use but I like the built in interactive cli rebase.

Destructuring variables


A variable is declared:

const comment = ['Some comment text'];

and later referenced with comment[0].


Consider how we can make these local variables more convenient to use. If there will be only one value you can initialize the variable with a string value, but if you expect there to be more than one value you can communicate more clearly by using specifically named variables (instead of having to reference it like comment[0]). Some options:

const comment = {
  someUsefulKeyName1: 'First comment',
  someUsefulKeyName2: 'Second comment',

and reference like comment.someUsefulKeyName1, or the fancy destructured way:

const { someUsefulKeyName1, someUsefulKeyName2 } = {
  someUsefulKeyName1: 'First comment',
  someUsefulKeyName2: 'Second comment',

and use the properties directly (someUsefulKeyName1).

const [someUsefulKeyName1, someUsefulKeyName2] = ['First comment', 'Second comment'];

Keep in mind though that unlike object destructuring, array destructuring depends on the order of the array items. This makes it generally less used.

Thanks for reading! Go home to see other notes.