build: add import/order eslint rule (#44108)

build: add import/order eslint rule (#44085)

* build: add import/order eslint rule

* chore: run lint:js --fix
This commit is contained in:
Samuel Attard 2024-10-03 15:21:54 -07:00 committed by GitHub
parent 6da785fd10
commit ba6d9291d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
208 changed files with 841 additions and 440 deletions

View file

@ -19,7 +19,40 @@
"prefer-const": ["error", {
"destructuring": "all"
}],
"n/no-callback-literal": "off"
"n/no-callback-literal": "off",
"import/newline-after-import": "error",
"import/order": ["error", {
"alphabetize": {
"order": "asc"
},
"newlines-between": "always",
"pathGroups": [
{
"pattern": "@electron/internal/**",
"group": "external",
"position": "before"
},
{
"pattern": "@electron/**",
"group": "external",
"position": "before"
},
{
"pattern": "{electron,electron/**}",
"group": "external",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": [],
"distinctGroup": true,
"groups": [
"external",
"builtin",
["sibling", "parent"],
"index",
"type"
]
}]
},
"parserOptions": {
"ecmaVersion": 6,

View file

@ -1,8 +1,9 @@
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const WrapperPlugin = require('wrapper-webpack-plugin');
const fs = require('node:fs');
const path = require('node:path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const WrapperPlugin = require('wrapper-webpack-plugin');
const electronRoot = path.resolve(__dirname, '../..');

View file

@ -1,5 +1,6 @@
import { shell } from 'electron/common';
import { app, dialog, BrowserWindow, ipcMain } from 'electron/main';
import * as path from 'node:path';
import * as url from 'node:url';

View file

@ -4,6 +4,7 @@ import * as fs from 'node:fs';
import { Module } from 'node:module';
import * as path from 'node:path';
import * as url from 'node:url';
const { app, dialog } = electron;
type DefaultAppOptions = {

View file

@ -1,7 +1,7 @@
import * as fs from 'fs';
import { Menu } from 'electron/main';
import * as fs from 'fs';
const bindings = process._linkedBinding('electron_browser_app');
const commandLine = process._linkedBinding('electron_common_command_line');
const { app } = bindings;

View file

@ -1,7 +1,9 @@
import { app } from 'electron/main';
import { EventEmitter } from 'events';
import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win';
import { app } from 'electron/main';
import { EventEmitter } from 'events';
class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
updateAvailable: boolean = false;
updateURL: string | null = null;

View file

@ -1,6 +1,6 @@
import { spawn, ChildProcessWithoutNullStreams } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { spawn, ChildProcessWithoutNullStreams } from 'child_process';
// i.e. my-app/app-0.1.13/
const appFolder = path.dirname(process.execPath);

View file

@ -1,6 +1,7 @@
import { EventEmitter } from 'events';
import type { BaseWindow as TLWT } from 'electron/main';
import { TouchBar } from 'electron/main';
import type { BaseWindow as TLWT } from 'electron/main';
import { EventEmitter } from 'events';
const { BaseWindow } = process._linkedBinding('electron_browser_base_window') as { BaseWindow: typeof TLWT };

View file

@ -1,5 +1,6 @@
import { BaseWindow, WebContents, BrowserView } from 'electron/main';
import type { BrowserWindow as BWT } from 'electron/main';
const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT };
Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype);

View file

@ -1,6 +1,7 @@
import { app } from 'electron/main';
import * as deprecate from '@electron/internal/common/deprecate';
import { app } from 'electron/main';
const binding = process._linkedBinding('electron_browser_crash_reporter');
class CrashReporter implements Electron.CrashReporter {

View file

@ -1,4 +1,5 @@
import { BrowserWindow } from 'electron/main';
const { createDesktopCapturer } = process._linkedBinding('electron_browser_desktop_capturer');
const deepEqual = (a: ElectronInternal.GetSourcesOptions, b: ElectronInternal.GetSourcesOptions) => JSON.stringify(a) === JSON.stringify(b);

View file

@ -1,5 +1,6 @@
import { app, BaseWindow } from 'electron/main';
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
const dialogBinding = process._linkedBinding('electron_browser_dialog');
enum SaveFileDialogProperties {

View file

@ -1,6 +1,6 @@
import { defineProperties } from '@electron/internal/common/define-properties';
import { commonModuleList } from '@electron/internal/common/api/module-list';
import { browserModuleList } from '@electron/internal/browser/api/module-list';
import { commonModuleList } from '@electron/internal/common/api/module-list';
import { defineProperties } from '@electron/internal/common/define-properties';
module.exports = {};

View file

@ -1,4 +1,5 @@
import * as roles from '@electron/internal/browser/api/menu-item-roles';
import { Menu, BaseWindow, WebContents, KeyboardEvent } from 'electron/main';
let nextCommandId = 0;

View file

@ -1,7 +1,8 @@
import { BaseWindow, MenuItem, webContents, Menu as MenuType, MenuItemConstructorOptions } from 'electron/main';
import { sortMenuItems } from '@electron/internal/browser/api/menu-utils';
import { setApplicationMenuWasSet } from '@electron/internal/browser/default-menu';
import { BaseWindow, MenuItem, webContents, Menu as MenuType, MenuItemConstructorOptions } from 'electron/main';
const bindings = process._linkedBinding('electron_browser_menu');
const { Menu } = bindings as { Menu: typeof MenuType };

View file

@ -1,5 +1,7 @@
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { EventEmitter } from 'events';
const { createPair } = process._linkedBinding('electron_browser_message_port');
export default class MessageChannelMain extends EventEmitter implements Electron.MessageChannelMain {

View file

@ -1,7 +1,9 @@
import { ClientRequestConstructorOptions, ClientRequest, IncomingMessage, Session as SessionT } from 'electron/main';
import { Readable, Writable, isReadable } from 'stream';
import { allowAnyProtocol } from '@electron/internal/common/api/net-client-request';
import { ClientRequestConstructorOptions, ClientRequest, IncomingMessage, Session as SessionT } from 'electron/main';
import { Readable, Writable, isReadable } from 'stream';
function createDeferredPromise<T, E extends Error = Error> (): { promise: Promise<T>; resolve: (x: T) => void; reject: (e: E) => void; } {
let res: (x: T) => void;
let rej: (e: E) => void;

View file

@ -1,6 +1,7 @@
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
import { app, IncomingMessage, session } from 'electron/main';
import type { ClientRequestConstructorOptions } from 'electron/main';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
const { isOnline } = process._linkedBinding('electron_common_net');

View file

@ -1,4 +1,5 @@
import { ProtocolRequest, session } from 'electron/main';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
import { ReadableStream } from 'stream/web';

View file

@ -1,5 +1,7 @@
import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';
import { net } from 'electron/main';
const { fromPartition, fromPath, Session } = process._linkedBinding('electron_browser_session');
Session.prototype.fetch = function (input: RequestInfo, init?: RequestInit) {

View file

@ -1,4 +1,5 @@
import { BrowserWindow, Menu, SharingItem, PopupOptions } from 'electron/main';
import { EventEmitter } from 'events';
class ShareMenu extends EventEmitter implements Electron.ShareMenu {

View file

@ -1,7 +1,9 @@
import { EventEmitter } from 'events';
import { Duplex, PassThrough } from 'stream';
import { Socket } from 'net';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { EventEmitter } from 'events';
import { Socket } from 'net';
import { Duplex, PassThrough } from 'stream';
const { _fork } = process._linkedBinding('electron_browser_utility_process');
class ForkUtilityProcess extends EventEmitter implements Electron.UtilityProcess {

View file

@ -1,4 +1,5 @@
import { EventEmitter } from 'events';
const { View } = process._linkedBinding('electron_browser_view');
Object.setPrototypeOf((View as any).prototype, EventEmitter.prototype);

View file

@ -1,16 +1,17 @@
import { app, ipcMain, session, webFrameMain, dialog } from 'electron/main';
import type { BrowserWindowConstructorOptions, MessageBoxOptions } from 'electron/main';
import * as url from 'url';
import * as path from 'path';
import { openGuestWindow, makeWebPreferences, parseContentTypeFormat } from '@electron/internal/browser/guest-window-manager';
import { parseFeatures } from '@electron/internal/browser/parse-features-string';
import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl';
import { parseFeatures } from '@electron/internal/browser/parse-features-string';
import * as deprecate from '@electron/internal/common/deprecate';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { app, ipcMain, session, webFrameMain, dialog } from 'electron/main';
import type { BrowserWindowConstructorOptions, MessageBoxOptions } from 'electron/main';
import * as path from 'path';
import * as url from 'url';
// session is not used here, the purpose is to make sure session is initialized
// before the webContents module.

View file

@ -1,5 +1,5 @@
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
const { WebFrameMain, fromId } = process._linkedBinding('electron_browser_web_frame_main');

View file

@ -1,5 +1,5 @@
import { app, Menu } from 'electron/main';
import { shell } from 'electron/common';
import { app, Menu } from 'electron/main';
const isMac = process.platform === 'darwin';

View file

@ -1,9 +1,10 @@
import { dialog, Menu } from 'electron/main';
import * as fs from 'fs';
import { IPC_MESSAGES } from '@electron/internal//common/ipc-messages';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
import { IPC_MESSAGES } from '@electron/internal//common/ipc-messages';
import { dialog, Menu } from 'electron/main';
import * as fs from 'fs';
const convertToMenuTemplate = function (items: ContextMenuItem[], handler: (id: number) => void) {
return items.map(function (item) {

View file

@ -1,10 +1,11 @@
import { webContents } from 'electron/main';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
import { parseWebViewWebPreferences } from '@electron/internal/browser/parse-features-string';
import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods';
import { webViewEvents } from '@electron/internal/browser/web-view-events';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods';
import { webContents } from 'electron/main';
interface GuestInstance {
elementInstanceId: number;

View file

@ -5,9 +5,10 @@
* out-of-process (cross-origin) are created here. "Embedder" roughly means
* "parent."
*/
import { parseFeatures } from '@electron/internal/browser/parse-features-string';
import { BrowserWindow } from 'electron/main';
import type { BrowserWindowConstructorOptions, Referrer, WebContents, LoadURLOptions } from 'electron/main';
import { parseFeatures } from '@electron/internal/browser/parse-features-string';
type PostData = LoadURLOptions['postData']
export type WindowOpenArgs = {

View file

@ -1,8 +1,9 @@
import type * as defaultMenuModule from '@electron/internal/browser/default-menu';
import { EventEmitter } from 'events';
import * as fs from 'fs';
import * as path from 'path';
import type * as defaultMenuModule from '@electron/internal/browser/default-menu';
import type * as url from 'url';
import type * as v8 from 'v8';

View file

@ -1,6 +1,7 @@
import { EventEmitter } from 'events';
import { IpcMainInvokeEvent } from 'electron/main';
import { EventEmitter } from 'events';
export class IpcMainImpl extends EventEmitter implements Electron.IpcMain {
private _invokeHandlers: Map<string, (e: IpcMainInvokeEvent, ...args: any[]) => void> = new Map();

View file

@ -1,9 +1,11 @@
import { clipboard } from 'electron/common';
import * as fs from 'fs';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { clipboard } from 'electron/common';
import * as fs from 'fs';
// Implements window.close()
ipcMainInternal.on(IPC_MESSAGES.BROWSER_WINDOW_CLOSE, function (event) {
const window = event.sender.getOwnerBrowserWindow();

View file

@ -1,10 +1,11 @@
import * as url from 'url';
import { Readable, Writable } from 'stream';
import type {
ClientRequestConstructorOptions,
UploadProgress
} from 'electron/common';
import { Readable, Writable } from 'stream';
import * as url from 'url';
const {
isValidHeaderName,
isValidHeaderValue,

View file

@ -1,7 +1,7 @@
import * as util from 'util';
import type * as stream from 'stream';
import timers = require('timers');
import * as util from 'util';
import type * as stream from 'stream';
type AnyFn = (...args: any[]) => any

View file

@ -1,3 +1,5 @@
/* eslint-disable import/newline-after-import */
/* eslint-disable import/order */
// Initialize ASAR support in fs module.
import { wrapFsWithAsar } from './asar-fs-wrapper';
wrapFsWithAsar(require('fs'));

View file

@ -1,5 +1,5 @@
import { defineProperties } from '@electron/internal/common/define-properties';
import { commonModuleList } from '@electron/internal/common/api/module-list';
import { defineProperties } from '@electron/internal/common/define-properties';
import { rendererModuleList } from '@electron/internal/renderer/api/module-list';
module.exports = {};

View file

@ -1,10 +1,10 @@
import { ipcRenderer } from 'electron/renderer';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import type * as securityWarningsModule from '@electron/internal/renderer/security-warnings';
import type * as webFrameInitModule from '@electron/internal/renderer/web-frame-init';
import type * as webViewInitModule from '@electron/internal/renderer/web-view/web-view-init';
import type * as windowSetupModule from '@electron/internal/renderer/window-setup';
import type * as webFrameInitModule from '@electron/internal/renderer/web-frame-init';
import type * as securityWarningsModule from '@electron/internal/renderer/security-warnings';
import { ipcRenderer } from 'electron/renderer';
const { mainFrame } = process._linkedBinding('electron_renderer_web_frame');
const v8Util = process._linkedBinding('electron_common_v8_util');
@ -49,6 +49,7 @@ if (process.isMainFrame) {
}
const { webFrameInit } = require('@electron/internal/renderer/web-frame-init') as typeof webFrameInitModule;
webFrameInit();
// Warn about security issues

View file

@ -1,10 +1,10 @@
import * as path from 'path';
import { pathToFileURL } from 'url';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal';
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
import * as path from 'path';
import { pathToFileURL } from 'url';
const Module = require('module') as NodeJS.ModuleInternal;
// We do not want to allow use of the VM module in the renderer process as

View file

@ -1,8 +1,9 @@
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
import { webFrame } from 'electron/renderer';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
const { contextIsolationEnabled } = internalContextBridge;

View file

@ -1,5 +1,5 @@
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame');

View file

@ -1,6 +1,7 @@
import { webFrame, WebFrame } from 'electron/renderer';
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
import { webFrame, WebFrame } from 'electron/renderer';
// All keys of WebFrame that extend Function
type WebFrameMethod = {

View file

@ -1,6 +1,6 @@
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame');

View file

@ -1,5 +1,5 @@
import type { WebViewImpl } from '@electron/internal/renderer/web-view/web-view-impl';
import { WEB_VIEW_ATTRIBUTES, WEB_VIEW_ERROR_MESSAGES } from '@electron/internal/renderer/web-view/web-view-constants';
import type { WebViewImpl } from '@electron/internal/renderer/web-view/web-view-impl';
const resolveURL = function (url?: string | null) {
return url ? new URL(url, location.href).href : '';

View file

@ -8,9 +8,9 @@
// which runs in browserify environment instead of Node environment, all native
// modules must be passed from outside, all included files must be plain JS.
import type { SrcAttribute } from '@electron/internal/renderer/web-view/web-view-attributes';
import { WEB_VIEW_ATTRIBUTES, WEB_VIEW_ERROR_MESSAGES } from '@electron/internal/renderer/web-view/web-view-constants';
import { WebViewImpl, WebViewImplHooks, setupMethods } from '@electron/internal/renderer/web-view/web-view-impl';
import type { SrcAttribute } from '@electron/internal/renderer/web-view/web-view-attributes';
const internals = new WeakMap<HTMLElement, WebViewImpl>();

View file

@ -1,8 +1,8 @@
import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal';
import { WEB_VIEW_ATTRIBUTES } from '@electron/internal/renderer/web-view/web-view-constants';
import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods';
import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal';
import type { WebViewAttribute, PartitionAttribute } from '@electron/internal/renderer/web-view/web-view-attributes';
import { setupWebViewAttributes } from '@electron/internal/renderer/web-view/web-view-attributes';
import { WEB_VIEW_ATTRIBUTES } from '@electron/internal/renderer/web-view/web-view-constants';
// ID generator.
let nextId = 0;

View file

@ -1,8 +1,7 @@
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import type * as webViewElementModule from '@electron/internal/renderer/web-view/web-view-element';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal';
import type * as webViewElementModule from '@electron/internal/renderer/web-view/web-view-element';
const v8Util = process._linkedBinding('electron_common_v8_util');
const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame');

View file

@ -1,6 +1,6 @@
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge';
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
const { contextIsolationEnabled } = internalContextBridge;

View file

@ -1,9 +1,9 @@
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal';
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
import * as events from 'events';
import { setImmediate, clearImmediate } from 'timers';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal';
declare const binding: {
get: (name: string) => any;

View file

@ -1,7 +1,8 @@
import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
import { IncomingMessage } from 'electron/utility';
import type { ClientRequestConstructorOptions } from 'electron/utility';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';
const { isOnline, resolveHost } = process._linkedBinding('electron_common_net');

View file

@ -1,8 +1,8 @@
import { ParentPort } from '@electron/internal/utility/parent-port';
import { EventEmitter } from 'events';
import { pathToFileURL } from 'url';
import { ParentPort } from '@electron/internal/utility/parent-port';
const v8Util = process._linkedBinding('electron_common_v8_util');
const entryScript: string = v8Util.getHiddenValue(process, '_serviceStartupScript');

View file

@ -1,5 +1,7 @@
import { EventEmitter } from 'events';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
import { EventEmitter } from 'events';
const { createParentPort } = process._linkedBinding('electron_utility_parent_port');
export class ParentPort extends EventEmitter implements Electron.ParentPort {

View file

@ -1,9 +1,9 @@
#!/usr/bin/env node
const electron = require('./');
const proc = require('child_process');
const electron = require('./');
const child = proc.spawn(electron, process.argv.slice(2), { stdio: 'inherit', windowsHide: false });
child.on('close', function (code, signal) {
if (code === null) {

View file

@ -1,13 +1,15 @@
#!/usr/bin/env node
const { version } = require('./package');
const { downloadArtifact } = require('@electron/get');
const extract = require('extract-zip');
const childProcess = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
const extract = require('extract-zip');
const { downloadArtifact } = require('@electron/get');
const { version } = require('./package');
if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
process.exit(0);

View file

@ -1,4 +1,5 @@
const { parseDocs } = require('@electron/docs-parser');
const fs = require('node:fs');
const path = require('node:path');

View file

@ -1,5 +1,8 @@
const args = require('minimist')(process.argv.slice(2));
const { Octokit } = require('@octokit/rest');
const minimist = require('minimist');
const args = minimist(process.argv.slice(2));
const octokit = new Octokit();
async function checkIfDocOnlyChange () {

View file

@ -1,6 +1,7 @@
const fs = require('node:fs');
const semver = require('semver');
const fs = require('node:fs');
const outputPath = process.argv[2];
const currentVersion = process.argv[3];

View file

@ -1,4 +1,5 @@
const asar = require('@electron/asar');
const crypto = require('node:crypto');
const fs = require('node:fs');

View file

@ -1,4 +1,5 @@
const asar = require('@electron/asar');
const assert = require('node:assert');
const fs = require('node:fs');
const os = require('node:os');

View file

@ -4,9 +4,12 @@ Usage:
$ node ./script/gn-check.js [--outDir=dirName]
*/
const minimist = require('minimist');
const cp = require('node:child_process');
const path = require('node:path');
const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] });
const args = minimist(process.argv.slice(2), { string: ['outDir'] });
const { getOutDir } = require('./lib/utils');

View file

@ -1,10 +1,13 @@
/* eslint-disable camelcase */
const { BlobServiceClient } = require('@azure/storage-blob');
const minimist = require('minimist');
const path = require('node:path');
const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.ELECTRON_ARTIFACTS_BLOB_STORAGE);
const args = require('minimist')(process.argv.slice(2));
const args = minimist(process.argv.slice(2));
let { prefix = '/', key_prefix = '', _: files } = args;
if (prefix && !prefix.endsWith(path.sep)) prefix = path.resolve(prefix) + path.sep;

View file

@ -1,5 +1,6 @@
const chalk = require('chalk');
const { GitProcess } = require('dugite');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');

View file

@ -1,14 +1,16 @@
#!/usr/bin/env node
const crypto = require('node:crypto');
const { GitProcess } = require('dugite');
const childProcess = require('node:child_process');
const { ESLint } = require('eslint');
const fs = require('node:fs');
const minimist = require('minimist');
const path = require('node:path');
const { getCodeBlocks } = require('@electron/lint-roller/dist/lib/markdown');
const { GitProcess } = require('dugite');
const { ESLint } = require('eslint');
const minimist = require('minimist');
const childProcess = require('node:child_process');
const crypto = require('node:crypto');
const fs = require('node:fs');
const path = require('node:path');
const { chunkFilenames, findMatchingFiles } = require('./lib/utils');
const ELECTRON_ROOT = path.normalize(path.dirname(__dirname));

View file

@ -1,3 +1,5 @@
const minimist = require('minimist');
const cp = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');
@ -13,7 +15,7 @@ if (!require.main) {
throw new Error('Must call the nan spec runner directly');
}
const args = require('minimist')(process.argv.slice(2), {
const args = minimist(process.argv.slice(2), {
string: ['only']
});

View file

@ -1,20 +1,23 @@
const minimist = require('minimist');
const cp = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');
const args = require('minimist')(process.argv.slice(2), {
const utils = require('./lib/utils');
const DISABLED_TESTS = require('./node-disabled-tests.json');
const args = minimist(process.argv.slice(2), {
boolean: ['default', 'validateDisabled'],
string: ['jUnitDir']
});
const BASE = path.resolve(__dirname, '../..');
const DISABLED_TESTS = require('./node-disabled-tests.json');
const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node');
const JUNIT_DIR = args.jUnitDir ? path.resolve(args.jUnitDir) : null;
const TAP_FILE_NAME = 'test.tap';
const utils = require('./lib/utils');
if (!require.main) {
throw new Error('Must call the node spec runner directly');
}

View file

@ -1,9 +1,12 @@
const { Octokit } = require('@octokit/rest');
const got = require('got');
const assert = require('node:assert');
const fs = require('node:fs');
const got = require('got');
const path = require('node:path');
const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js');
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit();
const APPVEYOR_IMAGES_URL = 'https://ci.appveyor.com/api/build-clouds';

View file

@ -1,4 +1,5 @@
const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth');
const cp = require('node:child_process');
async function main () {

View file

@ -1,4 +1,5 @@
import { parseArgs } from 'node:util';
import { cleanReleaseArtifacts } from '../release-artifact-cleanup';
const { values: { tag: _tag, releaseID } } = parseArgs({

View file

@ -1,13 +1,13 @@
import { Octokit } from '@octokit/rest';
import * as childProcess from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as semver from 'semver';
import * as temp from 'temp';
import { getCurrentBranch, ELECTRON_DIR } from '../../lib/utils';
import { getElectronVersion } from '../../lib/get-version';
import * as childProcess from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { getElectronVersion } from '../../lib/get-version';
import { getCurrentBranch, ELECTRON_DIR } from '../../lib/utils';
import { getAssetContents } from '../get-asset';
import { createGitHubTokenStrategy } from '../github-token';
import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types';

View file

@ -1,4 +1,5 @@
import { Octokit } from '@octokit/rest';
import { createGitHubTokenStrategy } from './github-token';
import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from './types';

View file

@ -1,5 +1,6 @@
import { Octokit } from '@octokit/rest';
import got from 'got';
import { createGitHubTokenStrategy } from './github-token';
import { ELECTRON_ORG, ElectronReleaseRepo } from './types';

View file

@ -1,4 +1,5 @@
import got from 'got';
import * as url from 'node:url';
const HASHER_FUNCTION_HOST = 'electron-artifact-hasher.azurewebsites.net';

View file

@ -1,15 +1,15 @@
#!/usr/bin/env node
import { Octokit } from '@octokit/rest';
import { GitProcess } from 'dugite';
import { basename } from 'node:path';
import { valid, compare, gte, lte } from 'semver';
import { ELECTRON_DIR } from '../../lib/utils';
import { get, render } from './notes';
import { Octokit } from '@octokit/rest';
import { createGitHubTokenStrategy } from '../github-token';
import { basename } from 'node:path';
import { parseArgs } from 'node:util';
import { get, render } from './notes';
import { ELECTRON_DIR } from '../../lib/utils';
import { createGitHubTokenStrategy } from '../github-token';
import { ELECTRON_ORG, ELECTRON_REPO } from '../types';
const octokit = new Octokit({

View file

@ -1,11 +1,11 @@
#!/usr/bin/env node
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { resolve as _resolve } from 'node:path';
import { Octokit } from '@octokit/rest';
import { GitProcess } from 'dugite';
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { resolve as _resolve } from 'node:path';
import { ELECTRON_DIR } from '../../lib/utils';
import { createGitHubTokenStrategy } from '../github-token';
import { ELECTRON_ORG, ELECTRON_REPO } from '../types';

View file

@ -1,14 +1,15 @@
import { Octokit } from '@octokit/rest';
import * as chalk from 'chalk';
import { GitProcess } from 'dugite';
import { execSync } from 'node:child_process';
import { join } from 'node:path';
import { runReleaseCIJobs } from './run-release-ci-jobs';
import releaseNotesGenerator from './notes';
import { getCurrentBranch, ELECTRON_DIR } from '../lib/utils.js';
import { createGitHubTokenStrategy } from './github-token';
import releaseNotesGenerator from './notes';
import { runReleaseCIJobs } from './run-release-ci-jobs';
import { ELECTRON_ORG, ElectronReleaseRepo, VersionBumpType } from './types';
import { getCurrentBranch, ELECTRON_DIR } from '../lib/utils.js';
const pass = chalk.green('✓');
const fail = chalk.red('✗');

View file

@ -4,17 +4,18 @@ import { BlobServiceClient } from '@azure/storage-blob';
import { Octokit } from '@octokit/rest';
import * as chalk from 'chalk';
import got from 'got';
import { execSync, ExecSyncOptions } from 'node:child_process';
import { statSync, createReadStream, writeFileSync, close } from 'node:fs';
import { join } from 'node:path';
import { gte } from 'semver';
import { track as trackTemp } from 'temp';
import { ELECTRON_DIR } from '../lib/utils';
import { getElectronVersion } from '../lib/get-version';
import { execSync, ExecSyncOptions } from 'node:child_process';
import { statSync, createReadStream, writeFileSync, close } from 'node:fs';
import { join } from 'node:path';
import { getUrlHash } from './get-url-hash';
import { createGitHubTokenStrategy } from './github-token';
import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from './types';
import { getElectronVersion } from '../lib/get-version';
import { ELECTRON_DIR } from '../lib/utils';
const temp = trackTemp();

View file

@ -1,5 +1,6 @@
import { Octokit } from '@octokit/rest';
import got, { OptionsOfTextResponseBody } from 'got';
import * as assert from 'node:assert';
import { createGitHubTokenStrategy } from './github-token';

View file

@ -1,5 +1,7 @@
import { Octokit } from '@octokit/rest';
import * as fs from 'node:fs';
import { createGitHubTokenStrategy } from '../github-token';
import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types';

View file

@ -2,7 +2,9 @@
import { valid, coerce, inc } from 'semver';
import { getElectronVersion } from '../lib/get-version';
import { parseArgs } from 'node:util';
import { VersionBumpType } from './types';
import {
isNightly,
isAlpha,
@ -12,8 +14,7 @@ import {
nextBeta,
isStable
} from './version-utils';
import { VersionBumpType } from './types';
import { parseArgs } from 'node:util';
import { getElectronVersion } from '../lib/get-version';
// run the script
async function main () {

View file

@ -1,5 +1,5 @@
import * as semver from 'semver';
import { GitProcess } from 'dugite';
import * as semver from 'semver';
import { ELECTRON_DIR } from '../lib/utils';

View file

@ -1,13 +1,14 @@
import * as childProcess from 'node:child_process';
import * as fs from 'node:fs';
import * as minimist from 'minimist';
import * as os from 'node:os';
import * as path from 'node:path';
import * as streamChain from 'stream-chain';
import * as streamJson from 'stream-json';
import { ignore as streamJsonIgnore } from 'stream-json/filters/Ignore';
import { streamArray as streamJsonStreamArray } from 'stream-json/streamers/StreamArray';
import * as childProcess from 'node:child_process';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { chunkFilenames, findMatchingFiles } from './lib/utils';
const SOURCE_ROOT = path.normalize(path.dirname(__dirname));

View file

@ -1,19 +1,23 @@
#!/usr/bin/env node
const { ElectronVersions, Installer } = require('@electron/fiddle-core');
const chalk = require('chalk');
const { hashElement } = require('folder-hash');
const minimist = require('minimist');
const childProcess = require('node:child_process');
const crypto = require('node:crypto');
const fs = require('node:fs');
const { hashElement } = require('folder-hash');
const os = require('node:os');
const path = require('node:path');
const unknownFlags = [];
const pass = chalk.green('✓');
const fail = chalk.red('✗');
const args = require('minimist')(process.argv, {
const args = minimist(process.argv, {
string: ['runners', 'target', 'electronVersion'],
unknown: arg => unknownFlags.push(arg)
});

View file

@ -1,6 +1,7 @@
const fs = require('node:fs');
const glob = require('glob');
const fs = require('node:fs');
const currentShard = parseInt(process.argv[2], 10);
const shardCount = parseInt(process.argv[3], 10);

View file

@ -1,5 +1,7 @@
const cp = require('node:child_process');
const utils = require('./lib/utils');
const electronPath = utils.getAbsoluteElectronExec();
const child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' });

View file

@ -1,18 +1,21 @@
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main';
import { assert, expect } from 'chai';
import * as semver from 'semver';
import split = require('split')
import * as cp from 'node:child_process';
import * as https from 'node:https';
import * as http from 'node:http';
import * as net from 'node:net';
import { once } from 'node:events';
import * as fs from 'node:fs';
import * as http from 'node:http';
import * as https from 'node:https';
import * as net from 'node:net';
import * as path from 'node:path';
import { promisify } from 'node:util';
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
import { collectStreamBody, getResponse } from './lib/net-helpers';
import { once } from 'node:events';
import split = require('split')
import * as semver from 'semver';
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
const fixturesPath = path.resolve(__dirname, 'fixtures');

View file

@ -1,8 +1,11 @@
import { autoUpdater } from 'electron/main';
import { expect } from 'chai';
import { ifit, ifdescribe } from './lib/spec-helpers';
import { once } from 'node:events';
import { ifit, ifdescribe } from './lib/spec-helpers';
ifdescribe(!process.mas)('autoUpdater module', function () {
describe('checkForUpdates', function () {
ifit(process.platform === 'win32')('emits an error on Windows if the feed URL is not set', async function () {

View file

@ -1,16 +1,19 @@
import { expect } from 'chai';
import * as cp from 'node:child_process';
import * as http from 'node:http';
import * as express from 'express';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as psList from 'ps-list';
import { AddressInfo } from 'node:net';
import { ifdescribe, ifit } from './lib/spec-helpers';
import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers';
import * as uuid from 'uuid';
import { autoUpdater, systemPreferences } from 'electron';
import { expect } from 'chai';
import * as express from 'express';
import * as psList from 'ps-list';
import * as uuid from 'uuid';
import * as cp from 'node:child_process';
import * as fs from 'node:fs';
import * as http from 'node:http';
import { AddressInfo } from 'node:net';
import * as path from 'node:path';
import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers';
import { withTempDirectory } from './lib/fs-helpers';
import { ifdescribe, ifit } from './lib/spec-helpers';
// We can only test the auto updater on darwin non-component builds
ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {

View file

@ -1,10 +1,13 @@
import { expect } from 'chai';
import * as path from 'node:path';
import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main';
import { closeWindow } from './lib/window-helpers';
import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers';
import { ScreenCapture } from './lib/screen-helpers';
import { expect } from 'chai';
import { once } from 'node:events';
import * as path from 'node:path';
import { ScreenCapture } from './lib/screen-helpers';
import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers';
import { closeWindow } from './lib/window-helpers';
describe('BrowserView module', () => {
const fixtures = path.resolve(__dirname, 'fixtures');

View file

@ -1,20 +1,22 @@
import { expect } from 'chai';
import * as childProcess from 'node:child_process';
import * as path from 'node:path';
import * as fs from 'node:fs';
import * as qs from 'node:querystring';
import * as http from 'node:http';
import * as os from 'node:os';
import { AddressInfo } from 'node:net';
import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main';
import { expect } from 'chai';
import * as childProcess from 'node:child_process';
import { once } from 'node:events';
import * as fs from 'node:fs';
import * as http from 'node:http';
import { AddressInfo } from 'node:net';
import * as os from 'node:os';
import * as path from 'node:path';
import * as qs from 'node:querystring';
import { setTimeout as syncSetTimeout } from 'node:timers';
import { setTimeout } from 'node:timers/promises';
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers';
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers';
import { once } from 'node:events';
import { setTimeout } from 'node:timers/promises';
import { setTimeout as syncSetTimeout } from 'node:timers';
const fixtures = path.resolve(__dirname, 'fixtures');
const mainFixtures = path.resolve(__dirname, 'fixtures');

View file

@ -1,9 +1,12 @@
import { expect } from 'chai';
import * as path from 'node:path';
import { Buffer } from 'node:buffer';
import { ifdescribe, ifit } from './lib/spec-helpers';
import { clipboard, nativeImage } from 'electron/common';
import { expect } from 'chai';
import { Buffer } from 'node:buffer';
import * as path from 'node:path';
import { ifdescribe, ifit } from './lib/spec-helpers';
// FIXME(zcbenz): Clipboard tests are failing on WOA.
ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard module', () => {
const fixtures = path.resolve(__dirname, 'fixtures');

View file

@ -1,8 +1,11 @@
import { expect } from 'chai';
import { app, contentTracing, TraceConfig, TraceCategoriesAndOptions } from 'electron/main';
import { expect } from 'chai';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { setTimeout } from 'node:timers/promises';
import { ifdescribe } from './lib/spec-helpers';
// FIXME: The tests are skipped on linux arm/arm64

View file

@ -1,15 +1,17 @@
import { BrowserWindow, ipcMain } from 'electron/main';
import { contextBridge } from 'electron/renderer';
import { expect } from 'chai';
import * as cp from 'node:child_process';
import { once } from 'node:events';
import * as fs from 'node:fs';
import * as http from 'node:http';
import * as os from 'node:os';
import * as path from 'node:path';
import * as cp from 'node:child_process';
import { closeWindow } from './lib/window-helpers';
import { listen } from './lib/spec-helpers';
import { once } from 'node:events';
import { closeWindow } from './lib/window-helpers';
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'context-bridge');

View file

@ -1,15 +1,18 @@
import { expect } from 'chai';
import * as childProcess from 'node:child_process';
import * as http from 'node:http';
import * as Busboy from 'busboy';
import * as path from 'node:path';
import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers';
import { app } from 'electron/main';
import * as Busboy from 'busboy';
import { expect } from 'chai';
import * as uuid from 'uuid';
import * as childProcess from 'node:child_process';
import { EventEmitter } from 'node:events';
import * as fs from 'node:fs';
import * as uuid from 'uuid';
import * as http from 'node:http';
import * as path from 'node:path';
import { setTimeout } from 'node:timers/promises';
import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers';
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
const isLinuxOnArm = process.platform === 'linux' && process.arch.includes('arm');

View file

@ -1,11 +1,14 @@
import { BrowserWindow } from 'electron/main';
import { expect } from 'chai';
import { once } from 'node:events';
import * as http from 'node:http';
import * as path from 'node:path';
import { BrowserWindow } from 'electron/main';
import { closeAllWindows } from './lib/window-helpers';
import { emittedUntil } from './lib/events-helpers';
import { listen } from './lib/spec-helpers';
import { once } from 'node:events';
import { closeAllWindows } from './lib/window-helpers';
describe('debugger module', () => {
const fixtures = path.resolve(__dirname, 'fixtures');

View file

@ -1,9 +1,11 @@
import { expect } from 'chai';
import { screen, desktopCapturer, BrowserWindow } from 'electron/main';
import { expect } from 'chai';
import { once } from 'node:events';
import { setTimeout } from 'node:timers/promises';
import { ifdescribe, ifit } from './lib/spec-helpers';
import { ifdescribe, ifit } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('desktopCapturer', () => {

View file

@ -1,9 +1,12 @@
import { expect } from 'chai';
import { dialog, BrowserWindow } from 'electron/main';
import { closeAllWindows } from './lib/window-helpers';
import { ifit } from './lib/spec-helpers';
import { expect } from 'chai';
import { setTimeout } from 'node:timers/promises';
import { ifit } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
describe('dialog module', () => {
describe('showOpenDialog', () => {
afterEach(closeAllWindows);

View file

@ -1,5 +1,7 @@
import { expect } from 'chai';
import { globalShortcut } from 'electron/main';
import { expect } from 'chai';
import { ifdescribe } from './lib/spec-helpers';
ifdescribe(process.platform !== 'win32')('globalShortcut module', () => {

View file

@ -1,5 +1,7 @@
import { expect } from 'chai';
import { inAppPurchase } from 'electron/main';
import { expect } from 'chai';
import { ifdescribe } from './lib/spec-helpers';
describe('inAppPurchase module', function () {

View file

@ -1,10 +1,13 @@
import { expect } from 'chai';
import * as path from 'node:path';
import * as cp from 'node:child_process';
import { closeAllWindows } from './lib/window-helpers';
import { defer } from './lib/spec-helpers';
import { ipcMain, BrowserWindow } from 'electron/main';
import { expect } from 'chai';
import * as cp from 'node:child_process';
import { once } from 'node:events';
import * as path from 'node:path';
import { defer } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
describe('ipc main module', () => {
const fixtures = path.join(__dirname, 'fixtures');

View file

@ -1,8 +1,11 @@
import { expect } from 'chai';
import { ipcMain, BrowserWindow } from 'electron/main';
import { closeWindow } from './lib/window-helpers';
import { expect } from 'chai';
import { once } from 'node:events';
import { closeWindow } from './lib/window-helpers';
describe('ipcRenderer module', () => {
let w: BrowserWindow;
before(async () => {

View file

@ -1,10 +1,13 @@
import { EventEmitter, once } from 'node:events';
import { expect } from 'chai';
import { BrowserWindow, ipcMain, IpcMainInvokeEvent, MessageChannelMain, WebContents } from 'electron/main';
import { closeAllWindows } from './lib/window-helpers';
import { defer, listen } from './lib/spec-helpers';
import * as path from 'node:path';
import { expect } from 'chai';
import { EventEmitter, once } from 'node:events';
import * as http from 'node:http';
import * as path from 'node:path';
import { defer, listen } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
const v8Util = process._linkedBinding('electron_common_v8_util');
const fixturesPath = path.resolve(__dirname, 'fixtures');

Some files were not shown because too many files have changed in this diff Show more