-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ESLint & Unicorn * Update TypeScript * Update vite * Fix build process not type-checked * Update project to lint all files * Update tsconfig to match project use - Removes unnecessary jsx setting - Fix deprectated moduleResolution marker * Improve legibility of dense JSON files * Fix yarn start never stops * Allow JS scripts to be formatted * nit * Apply auto-fixes * Convert preMake to named export * Apply auto-fixes * Add top-level awaits to ESM scripts * Add types * Format launchdev.js * Remove workaround, clean up * Revert "Allow JS scripts to be formatted" This reverts commit 21cecd7. * Update test expectations * nit * Fix tests not linted
- Loading branch information
1 parent
579526b
commit 146a588
Showing
22 changed files
with
1,100 additions
and
442 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import globals from 'globals'; | ||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import eslintPluginUnicorn from 'eslint-plugin-unicorn'; | ||
|
||
export default tseslint.config( | ||
// Baseline include / exclude | ||
{ files: ['**/*.{js,cjs,mjs,ts,mts}'] }, | ||
{ ignores: ['dist/**/*', 'jest.config.cjs'] }, | ||
|
||
// Baseline | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommendedTypeChecked, | ||
{ | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
rules: { | ||
'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }], | ||
'no-control-regex': 'off', | ||
|
||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
}, | ||
}, | ||
|
||
// Baseline (except preload) | ||
{ | ||
ignores: ['./src/preload.ts'], | ||
languageOptions: { globals: { ...globals.node } }, | ||
}, | ||
|
||
// Preload | ||
{ | ||
files: ['./src/preload.ts'], | ||
languageOptions: { globals: { ...globals.browser } }, | ||
}, | ||
|
||
// Unicorn | ||
eslintPluginUnicorn.configs['flat/recommended'], | ||
{ | ||
rules: { | ||
// Enable | ||
'unicorn/better-regex': 'warn', | ||
// Disable | ||
'unicorn/prefer-string-slice': 'off', | ||
'unicorn/no-negated-condition': 'off', | ||
'unicorn/filename-case': 'off', | ||
'unicorn/no-null': 'off', | ||
'unicorn/prevent-abbreviations': 'off', | ||
'unicorn/switch-case-braces': 'off', | ||
}, | ||
}, | ||
|
||
// Scripts | ||
{ | ||
files: ['scripts/**/*'], | ||
rules: { | ||
'unicorn/no-process-exit': 'off', | ||
}, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,84 @@ | ||
import { build } from 'vite' | ||
import electronPath from 'electron' | ||
import { spawn } from 'child_process' | ||
import { build } from 'vite'; | ||
import electronPath from 'electron'; | ||
import { spawn } from 'node:child_process'; | ||
|
||
/** @type 'production' | 'development'' */ | ||
const mode = (process.env.MODE = process.env.MODE || 'development') | ||
/** @type {'production' | 'development'} */ | ||
const mode = (process.env.MODE = process.env.MODE || 'development'); | ||
|
||
/** @type {import('vite').LogLevel} */ | ||
const logLevel = 'warn' | ||
const logLevel = 'warn'; | ||
|
||
/** | ||
* Setup watcher for `main` package | ||
* On file changed it totally re-launch electron app. | ||
*/ | ||
function setupMainPackageWatcher() { | ||
/** @type {ChildProcess | null} */ | ||
let electronApp = null; | ||
/** @type {import('node:child_process').ChildProcess | null} */ | ||
let electronApp = null; | ||
|
||
return build({ | ||
mode, | ||
logLevel, | ||
configFile: 'vite.main.config.ts', | ||
build: { | ||
/** | ||
* Set to {} to enable rollup watcher | ||
* @see https://vitejs.dev/config/build-options.html#build-watch | ||
*/ | ||
watch: {}, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'reload-app-on-main-package-change', | ||
writeBundle() { | ||
/** Kill electron if process already exist */ | ||
if (electronApp !== null) { | ||
electronApp.removeListener('exit', process.exit); | ||
electronApp.kill('SIGINT'); | ||
electronApp = null; | ||
} | ||
return build({ | ||
mode, | ||
logLevel, | ||
configFile: 'vite.main.config.ts', | ||
build: { | ||
/** | ||
* Set to {} to enable rollup watcher | ||
* @see https://vitejs.dev/config/build-options.html#build-watch | ||
*/ | ||
watch: {}, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'reload-app-on-main-package-change-a', | ||
writeBundle() { | ||
/** Kill electron if process already exist */ | ||
if (electronApp !== null) { | ||
electronApp.removeListener('exit', () => process.exit()); | ||
electronApp.kill('SIGINT'); | ||
electronApp = null; | ||
} | ||
|
||
const args = process.env.CI ? ['--remote-debugging-port=9000', '--remote-allow-origins=http://127.0.0.1:9000' ] : ['--inspect=9223'] | ||
const args = process.env.CI | ||
? ['--remote-debugging-port=9000', '--remote-allow-origins=http://127.0.0.1:9000'] | ||
: ['--inspect=9223']; | ||
|
||
/** Spawn new electron process */ | ||
electronApp = spawn(String(electronPath), [...args, '.'], { | ||
stdio: 'inherit', | ||
}); | ||
/** Spawn new electron process */ | ||
electronApp = spawn(String(electronPath), [...args, '.'], { | ||
stdio: 'inherit', | ||
}); | ||
|
||
electronApp.addListener('') | ||
/** Stops the watch script when the application has been quit */ | ||
electronApp.addListener('exit', process.exit); | ||
}, | ||
}, | ||
], | ||
}); | ||
/** Stops the watch script when the application has been quit */ | ||
electronApp.addListener('exit', () => process.exit()); | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
/** | ||
* Setup watcher for `preload` package | ||
* On file changed it reload web page. | ||
*/ | ||
function setupPreloadPackageWatcher() { | ||
return build({ | ||
mode, | ||
logLevel, | ||
configFile: 'vite.preload.config.ts', | ||
build: { | ||
/** | ||
* Set to {} to enable rollup watcher | ||
* @see https://vitejs.dev/config/build-options.html#build-watch | ||
*/ | ||
watch: {}, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'reload-page-on-preload-package-change', | ||
writeBundle() {}, | ||
}, | ||
], | ||
}); | ||
return build({ | ||
mode, | ||
logLevel, | ||
configFile: 'vite.preload.config.ts', | ||
build: { | ||
/** | ||
* Set to {} to enable rollup watcher | ||
* @see https://vitejs.dev/config/build-options.html#build-watch | ||
*/ | ||
watch: {}, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'reload-page-on-preload-package-change', | ||
writeBundle() {}, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
(async () => { | ||
await setupPreloadPackageWatcher(); | ||
await setupMainPackageWatcher(); | ||
})(); | ||
await setupPreloadPackageWatcher(); | ||
await setupMainPackageWatcher(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.