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/.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 $!" diff --git a/__tests__/__main__/import-export.js b/__tests__/__main__/import-export.js index 7246a1452..62080b68d 100644 --- a/__tests__/__main__/import-export.js +++ b/__tests__/__main__/import-export.js @@ -8,9 +8,9 @@ const { validEntry } = require('../../js/import-export'); -const fs = require('fs'); -const Store = require('electron-store'); -const path = require('path'); +import fs from 'fs'; +import Store from 'electron-store'; +import path from 'path'; describe('Import export', function() { diff --git a/__tests__/__main__/main-window.js b/__tests__/__main__/main-window.js index 3c029a3af..d4e4af20f 100644 --- a/__tests__/__main__/main-window.js +++ b/__tests__/__main__/main-window.js @@ -1,7 +1,9 @@ +'use strict'; + 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__/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__/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__/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 17164b50e..7278d68c9 100644 --- a/__tests__/__main__/update-manager.js +++ b/__tests__/__main__/update-manager.js @@ -1,4 +1,6 @@ -const ElectronStore = require('electron-store'); +'use strict'; + +import Store from 'electron-store'; const { getDateStr } = require('../../js/date-aux'); const {shouldCheckForUpdates, checkForUpdates} = require('../../js/update-manager'); @@ -26,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); }); @@ -35,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); }); @@ -43,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__/__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__/__main__/windows.js b/__tests__/__main__/windows.js index 6683a795b..e5a62205e 100644 --- a/__tests__/__main__/windows.js +++ b/__tests__/__main__/windows.js @@ -1,4 +1,6 @@ -const { BrowserWindow } = require('electron'); +'use strict'; + +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/__tests__/__renderer__/classes/BaseCalendar.js b/__tests__/__renderer__/classes/BaseCalendar.js index 2a2160b28..764fc5418 100644 --- a/__tests__/__renderer__/classes/BaseCalendar.js +++ b/__tests__/__renderer__/classes/BaseCalendar.js @@ -1,8 +1,9 @@ -import ElectronStore from 'electron-store'; +'use strict'; + +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'; @@ -47,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 = () => {}; @@ -120,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/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..c46d40ee5 100644 --- a/__tests__/__renderer__/classes/FlexibleDayCalendar.js +++ b/__tests__/__renderer__/classes/FlexibleDayCalendar.js @@ -1,6 +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__/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/__tests__/__renderer__/preferences.js b/__tests__/__renderer__/preferences.js index d6a0c1405..19bfe32f4 100644 --- a/__tests__/__renderer__/preferences.js +++ b/__tests__/__renderer__/preferences.js @@ -1,8 +1,8 @@ /* eslint-disable no-undef */ 'use strict'; -const fs = require('fs'); -const path = require('path'); +import fs from 'fs'; +import path from 'path'; const { defaultPreferences, getPreferencesFilePath, 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__/window-aux.js b/__tests__/__renderer__/window-aux.js index 6a97e0a97..5ec554549 100644 --- a/__tests__/__renderer__/window-aux.js +++ b/__tests__/__renderer__/window-aux.js @@ -1,11 +1,11 @@ /* 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.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..224551156 100644 --- a/__tests__/__renderer__/workday-waiver.js +++ b/__tests__/__renderer__/workday-waiver.js @@ -1,9 +1,9 @@ /* eslint-disable no-undef */ 'use strict'; -const Store = require('electron-store'); -const fs = require('fs'); -const path = require('path'); +import Store from 'electron-store'; +import fs from 'fs'; +import path from 'path'; const Holidays = require('date-holidays'); /* eslint-disable-next-line no-global-assign */ window.$ = require('jquery'); @@ -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..5ea139c35 100644 --- a/esm-main.js +++ b/esm-main.js @@ -1,15 +1,15 @@ /*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'); 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..7a99c05fc 100644 --- a/js/app-config.js +++ 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'; @@ -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/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 5f682cfb6..7ce70e8bb 100644 --- a/js/demo-generator.js +++ b/js/demo-generator.js @@ -1,6 +1,8 @@ +'use strict'; + 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 @@ -66,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 3ea8e8500..0dc462e69 100644 --- a/js/import-export.js +++ b/js/import-export.js @@ -1,8 +1,8 @@ /*eslint-disable no-prototype-builtins*/ 'use strict'; -const Store = require('electron-store'); -const fs = require('fs'); +import Store from 'electron-store'; +import fs from 'fs'; import { validateTime } from './time-math.js'; import { generateKey } from './date-db-formatter.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 ae56928b9..06a4b7905 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -1,8 +1,8 @@ 'use strict'; -const { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } = require('electron'); -const path = require('path'); -const Store = require('electron-store'); +import { app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray } from 'electron'; +import path from 'path'; +import Store from 'electron-store'; const { checkForUpdates, shouldCheckForUpdates } = require('./update-manager'); const { migrateFixedDbToFlexible } = require('./import-export.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 @@ -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 b75457db5..45533cf46 100644 --- a/js/menus.js +++ b/js/menus.js @@ -1,8 +1,8 @@ 'use strict'; -const { app, BrowserWindow, clipboard, dialog, shell } = require('electron'); -const path = require('path'); -const Store = require('electron-store'); +import { app, BrowserWindow, clipboard, dialog, shell } from 'electron'; +import path from 'path'; +import Store from 'electron-store'; const { checkForUpdates } = require('./update-manager'); const { getSavedPreferences } = require('./saved-preferences.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'; @@ -375,5 +375,5 @@ module.exports = { getEditMenuTemplate, getHelpMenuTemplate, getMainMenuTemplate, - getViewMenuTemplate + getViewMenuTemplate, }; diff --git a/js/notification.js b/js/notification.js index 355874500..814a53861 100644 --- a/js/notification.js +++ b/js/notification.js @@ -1,8 +1,7 @@ 'use strict'; -const path = require('path'); -const { app } = require('electron'); -const ElectronNotification = require('electron').Notification; +import path from 'path'; +import { app, Notification as ElectronNotification } from 'electron'; const { subtractTime, @@ -127,9 +126,9 @@ function getDismiss() return dismissToday; } -module.exports = { +export { + createLeaveNotification, createNotification, getDismiss, - createLeaveNotification, updateDismiss, }; diff --git a/js/saved-preferences.js b/js/saved-preferences.js index 19d6a32d1..918d5fac9 100644 --- a/js/saved-preferences.js +++ b/js/saved-preferences.js @@ -1,7 +1,8 @@ 'use strict'; + const { changeLanguage } = require('../src/configs/i18next.config'); -const { app, ipcMain } = require('electron'); +import { app, ipcMain } from 'electron'; let savedPreferences = null; @@ -24,4 +25,4 @@ ipcMain.on('PREFERENCE_SAVE_DATA_NEEDED', (event, preferences) => module.exports = { getSavedPreferences -}; \ No newline at end of file +}; diff --git a/js/squirrel.js b/js/squirrel.js index 81bf415d2..7b2f55e8b 100644 --- a/js/squirrel.js +++ b/js/squirrel.js @@ -1,3 +1,7 @@ +'use strict'; + +import path from 'path'; + function handleSquirrelEvent(application) { if (process.argv.length === 1) @@ -6,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/time-balance.js b/js/time-balance.js index 422ec23f3..7c30164b6 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, @@ -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 e38df139d..7085a00dc 100644 --- a/js/update-manager.js +++ b/js/update-manager.js @@ -1,9 +1,9 @@ 'use strict'; -const { app, net, shell, dialog, BrowserWindow } = require('electron'); +import { app, net, shell, dialog, BrowserWindow } from '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'; @@ -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/window-aux.js b/js/window-aux.cjs similarity index 83% rename from js/window-aux.js rename to js/window-aux.cjs index 5a4934e1c..e139b27a4 100644 --- a/js/window-aux.js +++ 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} */ @@ -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..5143037fa 100644 --- a/js/windows.js +++ b/js/windows.js @@ -1,8 +1,8 @@ 'use strict'; -const { BrowserWindow } = require('electron'); -import { appConfig } from './app-config.js'; -const path = require('path'); +import { BrowserWindow } from 'electron'; +import { appConfig } from './app-config.cjs'; +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 @@ -86,11 +86,11 @@ function getWaiverWindow() } module.exports = { - prefWindow, - tray, contextMenu, - openWaiverManagerWindow, getDialogCoordinates, getWaiverWindow, - resetWindowsElements + openWaiverManagerWindow, + prefWindow, + resetWindowsElements, + tray, }; diff --git a/main/calendar-aux.js b/main/calendar-aux.js index 724fe0086..3250b0f0c 100644 --- a/main/calendar-aux.js +++ b/main/calendar-aux.js @@ -1,10 +1,10 @@ 'use strict'; -const { ipcMain } = require('electron'); +import { ipcMain } from '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'}); 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/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:*", 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 b014d3198..56c780572 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(); @@ -6,4 +8,4 @@ const searchLeaveByElement = (event) => export { searchLeaveByElement -}; \ No newline at end of file +}; 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 }; 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 277cc279a..4db135841 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', @@ -61,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 623469e80..d3c986e78 100644 --- a/src/configs/i18next.config.js +++ b/src/configs/i18next.config.js @@ -1,10 +1,12 @@ +'use strict'; + const i18n = require('i18next'); const i18nextBackend = require('i18next-node-fs-backend'); -const path = require('path'); -const { ipcMain } = require('electron'); +import path from 'path'; +import { ipcMain } from 'electron'; const config = require('../configs/app.config'); -const { appConfig } = require('../../js/app-config'); +const { appConfig } = require('../../js/app-config.cjs'); const i18nextOptions = { backend:{ @@ -97,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 }; 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');