From e39d2a9b95e5c57b0731202da6e09eb2f6e508bd Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 31 Mar 2022 21:52:32 -0700 Subject: [PATCH] xo: Fix unicorn/prefer-node-protocol. Signed-off-by: Anders Kaseorg --- app/common/config-util.ts | 4 ++-- app/common/default-util.ts | 2 +- app/common/dnd-util.ts | 2 +- app/common/enterprise-util.ts | 6 +++--- app/common/link-util.ts | 6 +++--- app/common/logger-util.ts | 8 ++++---- app/common/remote.ts | 2 +- app/common/translation-util.ts | 2 +- app/main/autoupdater.ts | 4 ++-- app/main/badge-settings.ts | 2 +- app/main/handle-external-link.ts | 4 ++-- app/main/index.ts | 4 ++-- app/main/linux-update-util.ts | 4 ++-- app/main/menu.ts | 2 +- app/main/request.ts | 8 ++++---- app/main/startup.ts | 2 +- app/renderer/js/clipboard-decrypter.ts | 4 ++-- app/renderer/js/components/context-menu.ts | 2 +- app/renderer/js/components/server-tab.ts | 2 +- app/renderer/js/components/webview.ts | 6 +++--- app/renderer/js/electron-bridge.ts | 2 +- app/renderer/js/main.ts | 4 ++-- app/renderer/js/pages/preference/general-section.ts | 6 +++--- app/renderer/js/pages/preference/preference.ts | 2 +- app/renderer/js/pages/preference/shortcuts-section.ts | 2 +- app/renderer/js/preload.ts | 2 +- app/renderer/js/tray.ts | 4 ++-- app/renderer/js/utils/domain-util.ts | 4 ++-- package.json | 3 +-- 29 files changed, 52 insertions(+), 53 deletions(-) diff --git a/app/common/config-util.ts b/app/common/config-util.ts index 8c624ce6..e61dad38 100644 --- a/app/common/config-util.ts +++ b/app/common/config-util.ts @@ -1,5 +1,5 @@ -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; import * as Sentry from "@sentry/electron"; import {JsonDB} from "node-json-db"; diff --git a/app/common/default-util.ts b/app/common/default-util.ts index 5256dc31..157ae225 100644 --- a/app/common/default-util.ts +++ b/app/common/default-util.ts @@ -1,4 +1,4 @@ -import fs from "fs"; +import fs from "node:fs"; import {app} from "./remote"; diff --git a/app/common/dnd-util.ts b/app/common/dnd-util.ts index 89c87115..58fd849b 100644 --- a/app/common/dnd-util.ts +++ b/app/common/dnd-util.ts @@ -1,4 +1,4 @@ -import process from "process"; +import process from "node:process"; import type * as z from "zod"; diff --git a/app/common/enterprise-util.ts b/app/common/enterprise-util.ts index 99c71825..ac346578 100644 --- a/app/common/enterprise-util.ts +++ b/app/common/enterprise-util.ts @@ -1,6 +1,6 @@ -import fs from "fs"; -import path from "path"; -import process from "process"; +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; import * as z from "zod"; diff --git a/app/common/link-util.ts b/app/common/link-util.ts index 82764b5a..e72dd13e 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -1,7 +1,7 @@ import {shell} from "electron/common"; -import fs from "fs"; -import os from "os"; -import path from "path"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; import {html} from "./html"; diff --git a/app/common/logger-util.ts b/app/common/logger-util.ts index 14683167..27f638f4 100644 --- a/app/common/logger-util.ts +++ b/app/common/logger-util.ts @@ -1,7 +1,7 @@ -import {Console} from "console"; // eslint-disable-line node/prefer-global/console -import fs from "fs"; -import os from "os"; -import process from "process"; +import {Console} from "node:console"; +import fs from "node:fs"; +import os from "node:os"; +import process from "node:process"; import {initSetUp} from "./default-util"; import {app} from "./remote"; diff --git a/app/common/remote.ts b/app/common/remote.ts index 2e3c195f..ac80b6a0 100644 --- a/app/common/remote.ts +++ b/app/common/remote.ts @@ -1,4 +1,4 @@ -import process from "process"; +import process from "node:process"; export const {app, dialog} = process.type === "renderer" diff --git a/app/common/translation-util.ts b/app/common/translation-util.ts index 005e4463..e08a526c 100644 --- a/app/common/translation-util.ts +++ b/app/common/translation-util.ts @@ -1,4 +1,4 @@ -import path from "path"; +import path from "node:path"; import i18n from "i18n"; diff --git a/app/main/autoupdater.ts b/app/main/autoupdater.ts index 0655e55b..a114ac30 100644 --- a/app/main/autoupdater.ts +++ b/app/main/autoupdater.ts @@ -1,7 +1,7 @@ import {shell} from "electron/common"; import {app, dialog, session} from "electron/main"; -import process from "process"; -import util from "util"; +import process from "node:process"; +import util from "node:util"; import log from "electron-log"; import type {UpdateDownloadedEvent, UpdateInfo} from "electron-updater"; diff --git a/app/main/badge-settings.ts b/app/main/badge-settings.ts index 511aeab5..3620a62a 100644 --- a/app/main/badge-settings.ts +++ b/app/main/badge-settings.ts @@ -1,7 +1,7 @@ import {nativeImage} from "electron/common"; import type {BrowserWindow} from "electron/main"; import {app} from "electron/main"; -import process from "process"; +import process from "node:process"; import * as ConfigUtil from "../common/config-util"; diff --git a/app/main/handle-external-link.ts b/app/main/handle-external-link.ts index 83fb4545..3291dc8f 100644 --- a/app/main/handle-external-link.ts +++ b/app/main/handle-external-link.ts @@ -5,8 +5,8 @@ import type { WebContents, } from "electron/main"; import {Notification, app} from "electron/main"; -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; import * as ConfigUtil from "../common/config-util"; import * as LinkUtil from "../common/link-util"; diff --git a/app/main/index.ts b/app/main/index.ts index afaf7bb2..34eb61ee 100644 --- a/app/main/index.ts +++ b/app/main/index.ts @@ -1,7 +1,7 @@ import type {IpcMainEvent, WebContents} from "electron/main"; import {BrowserWindow, app, dialog, powerMonitor, session} from "electron/main"; -import path from "path"; -import process from "process"; +import path from "node:path"; +import process from "node:process"; import * as remoteMain from "@electron/remote/main"; import windowStateKeeper from "electron-window-state"; diff --git a/app/main/linux-update-util.ts b/app/main/linux-update-util.ts index 85977a29..4c2213b0 100644 --- a/app/main/linux-update-util.ts +++ b/app/main/linux-update-util.ts @@ -1,6 +1,6 @@ import {app, dialog} from "electron/main"; -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; import {JsonDB} from "node-json-db"; import {DataError} from "node-json-db/dist/lib/Errors"; diff --git a/app/main/menu.ts b/app/main/menu.ts index d296cd5c..65435e4d 100644 --- a/app/main/menu.ts +++ b/app/main/menu.ts @@ -1,7 +1,7 @@ import {shell} from "electron/common"; import type {MenuItemConstructorOptions} from "electron/main"; import {BrowserWindow, Menu, app} from "electron/main"; -import process from "process"; +import process from "node:process"; import AdmZip from "adm-zip"; diff --git a/app/main/request.ts b/app/main/request.ts index 3bcc1414..40fb89c4 100644 --- a/app/main/request.ts +++ b/app/main/request.ts @@ -1,9 +1,9 @@ import type {ClientRequest, IncomingMessage, Session} from "electron/main"; import {app, net} from "electron/main"; -import fs from "fs"; -import path from "path"; -import stream from "stream"; -import util from "util"; +import fs from "node:fs"; +import path from "node:path"; +import stream from "node:stream"; +import util from "node:util"; import * as Sentry from "@sentry/electron"; import getStream from "get-stream"; diff --git a/app/main/startup.ts b/app/main/startup.ts index cc6ec7a1..c65ca041 100644 --- a/app/main/startup.ts +++ b/app/main/startup.ts @@ -1,5 +1,5 @@ import {app} from "electron/main"; -import process from "process"; +import process from "node:process"; import AutoLaunch from "auto-launch"; diff --git a/app/renderer/js/clipboard-decrypter.ts b/app/renderer/js/clipboard-decrypter.ts index 8758e638..141e456d 100644 --- a/app/renderer/js/clipboard-decrypter.ts +++ b/app/renderer/js/clipboard-decrypter.ts @@ -1,6 +1,6 @@ -import {Buffer} from "buffer"; -import crypto from "crypto"; import {clipboard} from "electron/common"; +import {Buffer} from "node:buffer"; +import crypto from "node:crypto"; // This helper is exposed via electron_bridge for use in the social // login flow. diff --git a/app/renderer/js/components/context-menu.ts b/app/renderer/js/components/context-menu.ts index 1b96d6b3..50041be4 100644 --- a/app/renderer/js/components/context-menu.ts +++ b/app/renderer/js/components/context-menu.ts @@ -4,7 +4,7 @@ import type { ContextMenuParams, MenuItemConstructorOptions, } from "electron/renderer"; -import process from "process"; +import process from "node:process"; import {Menu} from "@electron/remote"; diff --git a/app/renderer/js/components/server-tab.ts b/app/renderer/js/components/server-tab.ts index c183fa9a..f3bcbff8 100644 --- a/app/renderer/js/components/server-tab.ts +++ b/app/renderer/js/components/server-tab.ts @@ -1,4 +1,4 @@ -import process from "process"; +import process from "node:process"; import type {Html} from "../../../common/html"; import {html} from "../../../common/html"; diff --git a/app/renderer/js/components/webview.ts b/app/renderer/js/components/webview.ts index bfc79e11..89fb302e 100644 --- a/app/renderer/js/components/webview.ts +++ b/app/renderer/js/components/webview.ts @@ -1,7 +1,7 @@ import type {WebContents} from "electron/main"; -import fs from "fs"; -import path from "path"; -import process from "process"; +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; import * as remote from "@electron/remote"; import {app, dialog} from "@electron/remote"; diff --git a/app/renderer/js/electron-bridge.ts b/app/renderer/js/electron-bridge.ts index 0e51f8ad..6635bec7 100644 --- a/app/renderer/js/electron-bridge.ts +++ b/app/renderer/js/electron-bridge.ts @@ -1,4 +1,4 @@ -import {EventEmitter} from "events"; +import {EventEmitter} from "node:events"; import type {ClipboardDecrypter} from "./clipboard-decrypter"; import {ClipboardDecrypterImpl} from "./clipboard-decrypter"; diff --git a/app/renderer/js/main.ts b/app/renderer/js/main.ts index 92074206..86eeb1dc 100644 --- a/app/renderer/js/main.ts +++ b/app/renderer/js/main.ts @@ -1,6 +1,6 @@ import {clipboard} from "electron/common"; -import path from "path"; -import process from "process"; +import path from "node:path"; +import process from "node:process"; import {Menu, app, dialog, session} from "@electron/remote"; import * as remote from "@electron/remote"; diff --git a/app/renderer/js/pages/preference/general-section.ts b/app/renderer/js/pages/preference/general-section.ts index cd927208..0ed2aee7 100644 --- a/app/renderer/js/pages/preference/general-section.ts +++ b/app/renderer/js/pages/preference/general-section.ts @@ -1,7 +1,7 @@ import type {OpenDialogOptions} from "electron/renderer"; -import fs from "fs"; -import path from "path"; -import process from "process"; +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; import * as remote from "@electron/remote"; import {app, dialog, session} from "@electron/remote"; diff --git a/app/renderer/js/pages/preference/preference.ts b/app/renderer/js/pages/preference/preference.ts index 1c3349a7..739be427 100644 --- a/app/renderer/js/pages/preference/preference.ts +++ b/app/renderer/js/pages/preference/preference.ts @@ -1,4 +1,4 @@ -import process from "process"; +import process from "node:process"; import type {DndSettings} from "../../../../common/dnd-util"; import {html} from "../../../../common/html"; diff --git a/app/renderer/js/pages/preference/shortcuts-section.ts b/app/renderer/js/pages/preference/shortcuts-section.ts index b962d9da..8030e78e 100644 --- a/app/renderer/js/pages/preference/shortcuts-section.ts +++ b/app/renderer/js/pages/preference/shortcuts-section.ts @@ -1,4 +1,4 @@ -import process from "process"; +import process from "node:process"; import {html} from "../../../../common/html"; import * as LinkUtil from "../../../../common/link-util"; diff --git a/app/renderer/js/preload.ts b/app/renderer/js/preload.ts index 018cc7cf..9b612ee8 100644 --- a/app/renderer/js/preload.ts +++ b/app/renderer/js/preload.ts @@ -1,5 +1,5 @@ import {contextBridge, webFrame} from "electron/renderer"; -import fs from "fs"; +import fs from "node:fs"; import electron_bridge, {bridgeEvents} from "./electron-bridge"; import * as NetworkError from "./pages/network"; diff --git a/app/renderer/js/tray.ts b/app/renderer/js/tray.ts index 0be984fe..4fab6bd8 100644 --- a/app/renderer/js/tray.ts +++ b/app/renderer/js/tray.ts @@ -1,8 +1,8 @@ import type {NativeImage} from "electron/common"; import {nativeImage} from "electron/common"; import type {Tray as ElectronTray} from "electron/main"; -import path from "path"; -import process from "process"; +import path from "node:path"; +import process from "node:process"; import {BrowserWindow, Menu, Tray} from "@electron/remote"; diff --git a/app/renderer/js/utils/domain-util.ts b/app/renderer/js/utils/domain-util.ts index f8f4694c..c64e0e6c 100644 --- a/app/renderer/js/utils/domain-util.ts +++ b/app/renderer/js/utils/domain-util.ts @@ -1,5 +1,5 @@ -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; import {app, dialog} from "@electron/remote"; import * as Sentry from "@sentry/electron"; diff --git a/package.json b/package.json index 300d68d2..594fd4bf 100644 --- a/package.json +++ b/package.json @@ -285,8 +285,7 @@ ], "strict": "error", "unicorn/prefer-json-parse-buffer": "off", - "unicorn/prefer-module": "off", - "unicorn/prefer-node-protocol": "off" + "unicorn/prefer-module": "off" }, "envs": [ "node",