From 7f380edd0fcca00b8425dfe7e5eed5f9d4e6e712 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 17:58:07 -0300 Subject: [PATCH 01/12] Preparing commit hook to accept mjs and cjs files, avoiding deleted files --- .husky/pre-commit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 714a8ce30..cfaeacb35 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -13,7 +13,7 @@ get_changed_files() while read -d $'\0' file do echo ${file} - done < <(git diff --staged -z --name-only -- "$@") + done < <(git diff --staged -z --name-only --diff-filter=d -- "$@") } readarray -t changed_css < <(get_changed_files 'css/*.css') @@ -22,7 +22,7 @@ if [ ! -z "$changed_css" ]; then pids="$pids $!" fi -readarray -t changed_js < <(get_changed_files '*/*.js') +readarray -t changed_js < <(get_changed_files '*/*.cjs' '*/*.js' '*/*.mjs') if [ ! -z "$changed_js" ]; then npx eslint "${changed_js[@]}" & pids="$pids $!" From 39eb261232ee1613d2c8f2c128ad296095c5fd51 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 17:58:20 -0300 Subject: [PATCH 02/12] Renaming window-aux and app-config to .cjs --- __tests__/__renderer__/window-aux.js | 4 ++-- __tests__/__renderer__/workday-waiver.js | 2 +- esm-main.js | 4 ++-- js/{app-config.js => app-config.cjs} | 6 +++--- js/main-window.js | 2 +- js/menus.js | 2 +- js/{window-aux.js => window-aux.cjs} | 4 ++-- js/windows.js | 2 +- src/configs/i18next.config.js | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) rename js/{app-config.js => app-config.cjs} (96%) rename js/{window-aux.js => window-aux.cjs} (95%) diff --git a/__tests__/__renderer__/window-aux.js b/__tests__/__renderer__/window-aux.js index 6a97e0a97..25b92404d 100644 --- a/__tests__/__renderer__/window-aux.js +++ b/__tests__/__renderer__/window-aux.js @@ -3,9 +3,9 @@ const path = require('path'); const BrowserWindow = require('@electron/remote').BrowserWindow; -import * as windowAux from '../../js/window-aux.js'; +import * as windowAux from '../../js/window-aux.cjs'; -describe('window-aux.js Testing', function() +describe('window-aux.cjs Testing', function() { process.env.NODE_ENV = 'test'; diff --git a/__tests__/__renderer__/workday-waiver.js b/__tests__/__renderer__/workday-waiver.js index 353988f70..526e1a1b2 100644 --- a/__tests__/__renderer__/workday-waiver.js +++ b/__tests__/__renderer__/workday-waiver.js @@ -150,7 +150,7 @@ async function testWaiverCount(expected) expect($('#waiver-list-table tbody')[0].rows.length).toBe(expected); } -jest.mock('../../js/window-aux.js'); +jest.mock('../../js/window-aux.cjs'); describe('Test Workday Waiver Window', function() { diff --git a/esm-main.js b/esm-main.js index 7321c9d20..cfb0a9011 100644 --- a/esm-main.js +++ b/esm-main.js @@ -7,9 +7,9 @@ const { createNotification } = require('./js/notification'); const { openWaiverManagerWindow } = require('./js/windows.js'); const { setupI18n, getCurrentTranslation, setLanguageChangedCallback } = require('./src/configs/i18next.config.js'); const { handleSquirrelEvent } = require('./js/squirrel.js'); -const { showAlert, showDialogSync } = require('./js/window-aux.js'); +const { showAlert, showDialogSync } = require('./js/window-aux.cjs'); -import { appConfig } from './js/app-config.js'; +import { appConfig } from './js/app-config.cjs'; import { setupCalendarStore } from './main/calendar-aux.js'; if (appConfig.win32) diff --git a/js/app-config.js b/js/app-config.cjs similarity index 96% rename from js/app-config.js rename to js/app-config.cjs index bc99ae602..9bd04707e 100644 --- a/js/app-config.js +++ b/js/app-config.cjs @@ -29,7 +29,7 @@ function getDetails() return `Version: ${version}\nElectron: ${electronVersion}\nChrome: ${chromeVersion}\nNode.js: ${nodeVersion}\nOS: ${OSInfo}`; } -export { +module.exports = { appConfig, - getDetails -}; \ No newline at end of file + getDetails, +}; diff --git a/js/main-window.js b/js/main-window.js index ae56928b9..259a0b4e2 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -18,7 +18,7 @@ const { getCurrentTranslation } = require('../src/configs/i18next.config'); let { contextMenu, tray } = require('./windows.js'); import { getDefaultWidthHeight, getUserPreferences, switchCalendarView } from './user-preferences.js'; -import { appConfig, getDetails } from './app-config.js'; +import { appConfig, getDetails } from './app-config.cjs'; import { createLeaveNotification } from './notification.js'; // Keep a global reference of the window object, if you don't, the window will diff --git a/js/menus.js b/js/menus.js index b75457db5..063e250c2 100644 --- a/js/menus.js +++ b/js/menus.js @@ -11,7 +11,7 @@ const { createNotification } = require('./notification'); const { getCurrentTranslation } = require('../src/configs/i18next.config'); let { openWaiverManagerWindow, prefWindow, getDialogCoordinates } = require('./windows'); -import { appConfig, getDetails } from './app-config.js'; +import { appConfig, getDetails } from './app-config.cjs'; import { savePreferences } from './user-preferences.js'; import { getCurrentDateTimeStr } from './date-aux.js'; diff --git a/js/window-aux.js b/js/window-aux.cjs similarity index 95% rename from js/window-aux.js rename to js/window-aux.cjs index 5a4934e1c..2e5595781 100644 --- a/js/window-aux.js +++ b/js/window-aux.cjs @@ -28,7 +28,7 @@ function showAlert(message) dialog.showMessageBoxSync(BrowserWindow.getFocusedWindow(), options); } -export { +module.exports = { showAlert, - showDialogSync + showDialogSync, }; diff --git a/js/windows.js b/js/windows.js index b2ad12192..3cabe403a 100644 --- a/js/windows.js +++ b/js/windows.js @@ -1,7 +1,7 @@ 'use strict'; const { BrowserWindow } = require('electron'); -import { appConfig } from './app-config.js'; +import { appConfig } from './app-config.cjs'; const path = require('path'); import { getDateStr } from './date-aux.js'; diff --git a/src/configs/i18next.config.js b/src/configs/i18next.config.js index 623469e80..44e7a88f3 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -4,7 +4,7 @@ const path = require('path'); const { ipcMain } = require('electron'); const config = require('../configs/app.config'); -const { appConfig } = require('../../js/app-config'); +const { appConfig } = require('../../js/app-config.cjs'); const i18nextOptions = { backend:{ From 781445c89554c36acfd8d516667d673171eea108 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 18:29:17 -0300 Subject: [PATCH 03/12] Updating renderer electron imports --- renderer/preload-scripts/calendar-api.js | 4 ++-- renderer/preload-scripts/esm-calendar-bridge.js | 4 ++-- renderer/preload-scripts/esm-preferences-bridge.js | 4 ++-- renderer/preload-scripts/esm-workday-waiver-bridge.js | 4 ++-- renderer/preload-scripts/preferences-api.js | 4 ++-- renderer/preload-scripts/workday-waiver-api.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/renderer/preload-scripts/calendar-api.js b/renderer/preload-scripts/calendar-api.js index 41b9cef8b..181c98390 100644 --- a/renderer/preload-scripts/calendar-api.js +++ b/renderer/preload-scripts/calendar-api.js @@ -1,6 +1,6 @@ 'use strict'; -const { ipcRenderer } = require('electron'); +import { ipcRenderer } from 'electron'; import * as config from '../../src/configs/app.config.js'; import { getUserPreferencesPromise, showDay } from '../../js/user-preferences.js'; @@ -88,6 +88,6 @@ const calendarApi = { computeAllTimeBalanceUntilPromise: (targetDate) => computeAllTimeBalanceUntilPromise(targetDate), }; -module.exports = { +export { calendarApi }; diff --git a/renderer/preload-scripts/esm-calendar-bridge.js b/renderer/preload-scripts/esm-calendar-bridge.js index effad1149..02e61caf0 100644 --- a/renderer/preload-scripts/esm-calendar-bridge.js +++ b/renderer/preload-scripts/esm-calendar-bridge.js @@ -1,7 +1,7 @@ 'use strict'; -const { contextBridge } = require('electron'); -const { calendarApi } = require('./calendar-api.js'); +import { contextBridge } from 'electron'; +import { calendarApi } from './calendar-api.js'; contextBridge.exposeInMainWorld( 'mainApi', calendarApi diff --git a/renderer/preload-scripts/esm-preferences-bridge.js b/renderer/preload-scripts/esm-preferences-bridge.js index 1e3c1ba9b..891cc2576 100644 --- a/renderer/preload-scripts/esm-preferences-bridge.js +++ b/renderer/preload-scripts/esm-preferences-bridge.js @@ -1,7 +1,7 @@ 'use strict'; -const { contextBridge } = require('electron'); -const { preferencesApi } = require('./preferences-api.js'); +import { contextBridge } from 'electron'; +import { preferencesApi } from './preferences-api.js'; contextBridge.exposeInMainWorld( 'mainApi', preferencesApi diff --git a/renderer/preload-scripts/esm-workday-waiver-bridge.js b/renderer/preload-scripts/esm-workday-waiver-bridge.js index 8f33e1682..943955de6 100644 --- a/renderer/preload-scripts/esm-workday-waiver-bridge.js +++ b/renderer/preload-scripts/esm-workday-waiver-bridge.js @@ -1,7 +1,7 @@ 'use strict'; -const { contextBridge } = require('electron'); -const { workdayWaiverApi } = require('./workday-waiver-api.js'); +import { contextBridge } from 'electron'; +import { workdayWaiverApi } from './workday-waiver-api.js'; contextBridge.exposeInMainWorld( 'mainApi', workdayWaiverApi diff --git a/renderer/preload-scripts/preferences-api.js b/renderer/preload-scripts/preferences-api.js index 6ade3d09d..baf6efe82 100644 --- a/renderer/preload-scripts/preferences-api.js +++ b/renderer/preload-scripts/preferences-api.js @@ -1,6 +1,6 @@ 'use strict'; -const { ipcRenderer } = require('electron'); +import { ipcRenderer } from 'electron'; import * as config from '../../src/configs/app.config.js'; import { getUserPreferencesPromise } from '../../js/user-preferences.js'; @@ -27,6 +27,6 @@ const preferencesApi = { getLanguageDataPromise: () => getLanguageDataPromise() }; -module.exports = { +export { preferencesApi }; diff --git a/renderer/preload-scripts/workday-waiver-api.js b/renderer/preload-scripts/workday-waiver-api.js index 7a9ae3671..6f45976ae 100644 --- a/renderer/preload-scripts/workday-waiver-api.js +++ b/renderer/preload-scripts/workday-waiver-api.js @@ -1,6 +1,6 @@ 'use strict'; -const { ipcRenderer } = require('electron'); +import { ipcRenderer } from 'electron'; import * as config from '../../src/configs/app.config.js'; import { getUserPreferencesPromise, showDay } from '../../js/user-preferences.js'; @@ -87,6 +87,6 @@ const workdayWaiverApi = { deleteWaiver: (key) => deleteWaiver(key) }; -module.exports = { +export { workdayWaiverApi }; From 3c58a5b6839cf17461be1fb9d198279d65c4d70d Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:06:19 -0300 Subject: [PATCH 04/12] Adding 'use strict' to all files --- __tests__/__main__/main-window.js | 2 ++ __tests__/__main__/menus.js | 2 ++ __tests__/__main__/update-manager.js | 2 ++ __tests__/__main__/windows.js | 2 ++ __tests__/__renderer__/classes/BaseCalendar.js | 2 ++ __tests__/__renderer__/classes/CalendarFactory.js | 2 ++ __tests__/__renderer__/classes/FlexibleDayCalendar.js | 1 + __tests__/__renderer__/notification-channel.js | 2 ++ js/demo-generator.js | 2 ++ js/saved-preferences.js | 1 + js/squirrel.js | 2 ++ renderer/notification-channel.js | 2 ++ src/configs/app.config.js | 2 ++ src/configs/i18next.config.js | 2 ++ tests/main-window.js | 2 ++ 15 files changed, 28 insertions(+) diff --git a/__tests__/__main__/main-window.js b/__tests__/__main__/main-window.js index 3c029a3af..0f2f690dc 100644 --- a/__tests__/__main__/main-window.js +++ b/__tests__/__main__/main-window.js @@ -1,3 +1,5 @@ +'use strict'; + const notification = require('../../js/notification.js'); const userPreferences = require('../../js/user-preferences.js'); const { savePreferences, defaultPreferences, resetPreferences } = userPreferences; diff --git a/__tests__/__main__/menus.js b/__tests__/__main__/menus.js index 943330716..b2e82f980 100644 --- a/__tests__/__main__/menus.js +++ b/__tests__/__main__/menus.js @@ -1,3 +1,5 @@ +'use strict'; + const { getContextMenuTemplate, getDockMenuTemplate, getEditMenuTemplate, getHelpMenuTemplate, getMainMenuTemplate, getViewMenuTemplate} = require('../../js/menus.js'); jest.mock('../../src/configs/i18next.config.js', () => ({ diff --git a/__tests__/__main__/update-manager.js b/__tests__/__main__/update-manager.js index 17164b50e..08bd47fd5 100644 --- a/__tests__/__main__/update-manager.js +++ b/__tests__/__main__/update-manager.js @@ -1,3 +1,5 @@ +'use strict'; + const ElectronStore = require('electron-store'); const { getDateStr } = require('../../js/date-aux'); const {shouldCheckForUpdates, checkForUpdates} = require('../../js/update-manager'); diff --git a/__tests__/__main__/windows.js b/__tests__/__main__/windows.js index 6683a795b..8ece451e4 100644 --- a/__tests__/__main__/windows.js +++ b/__tests__/__main__/windows.js @@ -1,3 +1,5 @@ +'use strict'; + const { BrowserWindow } = require('electron'); const { getDateStr } = require('../../js/date-aux.js'); const windows = require('../../js/windows.js'); diff --git a/__tests__/__renderer__/classes/BaseCalendar.js b/__tests__/__renderer__/classes/BaseCalendar.js index 2a2160b28..89ddc9fea 100644 --- a/__tests__/__renderer__/classes/BaseCalendar.js +++ b/__tests__/__renderer__/classes/BaseCalendar.js @@ -1,3 +1,5 @@ +'use strict'; + import ElectronStore from 'electron-store'; import { BaseCalendar } from '../../../renderer/classes/BaseCalendar.js'; import { generateKey } from '../../../js/date-db-formatter.js'; diff --git a/__tests__/__renderer__/classes/CalendarFactory.js b/__tests__/__renderer__/classes/CalendarFactory.js index 895734e4a..e661b77bd 100644 --- a/__tests__/__renderer__/classes/CalendarFactory.js +++ b/__tests__/__renderer__/classes/CalendarFactory.js @@ -1,3 +1,5 @@ +'use strict'; + import { CalendarFactory } from '../../../renderer/classes/CalendarFactory.js'; import { FlexibleDayCalendar } from '../../../renderer/classes/FlexibleDayCalendar.js'; import { FlexibleMonthCalendar } from '../../../renderer/classes/FlexibleMonthCalendar.js'; diff --git a/__tests__/__renderer__/classes/FlexibleDayCalendar.js b/__tests__/__renderer__/classes/FlexibleDayCalendar.js index 8f9e4aa19..7316cddee 100644 --- a/__tests__/__renderer__/classes/FlexibleDayCalendar.js +++ b/__tests__/__renderer__/classes/FlexibleDayCalendar.js @@ -1,4 +1,5 @@ /* eslint-disable no-undef */ +'use strict'; const Store = require('electron-store'); import { computeAllTimeBalanceUntilAsync } from '../../../js/time-balance.js'; diff --git a/__tests__/__renderer__/notification-channel.js b/__tests__/__renderer__/notification-channel.js index 6026fd508..394b9f534 100644 --- a/__tests__/__renderer__/notification-channel.js +++ b/__tests__/__renderer__/notification-channel.js @@ -1,3 +1,5 @@ +'use strict'; + const notificationChannel = require('../../renderer/notification-channel.js'); describe('Notifications channel', () => diff --git a/js/demo-generator.js b/js/demo-generator.js index 5f682cfb6..9d2e06f13 100644 --- a/js/demo-generator.js +++ b/js/demo-generator.js @@ -1,3 +1,5 @@ +'use strict'; + const { hourMinToHourFormatted, sumTime } = require('./time-math.js'); const { generateKey } = require('./date-db-formatter.js'); const Store = require('electron-store'); diff --git a/js/saved-preferences.js b/js/saved-preferences.js index 19d6a32d1..53d6aa13b 100644 --- a/js/saved-preferences.js +++ b/js/saved-preferences.js @@ -1,4 +1,5 @@ 'use strict'; + const { changeLanguage } = require('../src/configs/i18next.config'); const { app, ipcMain } = require('electron'); diff --git a/js/squirrel.js b/js/squirrel.js index 81bf415d2..dd9d801c0 100644 --- a/js/squirrel.js +++ b/js/squirrel.js @@ -1,3 +1,5 @@ +'use strict'; + function handleSquirrelEvent(application) { if (process.argv.length === 1) diff --git a/renderer/notification-channel.js b/renderer/notification-channel.js index b014d3198..d59e67ee5 100644 --- a/renderer/notification-channel.js +++ b/renderer/notification-channel.js @@ -1,3 +1,5 @@ +'use strict'; + const searchLeaveByElement = (event) => { const leaveByElement = $('#leave-by').val(); diff --git a/src/configs/app.config.js b/src/configs/app.config.js index 277cc279a..7852a5ef6 100644 --- a/src/configs/app.config.js +++ b/src/configs/app.config.js @@ -1,3 +1,5 @@ +'use strict'; + const languages = { 'bn':'বাংলা', 'ca': 'Catalàn', diff --git a/src/configs/i18next.config.js b/src/configs/i18next.config.js index 44e7a88f3..bf0e814b1 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -1,3 +1,5 @@ +'use strict'; + const i18n = require('i18next'); const i18nextBackend = require('i18next-node-fs-backend'); const path = require('path'); diff --git a/tests/main-window.js b/tests/main-window.js index 08a5c2300..6621fb607 100644 --- a/tests/main-window.js +++ b/tests/main-window.js @@ -1,4 +1,6 @@ // file deepcode ignore no-invalid-this: the this keyword is being used for testing purposes only in this file +'use strict'; + const Application = require('spectron').Application; const assert = require('assert'); const electronPath = require('electron'); From 65cf104f6215d3bad0596f011b34e2bfce911ec8 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:08:05 -0300 Subject: [PATCH 05/12] Switching 'fs' import to use import --- __tests__/__main__/import-export.js | 2 +- __tests__/__main__/user-preferences.js | 2 +- __tests__/__renderer__/preferences.js | 2 +- __tests__/__renderer__/user-preferences.js | 2 +- __tests__/__renderer__/workday-waiver.js | 2 +- js/import-export.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/__tests__/__main__/import-export.js b/__tests__/__main__/import-export.js index 7246a1452..1badf96ee 100644 --- a/__tests__/__main__/import-export.js +++ b/__tests__/__main__/import-export.js @@ -8,7 +8,7 @@ const { validEntry } = require('../../js/import-export'); -const fs = require('fs'); +import fs from 'fs'; const Store = require('electron-store'); const path = require('path'); diff --git a/__tests__/__main__/user-preferences.js b/__tests__/__main__/user-preferences.js index 17022a048..7d53b3035 100644 --- a/__tests__/__main__/user-preferences.js +++ b/__tests__/__main__/user-preferences.js @@ -2,7 +2,7 @@ 'use strict'; const { booleanInputs, defaultPreferences, getDefaultWidthHeight, getPreferencesFilePath, getUserPreferences, savePreferences, showDay, switchCalendarView, notificationIsEnabled, getUserLanguage, getNotificationsInterval, repetitionIsEnabled, getUserPreferencesPromise, resetPreferences } = require('../../js/user-preferences'); -const fs = require('fs'); +import fs from 'fs'; const { themeOptions } = require('../../renderer/themes'); const { getLanguageMap, getLanguagesCodes, getLanguageName } = require('../../src/configs/app.config'); diff --git a/__tests__/__renderer__/preferences.js b/__tests__/__renderer__/preferences.js index d6a0c1405..e47103e60 100644 --- a/__tests__/__renderer__/preferences.js +++ b/__tests__/__renderer__/preferences.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const fs = require('fs'); +import fs from 'fs'; const path = require('path'); const { defaultPreferences, diff --git a/__tests__/__renderer__/user-preferences.js b/__tests__/__renderer__/user-preferences.js index 5d3fb42fc..8ca4bf9e9 100644 --- a/__tests__/__renderer__/user-preferences.js +++ b/__tests__/__renderer__/user-preferences.js @@ -9,7 +9,7 @@ const { isNotBoolean, isNotificationInterval, } = require('../../js/user-preferences'); -const fs = require('fs'); +import fs from 'fs'; describe('Should return false if the value is not boolean type', () => { diff --git a/__tests__/__renderer__/workday-waiver.js b/__tests__/__renderer__/workday-waiver.js index 526e1a1b2..42f8b4456 100644 --- a/__tests__/__renderer__/workday-waiver.js +++ b/__tests__/__renderer__/workday-waiver.js @@ -2,7 +2,7 @@ 'use strict'; const Store = require('electron-store'); -const fs = require('fs'); +import fs from 'fs'; const path = require('path'); const Holidays = require('date-holidays'); /* eslint-disable-next-line no-global-assign */ diff --git a/js/import-export.js b/js/import-export.js index 3ea8e8500..8d86017a6 100644 --- a/js/import-export.js +++ b/js/import-export.js @@ -2,7 +2,7 @@ 'use strict'; const Store = require('electron-store'); -const fs = require('fs'); +import fs from 'fs'; import { validateTime } from './time-math.js'; import { generateKey } from './date-db-formatter.js'; From 453ca62d540f5522330e1822f84dd63042f134b9 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:13:30 -0300 Subject: [PATCH 06/12] Switching 'electron-store' import to use import --- __tests__/__main__/import-export.js | 2 +- __tests__/__main__/time-balance.js | 2 +- __tests__/__main__/update-manager.js | 8 ++++---- __tests__/__renderer__/classes/BaseCalendar.js | 11 +++++------ __tests__/__renderer__/classes/FlexibleDayCalendar.js | 2 +- .../__renderer__/classes/FlexibleMonthCalendar.js | 2 +- __tests__/__renderer__/workday-waiver.js | 2 +- js/demo-generator.js | 2 +- js/import-export.js | 2 +- js/main-window.js | 2 +- js/menus.js | 2 +- js/time-balance.js | 2 +- js/update-manager.js | 2 +- main/calendar-aux.js | 2 +- 14 files changed, 21 insertions(+), 22 deletions(-) diff --git a/__tests__/__main__/import-export.js b/__tests__/__main__/import-export.js index 1badf96ee..3d3761bcf 100644 --- a/__tests__/__main__/import-export.js +++ b/__tests__/__main__/import-export.js @@ -9,7 +9,7 @@ const { } = require('../../js/import-export'); import fs from 'fs'; -const Store = require('electron-store'); +import Store from 'electron-store'; const path = require('path'); describe('Import export', function() diff --git a/__tests__/__main__/time-balance.js b/__tests__/__main__/time-balance.js index 57d3a797f..99c96df56 100644 --- a/__tests__/__main__/time-balance.js +++ b/__tests__/__main__/time-balance.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import { computeAllTimeBalanceUntil, getFirstInputInDb, diff --git a/__tests__/__main__/update-manager.js b/__tests__/__main__/update-manager.js index 08bd47fd5..7278d68c9 100644 --- a/__tests__/__main__/update-manager.js +++ b/__tests__/__main__/update-manager.js @@ -1,6 +1,6 @@ 'use strict'; -const ElectronStore = require('electron-store'); +import Store from 'electron-store'; const { getDateStr } = require('../../js/date-aux'); const {shouldCheckForUpdates, checkForUpdates} = require('../../js/update-manager'); @@ -28,7 +28,7 @@ describe('js/update-manager.js', () => { test('Should return true when was never checked', () => { - const store = new ElectronStore(); + const store = new Store(); store.set('update-remind-me-after', false); expect(shouldCheckForUpdates()).toBe(true); }); @@ -37,7 +37,7 @@ describe('js/update-manager.js', () => { const now = new Date(); now.setDate(now.getDate() - 1); - const store = new ElectronStore(); + const store = new Store(); store.set('update-remind-me-after', getDateStr(now)); expect(shouldCheckForUpdates()).toBe(true); }); @@ -45,7 +45,7 @@ describe('js/update-manager.js', () => test('Should return false when was checked today', () => { const now = new Date(); - const store = new ElectronStore(); + const store = new Store(); store.set('update-remind-me-after', getDateStr(now)); expect(shouldCheckForUpdates()).toBe(false); }); diff --git a/__tests__/__renderer__/classes/BaseCalendar.js b/__tests__/__renderer__/classes/BaseCalendar.js index 89ddc9fea..764fc5418 100644 --- a/__tests__/__renderer__/classes/BaseCalendar.js +++ b/__tests__/__renderer__/classes/BaseCalendar.js @@ -1,10 +1,9 @@ 'use strict'; -import ElectronStore from 'electron-store'; +import Store from 'electron-store'; import { BaseCalendar } from '../../../renderer/classes/BaseCalendar.js'; import { generateKey } from '../../../js/date-db-formatter.js'; import { getUserPreferences, resetPreferences, savePreferences, switchCalendarView } from '../../../js/user-preferences.js'; -const Store = require('electron-store'); const timeBalance = require('../../../js/time-balance'); import { calendarApi } from '../../../renderer/preload-scripts/calendar-api.js'; @@ -49,9 +48,9 @@ describe('BaseCalendar.js', () => const mocks = {}; beforeEach(() => { - const flexibleStore = new ElectronStore({name: 'flexible-store'}); + const flexibleStore = new Store({name: 'flexible-store'}); flexibleStore.clear(); - const waivedWorkdays = new ElectronStore({name: 'waived-workdays'}); + const waivedWorkdays = new Store({name: 'waived-workdays'}); waivedWorkdays.clear(); ExtendedClass.prototype._initCalendar = () => {}; ExtendedClass.prototype._getTargetDayForAllTimeBalance = () => {}; @@ -122,10 +121,10 @@ describe('BaseCalendar.js', () => test('Should build with default internal store values', async(done) => { ExtendedClass.prototype._initCalendar = () => { done(); }; - const flexibleStore = new ElectronStore({name: 'flexible-store'}); + const flexibleStore = new Store({name: 'flexible-store'}); flexibleStore.set('flexible', 'store'); - const waivedWorkdays = new ElectronStore({name: 'waived-workdays'}); + const waivedWorkdays = new Store({name: 'waived-workdays'}); waivedWorkdays.set('2022-01-01', { reason: 'dismiss', hours: '10:00' diff --git a/__tests__/__renderer__/classes/FlexibleDayCalendar.js b/__tests__/__renderer__/classes/FlexibleDayCalendar.js index 7316cddee..c46d40ee5 100644 --- a/__tests__/__renderer__/classes/FlexibleDayCalendar.js +++ b/__tests__/__renderer__/classes/FlexibleDayCalendar.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import { computeAllTimeBalanceUntilAsync } from '../../../js/time-balance.js'; import { defaultPreferences } from '../../../js/user-preferences.js'; import { CalendarFactory } from '../../../renderer/classes/CalendarFactory.js'; diff --git a/__tests__/__renderer__/classes/FlexibleMonthCalendar.js b/__tests__/__renderer__/classes/FlexibleMonthCalendar.js index 415ac42fa..8aa27e756 100644 --- a/__tests__/__renderer__/classes/FlexibleMonthCalendar.js +++ b/__tests__/__renderer__/classes/FlexibleMonthCalendar.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import { computeAllTimeBalanceUntilAsync } from '../../../js/time-balance.js'; import { defaultPreferences } from '../../../js/user-preferences.js'; import { CalendarFactory } from '../../../renderer/classes/CalendarFactory.js'; diff --git a/__tests__/__renderer__/workday-waiver.js b/__tests__/__renderer__/workday-waiver.js index 42f8b4456..7ec12c7a7 100644 --- a/__tests__/__renderer__/workday-waiver.js +++ b/__tests__/__renderer__/workday-waiver.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import fs from 'fs'; const path = require('path'); const Holidays = require('date-holidays'); diff --git a/js/demo-generator.js b/js/demo-generator.js index 9d2e06f13..979878b66 100644 --- a/js/demo-generator.js +++ b/js/demo-generator.js @@ -2,7 +2,7 @@ const { hourMinToHourFormatted, sumTime } = require('./time-math.js'); const { generateKey } = require('./date-db-formatter.js'); -const Store = require('electron-store'); +import Store from 'electron-store'; /** * Returns a random integer between min (inclusive) and max (inclusive), rounding up to closest multiple of 5 diff --git a/js/import-export.js b/js/import-export.js index 8d86017a6..6e0352deb 100644 --- a/js/import-export.js +++ b/js/import-export.js @@ -1,7 +1,7 @@ /*eslint-disable no-prototype-builtins*/ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import fs from 'fs'; import { validateTime } from './time-math.js'; diff --git a/js/main-window.js b/js/main-window.js index 259a0b4e2..d28c5cfc4 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -2,7 +2,7 @@ const { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } = require('electron'); const path = require('path'); -const Store = require('electron-store'); +import Store from 'electron-store'; const { checkForUpdates, shouldCheckForUpdates } = require('./update-manager'); const { migrateFixedDbToFlexible } = require('./import-export.js'); diff --git a/js/menus.js b/js/menus.js index 063e250c2..2faa0746b 100644 --- a/js/menus.js +++ b/js/menus.js @@ -2,7 +2,7 @@ const { app, BrowserWindow, clipboard, dialog, shell } = require('electron'); const path = require('path'); -const Store = require('electron-store'); +import Store from 'electron-store'; const { checkForUpdates } = require('./update-manager'); const { getSavedPreferences } = require('./saved-preferences.js'); diff --git a/js/time-balance.js b/js/time-balance.js index 422ec23f3..5e295fad7 100644 --- a/js/time-balance.js +++ b/js/time-balance.js @@ -1,6 +1,6 @@ 'use strict'; -const Store = require('electron-store'); +import Store from 'electron-store'; import { subtractTime, diff --git a/js/update-manager.js b/js/update-manager.js index e38df139d..8b2f07e50 100644 --- a/js/update-manager.js +++ b/js/update-manager.js @@ -3,7 +3,7 @@ const { app, net, shell, dialog, BrowserWindow } = require('electron'); const isOnline = require('is-online'); -const Store = require('electron-store'); +import Store from 'electron-store'; const { getCurrentTranslation } = require('../src/configs/i18next.config'); import { getDateStr } from './date-aux.js'; diff --git a/main/calendar-aux.js b/main/calendar-aux.js index 724fe0086..81ea29620 100644 --- a/main/calendar-aux.js +++ b/main/calendar-aux.js @@ -4,7 +4,7 @@ const { ipcMain } = require('electron'); import { computeAllTimeBalanceUntilAsync } from '../js/time-balance.js'; -const Store = require('electron-store'); +import Store from 'electron-store'; const flexibleStore = new Store({name: 'flexible-store'}); From 8af507c57b1183acb759fef418a9fac801d5412d Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:38:20 -0300 Subject: [PATCH 07/12] Switching notification.js to use export --- js/notification.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/notification.js b/js/notification.js index 355874500..f3c8ec014 100644 --- a/js/notification.js +++ b/js/notification.js @@ -127,9 +127,9 @@ function getDismiss() return dismissToday; } -module.exports = { +export { + createLeaveNotification, createNotification, getDismiss, - createLeaveNotification, updateDismiss, }; From ab7a6f7558761d9cd8fe52c95401c60620e23def Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:26:49 -0300 Subject: [PATCH 08/12] Switching 'path' import to use import --- __tests__/__main__/import-export.js | 2 +- __tests__/__renderer__/preferences.js | 2 +- __tests__/__renderer__/window-aux.js | 2 +- __tests__/__renderer__/workday-waiver.js | 2 +- js/main-window.js | 2 +- js/menus.js | 2 +- js/notification.js | 2 +- js/squirrel.js | 3 ++- js/windows.js | 2 +- src/configs/i18next.config.js | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/__tests__/__main__/import-export.js b/__tests__/__main__/import-export.js index 3d3761bcf..62080b68d 100644 --- a/__tests__/__main__/import-export.js +++ b/__tests__/__main__/import-export.js @@ -10,7 +10,7 @@ const { import fs from 'fs'; import Store from 'electron-store'; -const path = require('path'); +import path from 'path'; describe('Import export', function() { diff --git a/__tests__/__renderer__/preferences.js b/__tests__/__renderer__/preferences.js index e47103e60..19bfe32f4 100644 --- a/__tests__/__renderer__/preferences.js +++ b/__tests__/__renderer__/preferences.js @@ -2,7 +2,7 @@ 'use strict'; import fs from 'fs'; -const path = require('path'); +import path from 'path'; const { defaultPreferences, getPreferencesFilePath, diff --git a/__tests__/__renderer__/window-aux.js b/__tests__/__renderer__/window-aux.js index 25b92404d..5ec554549 100644 --- a/__tests__/__renderer__/window-aux.js +++ b/__tests__/__renderer__/window-aux.js @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ 'use strict'; -const path = require('path'); +import path from 'path'; const BrowserWindow = require('@electron/remote').BrowserWindow; import * as windowAux from '../../js/window-aux.cjs'; diff --git a/__tests__/__renderer__/workday-waiver.js b/__tests__/__renderer__/workday-waiver.js index 7ec12c7a7..224551156 100644 --- a/__tests__/__renderer__/workday-waiver.js +++ b/__tests__/__renderer__/workday-waiver.js @@ -3,7 +3,7 @@ import Store from 'electron-store'; import fs from 'fs'; -const path = require('path'); +import path from 'path'; const Holidays = require('date-holidays'); /* eslint-disable-next-line no-global-assign */ window.$ = require('jquery'); diff --git a/js/main-window.js b/js/main-window.js index d28c5cfc4..127b150b8 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -1,7 +1,7 @@ 'use strict'; const { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } = require('electron'); -const path = require('path'); +import path from 'path'; import Store from 'electron-store'; const { checkForUpdates, shouldCheckForUpdates } = require('./update-manager'); diff --git a/js/menus.js b/js/menus.js index 2faa0746b..63fd9a6e0 100644 --- a/js/menus.js +++ b/js/menus.js @@ -1,7 +1,7 @@ 'use strict'; const { app, BrowserWindow, clipboard, dialog, shell } = require('electron'); -const path = require('path'); +import path from 'path'; import Store from 'electron-store'; const { checkForUpdates } = require('./update-manager'); diff --git a/js/notification.js b/js/notification.js index f3c8ec014..dc5d655e4 100644 --- a/js/notification.js +++ b/js/notification.js @@ -1,6 +1,6 @@ 'use strict'; -const path = require('path'); +import path from 'path'; const { app } = require('electron'); const ElectronNotification = require('electron').Notification; diff --git a/js/squirrel.js b/js/squirrel.js index dd9d801c0..7b2f55e8b 100644 --- a/js/squirrel.js +++ b/js/squirrel.js @@ -1,5 +1,7 @@ 'use strict'; +import path from 'path'; + function handleSquirrelEvent(application) { if (process.argv.length === 1) @@ -8,7 +10,6 @@ function handleSquirrelEvent(application) } const ChildProcess = require('child_process'); - const path = require('path'); const appFolder = path.resolve(process.execPath, '..'); const rootAtomFolder = path.resolve(appFolder, '..'); diff --git a/js/windows.js b/js/windows.js index 3cabe403a..d404fa637 100644 --- a/js/windows.js +++ b/js/windows.js @@ -2,7 +2,7 @@ const { BrowserWindow } = require('electron'); import { appConfig } from './app-config.cjs'; -const path = require('path'); +import path from 'path'; import { getDateStr } from './date-aux.js'; // Keep a global reference of the window object, if you don't, the window will diff --git a/src/configs/i18next.config.js b/src/configs/i18next.config.js index bf0e814b1..2797ffe32 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -2,7 +2,7 @@ const i18n = require('i18next'); const i18nextBackend = require('i18next-node-fs-backend'); -const path = require('path'); +import path from 'path'; const { ipcMain } = require('electron'); const config = require('../configs/app.config'); From fa8a8d838aa4e5c766a7c2de32372867ab5bd6c3 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:29:35 -0300 Subject: [PATCH 09/12] Switching 'electron' to use import --- __tests__/__main__/main-window.js | 2 +- __tests__/__main__/notification.js | 2 +- __tests__/__main__/windows.js | 2 +- esm-main.js | 2 +- js/main-window.js | 2 +- js/menus.js | 2 +- js/notification.js | 3 +-- js/saved-preferences.js | 2 +- js/update-manager.js | 2 +- js/windows.js | 2 +- main/calendar-aux.js | 2 +- src/configs/i18next.config.js | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) diff --git a/__tests__/__main__/main-window.js b/__tests__/__main__/main-window.js index 0f2f690dc..d4e4af20f 100644 --- a/__tests__/__main__/main-window.js +++ b/__tests__/__main__/main-window.js @@ -3,7 +3,7 @@ const notification = require('../../js/notification.js'); const userPreferences = require('../../js/user-preferences.js'); const { savePreferences, defaultPreferences, resetPreferences } = userPreferences; -const { app, BrowserWindow, ipcMain } = require('electron'); +import { app, BrowserWindow, ipcMain } from 'electron'; jest.mock('../../js/update-manager', () => ({ checkForUpdates: jest.fn(), diff --git a/__tests__/__main__/notification.js b/__tests__/__main__/notification.js index 000dadc5c..bfb947786 100644 --- a/__tests__/__main__/notification.js +++ b/__tests__/__main__/notification.js @@ -4,7 +4,7 @@ const { createNotification, createLeaveNotification, updateDismiss, getDismiss } = require('../../js/notification.js'); const { getUserPreferences, savePreferences, resetPreferences } = require('../../js/user-preferences.js'); const { getDateStr } = require('../../js/date-aux.js'); -const { app } = require('electron'); +import { app } from 'electron'; function buildTimeString(now) { diff --git a/__tests__/__main__/windows.js b/__tests__/__main__/windows.js index 8ece451e4..e5a62205e 100644 --- a/__tests__/__main__/windows.js +++ b/__tests__/__main__/windows.js @@ -1,6 +1,6 @@ 'use strict'; -const { BrowserWindow } = require('electron'); +import { BrowserWindow } from 'electron'; const { getDateStr } = require('../../js/date-aux.js'); const windows = require('../../js/windows.js'); const {getWaiverWindow, tray, contextMenu, prefWindow, resetWindowsElements, openWaiverManagerWindow, getDialogCoordinates} = require('../../js/windows.js'); diff --git a/esm-main.js b/esm-main.js index cfb0a9011..5ea139c35 100644 --- a/esm-main.js +++ b/esm-main.js @@ -1,7 +1,7 @@ /*eslint-disable no-useless-escape*/ 'use strict'; -const { app, ipcMain } = require('electron'); +import { app, ipcMain } from 'electron'; const { createWindow, createMenu, getMainWindow, triggerStartupDialogs } = require('./js/main-window'); const { createNotification } = require('./js/notification'); const { openWaiverManagerWindow } = require('./js/windows.js'); diff --git a/js/main-window.js b/js/main-window.js index 127b150b8..6e3e6c8c4 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -1,6 +1,6 @@ 'use strict'; -const { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } = require('electron'); +import { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } from 'electron'; import path from 'path'; import Store from 'electron-store'; diff --git a/js/menus.js b/js/menus.js index 63fd9a6e0..3f285fe3b 100644 --- a/js/menus.js +++ b/js/menus.js @@ -1,6 +1,6 @@ 'use strict'; -const { app, BrowserWindow, clipboard, dialog, shell } = require('electron'); +import { app, BrowserWindow, clipboard, dialog, shell } from 'electron'; import path from 'path'; import Store from 'electron-store'; diff --git a/js/notification.js b/js/notification.js index dc5d655e4..814a53861 100644 --- a/js/notification.js +++ b/js/notification.js @@ -1,8 +1,7 @@ 'use strict'; import path from 'path'; -const { app } = require('electron'); -const ElectronNotification = require('electron').Notification; +import { app, Notification as ElectronNotification } from 'electron'; const { subtractTime, diff --git a/js/saved-preferences.js b/js/saved-preferences.js index 53d6aa13b..24554a5b0 100644 --- a/js/saved-preferences.js +++ b/js/saved-preferences.js @@ -2,7 +2,7 @@ const { changeLanguage } = require('../src/configs/i18next.config'); -const { app, ipcMain } = require('electron'); +import { app, ipcMain } from 'electron'; let savedPreferences = null; diff --git a/js/update-manager.js b/js/update-manager.js index 8b2f07e50..2683e16cc 100644 --- a/js/update-manager.js +++ b/js/update-manager.js @@ -1,6 +1,6 @@ 'use strict'; -const { app, net, shell, dialog, BrowserWindow } = require('electron'); +import { app, net, shell, dialog, BrowserWindow } from 'electron'; const isOnline = require('is-online'); import Store from 'electron-store'; diff --git a/js/windows.js b/js/windows.js index d404fa637..6dc14f1bb 100644 --- a/js/windows.js +++ b/js/windows.js @@ -1,6 +1,6 @@ 'use strict'; -const { BrowserWindow } = require('electron'); +import { BrowserWindow } from 'electron'; import { appConfig } from './app-config.cjs'; import path from 'path'; import { getDateStr } from './date-aux.js'; diff --git a/main/calendar-aux.js b/main/calendar-aux.js index 81ea29620..3250b0f0c 100644 --- a/main/calendar-aux.js +++ b/main/calendar-aux.js @@ -1,6 +1,6 @@ 'use strict'; -const { ipcMain } = require('electron'); +import { ipcMain } from 'electron'; import { computeAllTimeBalanceUntilAsync } from '../js/time-balance.js'; diff --git a/src/configs/i18next.config.js b/src/configs/i18next.config.js index 2797ffe32..5d163c8f7 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -3,7 +3,7 @@ const i18n = require('i18next'); const i18nextBackend = require('i18next-node-fs-backend'); import path from 'path'; -const { ipcMain } = require('electron'); +import { ipcMain } from 'electron'; const config = require('../configs/app.config'); const { appConfig } = require('../../js/app-config.cjs'); From d633731210109bee715febaab6627c9fe7e968f9 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 19:59:14 -0300 Subject: [PATCH 10/12] Export section to have commas and be sorted, last line at end --- js/date-aux.js | 4 +++- js/date-db-formatter.js | 4 ++-- js/date-to-string-util.js | 2 +- js/demo-generator.js | 2 +- js/import-export.js | 4 ++-- js/main-window.js | 10 +++++----- js/menus.js | 2 +- js/saved-preferences.js | 2 +- js/time-balance.js | 4 ++-- js/time-math.js | 8 ++++---- js/update-manager.js | 4 ++-- js/user-preferences.js | 12 ++++++------ js/windows.js | 8 ++++---- main/workday-waiver-aux.js | 2 +- renderer/i18n-translator.js | 4 ++-- renderer/notification-channel.js | 2 +- renderer/themes.js | 4 ++-- renderer/workday-waiver-aux.js | 2 +- src/configs/app.config.js | 4 ++-- src/configs/i18next.config.js | 2 +- src/workday-waiver.js | 4 ++-- 21 files changed, 46 insertions(+), 44 deletions(-) diff --git a/js/date-aux.js b/js/date-aux.js index f99e3cd29..1b285b7cd 100644 --- a/js/date-aux.js +++ b/js/date-aux.js @@ -43,5 +43,7 @@ function getCurrentDateTimeStr() } export { - getDateStr, getMonthLength, getCurrentDateTimeStr + getCurrentDateTimeStr, + getDateStr, + getMonthLength, }; diff --git a/js/date-db-formatter.js b/js/date-db-formatter.js index e150174da..3100d635a 100644 --- a/js/date-db-formatter.js +++ b/js/date-db-formatter.js @@ -13,5 +13,5 @@ function generateKey(year, month, day) } export { - generateKey, -}; \ No newline at end of file + generateKey +}; diff --git a/js/date-to-string-util.js b/js/date-to-string-util.js index f81a6cf3e..bc4f95045 100644 --- a/js/date-to-string-util.js +++ b/js/date-to-string-util.js @@ -28,5 +28,5 @@ function getMonthName(languageData, monthIndex) export { getDayAbbr, - getMonthName + getMonthName, }; \ No newline at end of file diff --git a/js/demo-generator.js b/js/demo-generator.js index 979878b66..7ce70e8bb 100644 --- a/js/demo-generator.js +++ b/js/demo-generator.js @@ -68,4 +68,4 @@ function generateDemoInformation(dateFromStr, dateToStr, workingDays, usualTimes module.exports = { generateDemoInformation -}; \ No newline at end of file +}; diff --git a/js/import-export.js b/js/import-export.js index 6e0352deb..0dc462e69 100644 --- a/js/import-export.js +++ b/js/import-export.js @@ -221,8 +221,8 @@ function migrateFixedDbToFlexible() } module.exports = { - importDatabaseFromFile, exportDatabaseToFile, + importDatabaseFromFile, migrateFixedDbToFlexible, - validEntry + validEntry, }; diff --git a/js/main-window.js b/js/main-window.js index 6e3e6c8c4..06a4b7905 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -287,13 +287,13 @@ function resetMainWindow() } module.exports = { - createWindow, createMenu, + createWindow, + getLeaveByInterval: () => leaveByInterval, getMainWindow, - triggerStartupDialogs, - shouldProposeFlexibleDbMigration, + getWindowTray: () => tray, proposeFlexibleDbMigration, resetMainWindow, - getLeaveByInterval: () => leaveByInterval, - getWindowTray: () => tray + shouldProposeFlexibleDbMigration, + triggerStartupDialogs, }; diff --git a/js/menus.js b/js/menus.js index 3f285fe3b..45533cf46 100644 --- a/js/menus.js +++ b/js/menus.js @@ -375,5 +375,5 @@ module.exports = { getEditMenuTemplate, getHelpMenuTemplate, getMainMenuTemplate, - getViewMenuTemplate + getViewMenuTemplate, }; diff --git a/js/saved-preferences.js b/js/saved-preferences.js index 24554a5b0..918d5fac9 100644 --- a/js/saved-preferences.js +++ b/js/saved-preferences.js @@ -25,4 +25,4 @@ ipcMain.on('PREFERENCE_SAVE_DATA_NEEDED', (event, preferences) => module.exports = { getSavedPreferences -}; \ No newline at end of file +}; diff --git a/js/time-balance.js b/js/time-balance.js index 5e295fad7..7c30164b6 100644 --- a/js/time-balance.js +++ b/js/time-balance.js @@ -205,7 +205,7 @@ async function computeAllTimeBalanceUntilAsync(limitDate) } export { - computeAllTimeBalanceUntilAsync, computeAllTimeBalanceUntil, - getFirstInputInDb + computeAllTimeBalanceUntilAsync, + getFirstInputInDb, }; diff --git a/js/time-math.js b/js/time-math.js index eba36cc39..28997fd77 100644 --- a/js/time-math.js +++ b/js/time-math.js @@ -147,14 +147,14 @@ function validateDate(date) } export { + diffDays, hourMinToHourFormatted, + hourToMinutes, isNegative, - multiplyTime, minutesToHourFormatted, + multiplyTime, subtractTime, sumTime, + validateDate, validateTime, - hourToMinutes, - diffDays, - validateDate }; diff --git a/js/update-manager.js b/js/update-manager.js index 2683e16cc..7085a00dc 100644 --- a/js/update-manager.js +++ b/js/update-manager.js @@ -81,5 +81,5 @@ async function checkForUpdates(showUpToDateDialog) module.exports = { checkForUpdates, - shouldCheckForUpdates -}; \ No newline at end of file + shouldCheckForUpdates, +}; diff --git a/js/user-preferences.js b/js/user-preferences.js index 76db19c39..6d6b4464c 100644 --- a/js/user-preferences.js +++ b/js/user-preferences.js @@ -359,16 +359,16 @@ export { defaultPreferences, getDefaultWidthHeight, getLoadedOrDerivedUserPreferences as getUserPreferences, - getUserPreferencesPromise, - getUserLanguage, getNotificationsInterval, getPreferencesFilePath, - savePreferences, - showDay, - switchCalendarView, + getUserLanguage, + getUserPreferencesPromise, isNotBoolean, isNotificationInterval, notificationIsEnabled, repetitionIsEnabled, - resetPreferences + resetPreferences, + savePreferences, + showDay, + switchCalendarView, }; diff --git a/js/windows.js b/js/windows.js index 6dc14f1bb..5143037fa 100644 --- a/js/windows.js +++ b/js/windows.js @@ -86,11 +86,11 @@ function getWaiverWindow() } module.exports = { - prefWindow, - tray, contextMenu, - openWaiverManagerWindow, getDialogCoordinates, getWaiverWindow, - resetWindowsElements + openWaiverManagerWindow, + prefWindow, + resetWindowsElements, + tray, }; diff --git a/main/workday-waiver-aux.js b/main/workday-waiver-aux.js index 9311a08fd..5f505362d 100644 --- a/main/workday-waiver-aux.js +++ b/main/workday-waiver-aux.js @@ -118,5 +118,5 @@ module.exports = { getCountries, getRegions, getStates, - setupWorkdayWaiverHandlers + setupWorkdayWaiverHandlers, }; diff --git a/renderer/i18n-translator.js b/renderer/i18n-translator.js index 1a0adf35c..ced69ebfb 100644 --- a/renderer/i18n-translator.js +++ b/renderer/i18n-translator.js @@ -53,5 +53,5 @@ function translatePage(language, languageData, windowName) export { getTranslationInLanguageData, - translatePage -}; \ No newline at end of file + translatePage, +}; diff --git a/renderer/notification-channel.js b/renderer/notification-channel.js index d59e67ee5..56c780572 100644 --- a/renderer/notification-channel.js +++ b/renderer/notification-channel.js @@ -8,4 +8,4 @@ const searchLeaveByElement = (event) => export { searchLeaveByElement -}; \ No newline at end of file +}; diff --git a/renderer/themes.js b/renderer/themes.js index 41d78fad9..324ecc06b 100644 --- a/renderer/themes.js +++ b/renderer/themes.js @@ -37,7 +37,7 @@ function applyTheme(theme) } export { - themeOptions, applyTheme, - isValidTheme + isValidTheme, + themeOptions, }; diff --git a/renderer/workday-waiver-aux.js b/renderer/workday-waiver-aux.js index 2a69ab819..880c13127 100644 --- a/renderer/workday-waiver-aux.js +++ b/renderer/workday-waiver-aux.js @@ -23,6 +23,6 @@ function displayWaiverWindow(waiverDay) } export { + displayWaiverWindow, formatDayId, - displayWaiverWindow }; diff --git a/src/configs/app.config.js b/src/configs/app.config.js index 7852a5ef6..4db135841 100644 --- a/src/configs/app.config.js +++ b/src/configs/app.config.js @@ -63,8 +63,8 @@ const namespace = 'translation'; export { fallbackLng, - namespace, getLanguageMap, + getLanguageName, getLanguagesCodes, - getLanguageName + namespace, }; diff --git a/src/configs/i18next.config.js b/src/configs/i18next.config.js index 5d163c8f7..d3c986e78 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -99,5 +99,5 @@ module.exports = changeLanguage, getCurrentTranslation, setLanguageChangedCallback, - setupI18n + setupI18n, }; diff --git a/src/workday-waiver.js b/src/workday-waiver.js index 5c8a0bc44..fdb371a0f 100644 --- a/src/workday-waiver.js +++ b/src/workday-waiver.js @@ -484,8 +484,8 @@ $(async() => export { addHolidayToList, addWaiver, - clearTable, clearHolidayTable, + clearTable, clearWaiverList, deleteEntryOnClick, getHolidays, @@ -497,8 +497,8 @@ export { populateList, populateState, populateYear, + refreshDataForTest, setDates, setHours, toggleAddButton, - refreshDataForTest }; From 171ac269b5b5378f2db90cf11464bf0a334eed47 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 20:16:08 -0300 Subject: [PATCH 11/12] Adding all 3 js extensions to eslint target --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25ab1432b..899da630c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "debug:render": "electron --remote-debugging-port=9222 .", "lint": "npm-run-all --parallel lint:*", "lint:css": "stylelint css/*.css", - "lint:eslint": "eslint . ", + "lint:eslint": "eslint . --ext .cjs,.js,.mjs", "lint:markdown": "prettier docs/*.md *.md -c", "lint:json": "prettier locales/*/*.json -c", "lint-fix": "npm-run-all --parallel lint-fix:*", From 5a3f644a85da7802d6508438760decb5335eff6b Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sun, 7 Jan 2024 21:25:12 -0300 Subject: [PATCH 12/12] Small updates to cjs files to switch CRLF to LF, adding attributes --- .gitattributes | 2 ++ js/app-config.cjs | 2 +- js/window-aux.cjs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index e1106beda..ab18c0c8c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,6 +10,7 @@ *.bat text eol=crlf *.cmd text eol=crlf *.coffee text +*.cjs text eol=lf *.css text *.htm text diff=html *.html text diff=html @@ -21,6 +22,7 @@ *.less text *.ls text *.map text -diff +*.mjs text eol=lf *.od text *.onlydata text *.php text diff=php diff --git a/js/app-config.cjs b/js/app-config.cjs index 9bd04707e..7a99c05fc 100644 --- a/js/app-config.cjs +++ b/js/app-config.cjs @@ -1,8 +1,8 @@ 'use strict'; const { app } = require('electron'); -const path = require('path'); const os = require('os'); +const path = require('path'); const macOS = process.platform === 'darwin'; const win32 = process.platform === 'win32'; diff --git a/js/window-aux.cjs b/js/window-aux.cjs index 2e5595781..e139b27a4 100644 --- a/js/window-aux.cjs +++ b/js/window-aux.cjs @@ -5,7 +5,7 @@ const BrowserWindow = (electron || require('@electron/remote')).BrowserWindow; const dialog = (electron || require('@electron/remote')).dialog; /** - * Opens an electron dialog, based on the options, and returns the promise. + * Opens an electron dialog based on the options, and returns a promise that resolves with the response. * @param {Object.} options * @return {Promise} */