diff --git a/.lintstagedrc.js b/.lintstagedrc.js --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -38,6 +38,9 @@ '{landing,lib}/**/*.js': function landingFlow(files) { return 'yarn workspace landing flow --quiet'; }, + '{desktop,lib}/**/*.js': function desktopFlow(files) { + return 'yarn workspace desktop flow --quiet'; + }, 'services/identity/**/*.rs': function testIdentity(files) { return 'bash -c "cd services/identity && cargo test"'; }, diff --git a/desktop/.eslintrc.json b/desktop/.eslintrc.json --- a/desktop/.eslintrc.json +++ b/desktop/.eslintrc.json @@ -1,6 +1,3 @@ { - "rules": { - "flowtype/require-valid-file-annotation": "off" - }, "env": { "node": true } } diff --git a/desktop/.flowconfig b/desktop/.flowconfig new file mode 100644 --- /dev/null +++ b/desktop/.flowconfig @@ -0,0 +1,29 @@ +[include] +../lib + +[libs] +../lib/flow-typed + +[options] +exact_by_default=true + +format.bracket_spacing=false + +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import diff --git a/desktop/babel.config.cjs b/desktop/babel.config.cjs --- a/desktop/babel.config.cjs +++ b/desktop/babel.config.cjs @@ -1,6 +1,7 @@ module.exports = { presets: [ ['@babel/preset-env', { targets: { electron: 22 }, modules: 'commonjs' }], + '@babel/preset-flow', ], plugins: [ '@babel/plugin-proposal-class-properties', diff --git a/desktop/flow-typed/npm/electron_vx.x.x.js b/desktop/flow-typed/npm/electron_vx.x.x.js new file mode 100644 --- /dev/null +++ b/desktop/flow-typed/npm/electron_vx.x.x.js @@ -0,0 +1,19 @@ +// @flow +// flow-typed signature: f8bfa3876f1890f644b65b1ebd801ed8 +// flow-typed version: <>/electron_v22.0.0/flow_v0.182.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'electron' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'electron' { + declare module.exports: any; +} diff --git a/desktop/forge.config.cjs b/desktop/forge.config.cjs --- a/desktop/forge.config.cjs +++ b/desktop/forge.config.cjs @@ -61,7 +61,13 @@ packagerConfig: { name: 'Comm', icon: 'icons/icon', - ignore: ['src', '.*config\\.cjs', '\\.eslintrc\\.json'], + ignore: [ + 'src', + '.*config\\.cjs', + '\\.eslintrc\\.json', + '\\.flowconfig', + 'flow-typed', + ], appBundleId: 'app.comm.macos', osxSign: { identity: 'Developer ID Application' }, osxNotarize: { diff --git a/desktop/package.json b/desktop/package.json --- a/desktop/package.json +++ b/desktop/package.json @@ -34,6 +34,7 @@ "@electron-forge/maker-squirrel": "^6.0.4", "@electron-forge/plugin-base": "^6.0.4", "electron": "^22.0.0", + "flow-bin": "^0.182.0", "fs-extra": "^10.1.0", "klaw": "^4.0.1" } diff --git a/desktop/src/handle-squirrel-event.js b/desktop/src/handle-squirrel-event.js --- a/desktop/src/handle-squirrel-event.js +++ b/desktop/src/handle-squirrel-event.js @@ -1,3 +1,4 @@ +// @flow import { spawn } from 'child_process'; import { app } from 'electron'; import path from 'path'; @@ -6,7 +7,7 @@ // uninstalling and updating so we can for example create or delete shortcuts. // After handling some of these events the app will be closed. If this function // returns false, the app should start normally. -export function handleSquirrelEvent() { +export function handleSquirrelEvent(): boolean { if (process.argv.length === 1) { return false; } diff --git a/desktop/src/main.js b/desktop/src/main.js --- a/desktop/src/main.js +++ b/desktop/src/main.js @@ -1,3 +1,4 @@ +// @flow import { app, BrowserWindow, diff --git a/desktop/src/preload.js b/desktop/src/preload.js --- a/desktop/src/preload.js +++ b/desktop/src/preload.js @@ -1,3 +1,4 @@ +// @flow import { contextBridge, ipcRenderer } from 'electron'; const bridge = { diff --git a/native/.flowconfig b/native/.flowconfig --- a/native/.flowconfig +++ b/native/.flowconfig @@ -14,6 +14,7 @@ .*/comm/web/.* .*/comm/keyserver/.* +.*/comm/desktop/.* .*/android/app/build/.*