Skip to content

Commit

Permalink
sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal committed Jul 25, 2023
1 parent 692f94a commit 36ff6e9
Show file tree
Hide file tree
Showing 75 changed files with 350 additions and 219 deletions.
21 changes: 20 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,26 @@
"lodash/collection-return": "error",
"lodash/collection-method-value": "error",
"import/no-extraneous-dependencies": "error",
"import/no-anonymous-default-export": "error"
"import/no-anonymous-default-export": "error",
"import/order": [
"error",
{
"groups": [
"builtin",
"internal",
"external",
"parent",
"sibling",
"index"
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"orderImportKind": "desc",
"caseInsensitive": true
}
}
]
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion app/auto-updater-linux.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fetch from 'electron-fetch';
import {EventEmitter} from 'events';

import fetch from 'electron-fetch';

class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
updateURL!: string;
quitAndInstall() {
Expand Down
3 changes: 2 additions & 1 deletion app/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {BrowserWindow} from 'electron';
import {app, Menu} from 'electron';
import type {BrowserWindow} from 'electron';

import {openConfig, getConfig} from './config';
import {updatePlugins} from './plugins';
import {installCLI} from './utils/cli-install';
Expand Down
9 changes: 6 additions & 3 deletions app/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import {app} from 'electron';

import chokidar from 'chokidar';
import notify from './notify';

import type {parsedConfig, configOptions} from '../typings/config';

import {_import, getDefaultConfig} from './config/import';
import _openConfig from './config/open';
import {cfgPath, cfgDir} from './config/paths';
import notify from './notify';
import {getColorMap} from './utils/colors';
import type {parsedConfig, configOptions} from '../typings/config';
import {app} from 'electron';

const watchers: Function[] = [];
let cfg: parsedConfig = {} as any;
Expand Down
8 changes: 5 additions & 3 deletions app/config/import.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {readFileSync, mkdirpSync} from 'fs-extra';
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
import {_init} from './init';
import notify from '../notify';

import type {rawConfig} from '../../typings/config';
import notify from '../notify';

import {_init} from './init';
import {migrateHyper3Config} from './migrate';
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';

let defaultConfig: rawConfig;

Expand Down
6 changes: 4 additions & 2 deletions app/config/init.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import vm from 'vm';

import merge from 'lodash/merge';

import type {parsedConfig, rawConfig, configOptions} from '../../typings/config';
import notify from '../notify';
import mapKeys from '../utils/map-keys';
import type {parsedConfig, rawConfig, configOptions} from '../../typings/config';
import merge from 'lodash/merge';

const _extract = (script?: vm.Script): Record<string, any> => {
const module: Record<string, any> = {};
Expand Down
10 changes: 6 additions & 4 deletions app/config/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {parse, prettyPrint} from 'recast';
import {dirname, resolve} from 'path';

import {builders, namedTypes} from 'ast-types';
import * as babelParser from 'recast/parsers/babel';
import type {ExpressionKind} from 'ast-types/lib/gen/kinds';
import {copy, copySync, existsSync, readFileSync, writeFileSync} from 'fs-extra';
import {dirname, resolve} from 'path';
import merge from 'lodash/merge';
import {parse, prettyPrint} from 'recast';
import * as babelParser from 'recast/parsers/babel';

import notify from '../notify';

import {_extractDefault} from './init';
import {cfgDir, cfgPath, defaultCfg, legacyCfgPath, plugs, schemaFile, schemaPath} from './paths';
import type {ExpressionKind} from 'ast-types/lib/gen/kinds';

// function to remove all json serializable entries from an array expression
function removeElements(node: namedTypes.ArrayExpression): namedTypes.ArrayExpression {
Expand Down
7 changes: 5 additions & 2 deletions app/config/open.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {exec} from 'child_process';

import {shell} from 'electron';
import {cfgPath} from './paths';

import * as Registry from 'native-reg';
import {exec} from 'child_process';

import {cfgPath} from './paths';

const getUserChoiceKey = () => {
try {
Expand Down
6 changes: 4 additions & 2 deletions app/config/paths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// This module exports paths, names, and other metadata that is referenced
import {homedir} from 'os';
import {app} from 'electron';
import {statSync} from 'fs';
import {homedir} from 'os';
import {resolve, join} from 'path';

import {app} from 'electron';

import isDev from 'electron-is-dev';

const cfgFile = 'hyper.json';
Expand Down
3 changes: 2 additions & 1 deletion app/config/windows.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Config from 'electron-store';
import type {BrowserWindow} from 'electron';

import Config from 'electron-store';

export const defaults = {
windowPosition: [50, 50] as [number, number],
windowSize: [540, 380] as [number, number]
Expand Down
20 changes: 12 additions & 8 deletions app/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/order
import {cfgPath} from './config/paths';

// Print diagnostic information for a few arguments instead of running Hyper.
Expand All @@ -11,27 +12,30 @@ if (['--help', '-v', '--version'].includes(process.argv[1])) {
}

// Enable remote module
// eslint-disable-next-line import/order
import {initialize as remoteInitialize} from '@electron/remote/main';
remoteInitialize();

// set up config
// eslint-disable-next-line import/order
import * as config from './config';
config.setup();

// Native
import {resolve} from 'path';

// Packages
import {app, BrowserWindow, Menu, screen} from 'electron';
import {gitDescribe} from 'git-describe';
import isDev from 'electron-is-dev';
import * as config from './config';

// set up config
config.setup();
import isDev from 'electron-is-dev';
import {gitDescribe} from 'git-describe';
import parseUrl from 'parse-url';

import * as plugins from './plugins';
import {installCLI} from './utils/cli-install';
import * as AppMenu from './menus/menu';
import * as plugins from './plugins';
import {newWindow} from './ui/window';
import {installCLI} from './utils/cli-install';
import * as windowUtils from './utils/window-utils';
import parseUrl from 'parse-url';

const windowSet = new Set<BrowserWindow>([]);

Expand Down
17 changes: 9 additions & 8 deletions app/menus/menu.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// Packages
import type {BrowserWindow} from 'electron';
import {app, dialog, Menu} from 'electron';
import type {BrowserWindow} from 'electron';

// Utilities
import {execCommand} from '../commands';
import {getConfig} from '../config';
import {icon} from '../config/paths';
import viewMenu from './menus/view';
import shellMenu from './menus/shell';
import {getDecoratedKeymaps} from '../plugins';
import {getRendererTypes} from '../utils/renderer-utils';

import darwinMenu from './menus/darwin';
import editMenu from './menus/edit';
import helpMenu from './menus/help';
import shellMenu from './menus/shell';
import toolsMenu from './menus/tools';
import viewMenu from './menus/view';
import windowMenu from './menus/window';
import helpMenu from './menus/help';
import darwinMenu from './menus/darwin';
import {getDecoratedKeymaps} from '../plugins';
import {execCommand} from '../commands';
import {getRendererTypes} from '../utils/renderer-utils';

const appName = app.name;
const appVersion = app.getVersion();
Expand Down
2 changes: 1 addition & 1 deletion app/menus/menus/darwin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This menu label is overrided by OSX to be the appName
// The label is set to appName here so it matches actual behavior
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
import {app} from 'electron';
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';

const darwinMenu = (
commandKeys: Record<string, string>,
Expand Down
7 changes: 5 additions & 2 deletions app/menus/menus/help.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {release} from 'os';
import type {MenuItemConstructorOptions} from 'electron';

import {app, shell, dialog, clipboard} from 'electron';
import type {MenuItemConstructorOptions} from 'electron';

import {getConfig, getPlugins} from '../../config';
const {arch, env, platform, versions} = process;
import {version} from '../../package.json';

const {arch, env, platform, versions} = process;

const helpMenu = (commands: Record<string, string>, showAbout: () => void): MenuItemConstructorOptions => {
const submenu: MenuItemConstructorOptions[] = [
{
Expand Down
6 changes: 4 additions & 2 deletions app/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ms from 'ms';
import type {BrowserWindow} from 'electron';

import fetch from 'electron-fetch';
import ms from 'ms';

import {version} from './package.json';
import type {BrowserWindow} from 'electron';

const NEWS_URL = 'https://hyper-news.now.sh';

Expand Down
1 change: 1 addition & 0 deletions app/notify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {app, Notification} from 'electron';

import {icon} from './config/paths';

export default function notify(title: string, body = '', details: {error?: any} = {}) {
Expand Down
22 changes: 13 additions & 9 deletions app/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
import {app, dialog, ipcMain as _ipcMain} from 'electron';
import {resolve, basename} from 'path';
import {exec, execFile} from 'child_process';
import {writeFileSync} from 'fs';
import {resolve, basename} from 'path';
import {promisify} from 'util';

import {app, dialog, ipcMain as _ipcMain} from 'electron';
import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
import React from 'react';

import Config from 'electron-store';
import ms from 'ms';
import React from 'react';
import ReactDom from 'react-dom';

import type {IpcMainWithCommands} from '../typings/common';
import type {configOptions} from '../typings/config';

import * as config from './config';
import {plugs} from './config/paths';
import notify from './notify';
import {availableExtensions} from './plugins/extensions';
import {install} from './plugins/install';
import {plugs} from './config/paths';
import mapKeys from './utils/map-keys';
import type {configOptions} from '../typings/config';
import {promisify} from 'util';
import {exec, execFile} from 'child_process';
import type {IpcMainWithCommands} from '../typings/common';

// local storage
const cache = new Config();
Expand Down
4 changes: 3 additions & 1 deletion app/plugins/install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import cp from 'child_process';
import queue from 'queue';

import ms from 'ms';
import queue from 'queue';

import {yarn, plugs} from '../config/paths';

export const install = (fn: (err: string | null) => void) => {
Expand Down
5 changes: 4 additions & 1 deletion app/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {EventEmitter} from 'events';
import type {BrowserWindow, IpcMainEvent} from 'electron';

import {ipcMain} from 'electron';
import type {BrowserWindow, IpcMainEvent} from 'electron';

import {v4 as uuidv4} from 'uuid';

import type {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../typings/common';

export class Server {
Expand Down
14 changes: 8 additions & 6 deletions app/session.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {EventEmitter} from 'events';
import {dirname} from 'path';
import {StringDecoder} from 'string_decoder';

import defaultShell from 'default-shell';
import {getDecoratedEnv} from './plugins';
import {productName, version} from './package.json';
import * as config from './config';
import type {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty';
import {cliScriptPath} from './config/paths';
import {dirname} from 'path';
import shellEnv from 'shell-env';
import osLocale from 'os-locale';
import shellEnv from 'shell-env';

import * as config from './config';
import {cliScriptPath} from './config/paths';
import {productName, version} from './package.json';
import {getDecoratedEnv} from './plugins';

const createNodePtyError = () =>
new Error(
Expand Down
8 changes: 5 additions & 3 deletions app/ui/contextmenu.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';

import {execCommand} from '../commands';
import {getProfiles} from '../config';
import editMenu from '../menus/menus/edit';
import shellMenu from '../menus/menus/shell';
import {execCommand} from '../commands';
import {getDecoratedKeymaps} from '../plugins';
import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';
import {getProfiles} from '../config';

const separator: MenuItemConstructorOptions = {type: 'separator'};

const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> =>
Expand Down
Loading

0 comments on commit 36ff6e9

Please sign in to comment.