thamara / time-to-leave

Log work hours and get notified when it's time to leave the office and start to live.
http://timetoleave.app
GNU General Public License v3.0
455 stars 267 forks source link

Preparations to use javascript modules and other small fixes #1050

Closed araujoarthur0 closed 8 months ago

araujoarthur0 commented 8 months ago

Related issue

This helps #1037

Context / Background

The new electron 28 changes things by providing main electron imports through JS modules. That means we'll be able to use import syntax rather than node's require(), and no longer need the esm module to use both notations. The require() notation will still be available, making it the best of both worlds for other imports that haven't migrated yet - date-holidays for example.

I'm separating a few of the changes that will need to be made for a simpler review. These changes here still work in electron 27 and will clear the field for a larger patch.

What change is being introduced by this PR?

Using the .cjs extension for files that will be using only node modules

Commit: Renaming window-aux and app-config to .cjs

Updating pre-commit script

Script was trying to format deleted files. It also had to be updated to format .cjs and .mjs files Commit: Preparing commit hook to accept mjs and cjs files, avoiding deleted files Commit: Adding all 3 js extensions to eslint target

Cleanups

Commit: Adding 'use strict' to all files Commit: Export section to have commas and be sorted, last line at end

Switching imports to import keyword rather than require()

Commit: Updating renderer electron imports Commit: Switching 'fs' import to use import Commit: Switching 'electron-store' import to use import Commit: Switching notification.js to use export Commit: Switching 'path' import to use import Commit: Switching 'electron' to use import

How will this be tested?

Testsuite works fine.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (7be9e9a) 79.89% compared to head (5a3f644) 79.36%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1050 +/- ## ========================================== - Coverage 79.89% 79.36% -0.53% ========================================== Files 21 19 -2 Lines 1278 1231 -47 Branches 190 183 -7 ========================================== - Hits 1021 977 -44 + Misses 257 254 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.