Proof read changes to prevent accidentally deleting code

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dumb-mistakes-and-gotchas category.

Last Updated: 2024-04-25

I was burning the midnight oil on Project S and in one commit, I accidentally deleted a function that was in use.

function bookAppointment(data, apiToken) {
   return postToApi(data, apiToken)
}

There was no good reason for this deletion. It was probably because my fingers slipped in vim and triggered some macro of destruction. But these things happen. What I could have done better was sticking to the discipline of proof-reading each set of changes, line-by-line, before committing. Instead my client was affected by the bug at 1.30 am on a Friday night, probably fuming.