<commit_before>import { App, BrowserWindow, dialog, Event as ElectronEvent } from "electron"
import { saveTranscript } from "./saveFile"
import { getAppState, setAppState } from "../common/appState"

export const rememberToSaveBeforeClosing = (window: BrowserWindow, app: App) => {
  window.on("close", (event: ElectronEvent) => {
    setAppState("userWantsToQuit", true)
    event.preventDefault()
    dialog.showMessageBox(
      window,
      {
        buttons: ["Save, Then Quit", "Go Back to Editing", "Quit Without Saving"],
        cancelId: 1,
        type: "question",
        defaultId: 0,
        title: "Going so soon?",
        message: "Do you want to save your changes before quitting?",
      },
      (response: number, checkboxChecked: boolean) => {
        if (response === 0) {
          saveTranscript(window, getAppState("transcript"), () => {
            if (getAppState("userWantsToQuit") === true && getAppState("safeToQuit") === true) {
              app.exit()
            }
          })
        } else if (response === 1) {
          return null
        } else if (response === 2) {
          app.exit()
        }
      },
    )
  })
}<commit_msg>Fix linting errors in saveBeforeClosing<commit_after>import { App, BrowserWindow, dialog, Event as ElectronEvent } from "electron"
import { saveTranscript } from "./saveFile"
import { getAppState, setAppState } from "../common/appState"

export const rememberToSaveBeforeClosing = (
  window: BrowserWindow,
  app: App,
): void => {
  window.on(
    "close",
    (event: ElectronEvent): void => {
      setAppState("userWantsToQuit", true)
      event.preventDefault()
      dialog.showMessageBox(
        window,
        {
          buttons: [
            "Save, Then Quit",
            "Go Back to Editing",
            "Quit Without Saving",
          ],
          cancelId: 1,
          type: "question",
          defaultId: 0,
          title: "Going so soon?",
          message: "Do you want to save your changes before quitting?",
        },
        (response: number): void => {
          if (response === 0) {
            saveTranscript(
              window,
              getAppState("transcript"),
              (): void => {
                if (
                  getAppState("userWantsToQuit") === true &&
                  getAppState("safeToQuit") === true
                ) {
                  app.quit()
                }
              },
            )
          } else if (response === 1) {
            null
          } else if (response === 2) {
            app.exit()
          }
        },
      )
    },
  )
}
{'fraction_non_alphanumeric': 0.12878497508623993, 'fraction_numerical': 0.0038328861632809506, 'mean_word_length': 1.7884615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4414484', 'n_tokens_mistral': 752, 'n_tokens_neox': 715, 'n_words': 187}