eslint: consistent type imports

This commit is contained in:
Labhansh Agrawal 2023-06-26 14:59:50 +05:30
parent 0eb05e8416
commit 928209b914
65 changed files with 141 additions and 112 deletions

View file

@ -92,7 +92,13 @@
"@typescript-eslint/no-shadow": ["error"], "@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/restrict-template-expressions": "off" "@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{
"disallowTypeAnnotations": false
}
]
} }
}, },
{ {

View file

@ -1,4 +1,5 @@
import {app, Menu, BrowserWindow} from 'electron'; import type {BrowserWindow} from 'electron';
import {app, Menu} from 'electron';
import {openConfig, getConfig} from './config'; import {openConfig, getConfig} from './config';
import {updatePlugins} from './plugins'; import {updatePlugins} from './plugins';
import {installCLI} from './utils/cli-install'; import {installCLI} from './utils/cli-install';

View file

@ -4,7 +4,7 @@ import {_import, getDefaultConfig} from './config/import';
import _openConfig from './config/open'; import _openConfig from './config/open';
import {cfgPath, cfgDir} from './config/paths'; import {cfgPath, cfgDir} from './config/paths';
import {getColorMap} from './utils/colors'; import {getColorMap} from './utils/colors';
import {parsedConfig, configOptions} from '../lib/config'; import type {parsedConfig, configOptions} from '../lib/config';
import {app} from 'electron'; import {app} from 'electron';
const watchers: Function[] = []; const watchers: Function[] = [];

View file

@ -2,7 +2,7 @@ import {readFileSync, mkdirpSync} from 'fs-extra';
import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths'; import {defaultCfg, cfgPath, plugs, defaultPlatformKeyPath} from './paths';
import {_init} from './init'; import {_init} from './init';
import notify from '../notify'; import notify from '../notify';
import {rawConfig} from '../../lib/config'; import type {rawConfig} from '../../lib/config';
import {migrateHyper3Config} from './migrate'; import {migrateHyper3Config} from './migrate';
let defaultConfig: rawConfig; let defaultConfig: rawConfig;

View file

@ -1,7 +1,7 @@
import vm from 'vm'; import vm from 'vm';
import notify from '../notify'; import notify from '../notify';
import mapKeys from '../utils/map-keys'; import mapKeys from '../utils/map-keys';
import {parsedConfig, rawConfig, configOptions} from '../../lib/config'; import type {parsedConfig, rawConfig, configOptions} from '../../lib/config';
import _ from 'lodash'; import _ from 'lodash';
const _extract = (script?: vm.Script): Record<string, any> => { const _extract = (script?: vm.Script): Record<string, any> => {

View file

@ -1,5 +1,5 @@
import Config from 'electron-store'; import Config from 'electron-store';
import {BrowserWindow} from 'electron'; import type {BrowserWindow} from 'electron';
export const defaults = { export const defaults = {
windowPosition: [50, 50] as [number, number], windowPosition: [50, 50] as [number, number],

View file

@ -1,5 +1,6 @@
// Packages // Packages
import {app, dialog, Menu, BrowserWindow} from 'electron'; import type {BrowserWindow} from 'electron';
import {app, dialog, Menu} from 'electron';
// Utilities // Utilities
import {getConfig} from '../config'; import {getConfig} from '../config';

View file

@ -1,6 +1,7 @@
// This menu label is overrided by OSX to be the appName // This menu label is overrided by OSX to be the appName
// The label is set to appName here so it matches actual behavior // The label is set to appName here so it matches actual behavior
import {app, BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
import {app} from 'electron';
export default ( export default (
commandKeys: Record<string, string>, commandKeys: Record<string, string>,

View file

@ -1,4 +1,4 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default ( export default (
commandKeys: Record<string, string>, commandKeys: Record<string, string>,

View file

@ -1,5 +1,6 @@
import {release} from 'os'; import {release} from 'os';
import {app, shell, MenuItemConstructorOptions, dialog, clipboard} from 'electron'; import type {MenuItemConstructorOptions} from 'electron';
import {app, shell, dialog, clipboard} from 'electron';
import {getConfig, getPlugins} from '../../config'; import {getConfig, getPlugins} from '../../config';
const {arch, env, platform, versions} = process; const {arch, env, platform, versions} = process;
import {version} from '../../package.json'; import {version} from '../../package.json';

View file

@ -1,4 +1,4 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default ( export default (
commandKeys: Record<string, string>, commandKeys: Record<string, string>,

View file

@ -1,4 +1,4 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default ( export default (
commands: Record<string, string>, commands: Record<string, string>,

View file

@ -1,4 +1,4 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default ( export default (
commandKeys: Record<string, string>, commandKeys: Record<string, string>,

View file

@ -1,4 +1,4 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default ( export default (
commandKeys: Record<string, string>, commandKeys: Record<string, string>,

View file

@ -1,7 +1,7 @@
import ms from 'ms'; import ms from 'ms';
import fetch from 'electron-fetch'; import fetch from 'electron-fetch';
import {version} from './package.json'; import {version} from './package.json';
import {BrowserWindow} from 'electron'; import type {BrowserWindow} from 'electron';
const NEWS_URL = 'https://hyper-news.now.sh'; const NEWS_URL = 'https://hyper-news.now.sh';

View file

@ -1,7 +1,8 @@
/* eslint-disable eslint-comments/disable-enable-pair */ /* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
import {app, dialog, BrowserWindow, App, ipcMain as _ipcMain, MenuItemConstructorOptions} from 'electron'; import type {BrowserWindow, App, MenuItemConstructorOptions} from 'electron';
import {app, dialog, ipcMain as _ipcMain} from 'electron';
import {resolve, basename} from 'path'; import {resolve, basename} from 'path';
import {writeFileSync} from 'fs'; import {writeFileSync} from 'fs';
import Config from 'electron-store'; import Config from 'electron-store';
@ -14,10 +15,10 @@ import {availableExtensions} from './plugins/extensions';
import {install} from './plugins/install'; import {install} from './plugins/install';
import {plugs} from './config/paths'; import {plugs} from './config/paths';
import mapKeys from './utils/map-keys'; import mapKeys from './utils/map-keys';
import {configOptions} from '../lib/config'; import type {configOptions} from '../lib/config';
import {promisify} from 'util'; import {promisify} from 'util';
import {exec, execFile} from 'child_process'; import {exec, execFile} from 'child_process';
import {IpcMainWithCommands} from '../common'; import type {IpcMainWithCommands} from '../common';
// local storage // local storage
const cache = new Config(); const cache = new Config();

View file

@ -1,7 +1,8 @@
import {EventEmitter} from 'events'; import {EventEmitter} from 'events';
import {ipcMain, BrowserWindow, IpcMainEvent} from 'electron'; import type {BrowserWindow, IpcMainEvent} from 'electron';
import {ipcMain} from 'electron';
import {v4 as uuidv4} from 'uuid'; import {v4 as uuidv4} from 'uuid';
import {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../common'; import type {TypedEmitter, MainEvents, RendererEvents, FilterNever} from '../common';
export class Server { export class Server {
emitter: TypedEmitter<MainEvents>; emitter: TypedEmitter<MainEvents>;

View file

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

View file

@ -2,7 +2,7 @@ import editMenu from '../menus/menus/edit';
import shellMenu from '../menus/menus/shell'; import shellMenu from '../menus/menus/shell';
import {execCommand} from '../commands'; import {execCommand} from '../commands';
import {getDecoratedKeymaps} from '../plugins'; import {getDecoratedKeymaps} from '../plugins';
import {MenuItemConstructorOptions, BrowserWindow} from 'electron'; import type {MenuItemConstructorOptions, BrowserWindow} from 'electron';
const separator: MenuItemConstructorOptions = {type: 'separator'}; const separator: MenuItemConstructorOptions = {type: 'separator'};
const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> => const getCommandKeys = (keymaps: Record<string, string[]>): Record<string, string> =>

View file

@ -1,4 +1,5 @@
import {app, BrowserWindow, shell, Menu, BrowserWindowConstructorOptions} from 'electron'; import type {BrowserWindowConstructorOptions} from 'electron';
import {app, BrowserWindow, shell, Menu} from 'electron';
import {isAbsolute, normalize, sep} from 'path'; import {isAbsolute, normalize, sep} from 'path';
import {URL, fileURLToPath} from 'url'; import {URL, fileURLToPath} from 'url';
import {v4 as uuidv4} from 'uuid'; import {v4 as uuidv4} from 'uuid';
@ -15,7 +16,7 @@ import {execCommand} from '../commands';
import {setRendererType, unsetRendererType} from '../utils/renderer-utils'; import {setRendererType, unsetRendererType} from '../utils/renderer-utils';
import {decorateSessionOptions, decorateSessionClass} from '../plugins'; import {decorateSessionOptions, decorateSessionClass} from '../plugins';
import {enable as remoteEnable} from '@electron/remote/main'; import {enable as remoteEnable} from '@electron/remote/main';
import {configOptions} from '../../lib/config'; import type {configOptions} from '../../lib/config';
import {getWorkingDirectoryFromPID} from 'native-process-working-directory'; import {getWorkingDirectoryFromPID} from 'native-process-working-directory';
import {existsSync} from 'fs'; import {existsSync} from 'fs';

View file

@ -1,5 +1,6 @@
// Packages // Packages
import electron, {app, BrowserWindow, AutoUpdater} from 'electron'; import type {BrowserWindow, AutoUpdater} from 'electron';
import electron, {app} from 'electron';
import ms from 'ms'; import ms from 'ms';
import retry from 'async-retry'; import retry from 'async-retry';

View file

@ -1,6 +1,7 @@
// This is a CLI tool, using console is OK // This is a CLI tool, using console is OK
/* eslint no-console: 0 */ /* eslint no-console: 0 */
import {spawn, exec, SpawnOptions} from 'child_process'; import type {SpawnOptions} from 'child_process';
import {spawn, exec} from 'child_process';
import {isAbsolute, resolve} from 'path'; import {isAbsolute, resolve} from 'path';
import {existsSync} from 'fs'; import {existsSync} from 'fs';
import {version} from '../app/package.json'; import {version} from '../app/package.json';

View file

@ -1,6 +1,6 @@
import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config'; import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config';
import {HyperActions} from '../hyper'; import type {HyperActions} from '../hyper';
import {configOptions} from '../config'; import type {configOptions} from '../config';
export function loadConfig(config: configOptions): HyperActions { export function loadConfig(config: configOptions): HyperActions {
return { return {

View file

@ -8,7 +8,7 @@ import {
} from '../constants/ui'; } from '../constants/ui';
import rpc from '../rpc'; import rpc from '../rpc';
import {userExitTermGroup, setActiveGroup} from './term-groups'; import {userExitTermGroup, setActiveGroup} from './term-groups';
import {HyperDispatch} from '../hyper'; import type {HyperDispatch} from '../hyper';
export function closeTab(uid: string) { export function closeTab(uid: string) {
return (dispatch: HyperDispatch) => { return (dispatch: HyperDispatch) => {

View file

@ -1,6 +1,6 @@
import rpc from '../rpc'; import rpc from '../rpc';
import {INIT} from '../constants'; import {INIT} from '../constants';
import {HyperDispatch} from '../hyper'; import type {HyperDispatch} from '../hyper';
export default function init() { export default function init() {
return (dispatch: HyperDispatch) => { return (dispatch: HyperDispatch) => {

View file

@ -1,5 +1,5 @@
import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../constants/notifications'; import {NOTIFICATION_MESSAGE, NOTIFICATION_DISMISS} from '../constants/notifications';
import {HyperActions} from '../hyper'; import type {HyperActions} from '../hyper';
export function dismissNotification(id: string): HyperActions { export function dismissNotification(id: string): HyperActions {
return { return {

View file

@ -15,7 +15,7 @@ import {
SESSION_SET_XTERM_TITLE, SESSION_SET_XTERM_TITLE,
SESSION_SEARCH SESSION_SEARCH
} from '../constants/sessions'; } from '../constants/sessions';
import {HyperState, session, HyperDispatch, HyperActions} from '../hyper'; import type {HyperState, session, HyperDispatch, HyperActions} from '../hyper';
export function addSession({ export function addSession({
uid, uid,

View file

@ -10,7 +10,7 @@ import {SESSION_REQUEST} from '../constants/sessions';
import findBySession from '../utils/term-groups'; import findBySession from '../utils/term-groups';
import {getRootGroups} from '../selectors'; import {getRootGroups} from '../selectors';
import {setActiveSession, ptyExitSession, userExitSession} from './sessions'; import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
import {ITermState, ITermGroup, HyperState, HyperDispatch, HyperActions} from '../hyper'; import type {ITermState, ITermGroup, HyperState, HyperDispatch, HyperActions} from '../hyper';
function requestSplit(direction: 'VERTICAL' | 'HORIZONTAL') { function requestSplit(direction: 'VERTICAL' | 'HORIZONTAL') {
return (activeUid: string | undefined) => return (activeUid: string | undefined) =>

View file

@ -27,9 +27,10 @@ import {
} from '../constants/ui'; } from '../constants/ui';
import {setActiveGroup} from './term-groups'; import {setActiveGroup} from './term-groups';
import parseUrl from 'parse-url'; import type parseUrl from 'parse-url';
import {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper'; import type {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper';
import {stat, Stats} from 'fs'; import type {Stats} from 'fs';
import {stat} from 'fs';
export function openContextMenu(uid: string, selection: string) { export function openContextMenu(uid: string, selection: string) {
return (dispatch: HyperDispatch, getState: () => HyperState) => { return (dispatch: HyperDispatch, getState: () => HyperState) => {

View file

@ -1,6 +1,6 @@
import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../constants/updater'; import {UPDATE_INSTALL, UPDATE_AVAILABLE} from '../constants/updater';
import rpc from '../rpc'; import rpc from '../rpc';
import {HyperActions} from '../hyper'; import type {HyperActions} from '../hyper';
export function installUpdate(): HyperActions { export function installUpdate(): HyperActions {
return { return {

View file

@ -1,5 +1,5 @@
import {require as remoteRequire} from '@electron/remote'; import {require as remoteRequire} from '@electron/remote';
import {HyperDispatch} from './hyper'; import type {HyperDispatch} from './hyper';
import {closeSearch} from './actions/sessions'; import {closeSearch} from './actions/sessions';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31 // TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31

View file

@ -3,7 +3,7 @@ import React from 'react';
import {decorate, getTabsProps} from '../utils/plugins'; import {decorate, getTabsProps} from '../utils/plugins';
import Tabs_ from './tabs'; import Tabs_ from './tabs';
import {HeaderProps} from '../hyper'; import type {HeaderProps} from '../hyper';
const Tabs = decorate(Tabs_, 'Tabs'); const Tabs = decorate(Tabs_, 'Tabs');

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {NotificationProps, NotificationState} from '../hyper'; import type {NotificationProps, NotificationState} from '../hyper';
export default class Notification extends React.PureComponent<NotificationProps, NotificationState> { export default class Notification extends React.PureComponent<NotificationProps, NotificationState> {
dismissTimer!: NodeJS.Timeout; dismissTimer!: NodeJS.Timeout;

View file

@ -3,7 +3,7 @@ import React from 'react';
import {decorate} from '../utils/plugins'; import {decorate} from '../utils/plugins';
import Notification_ from './notification'; import Notification_ from './notification';
import {NotificationsProps} from '../hyper'; import type {NotificationsProps} from '../hyper';
const Notification = decorate(Notification_, 'Notification'); const Notification = decorate(Notification_, 'Notification');

View file

@ -1,5 +1,5 @@
import React, {useCallback} from 'react'; import React, {useCallback} from 'react';
import {SearchBoxProps} from '../hyper'; import type {SearchBoxProps} from '../hyper';
import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp'; import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp';
import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown'; import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown';
import {VscClose} from '@react-icons/all-files/vsc/VscClose'; import {VscClose} from '@react-icons/all-files/vsc/VscClose';

View file

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import {SplitPaneProps} from '../hyper'; import type {SplitPaneProps} from '../hyper';
export default class SplitPane extends React.PureComponent<SplitPaneProps, {dragging: boolean}> { export default class SplitPane extends React.PureComponent<SplitPaneProps, {dragging: boolean}> {
dragPanePosition!: number; dragPanePosition!: number;

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {StyleSheetProps} from '../hyper'; import type {StyleSheetProps} from '../hyper';
export default class StyleSheet extends React.PureComponent<StyleSheetProps> { export default class StyleSheet extends React.PureComponent<StyleSheetProps> {
render() { render() {

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {TabProps} from '../hyper'; import type {TabProps} from '../hyper';
export default class Tab extends React.PureComponent<TabProps> { export default class Tab extends React.PureComponent<TabProps> {
constructor(props: TabProps) { constructor(props: TabProps) {

View file

@ -3,7 +3,7 @@ import React from 'react';
import {decorate, getTabProps} from '../utils/plugins'; import {decorate, getTabProps} from '../utils/plugins';
import Tab_ from './tab'; import Tab_ from './tab';
import {TabsProps} from '../hyper'; import type {TabsProps} from '../hyper';
const Tab = decorate(Tab_, 'Tab'); const Tab = decorate(Tab_, 'Tab');
const isMac = /Mac/.test(navigator.userAgent); const isMac = /Mac/.test(navigator.userAgent);

View file

@ -4,7 +4,7 @@ import {decorate, getTermProps, getTermGroupProps} from '../utils/plugins';
import {resizeTermGroup} from '../actions/term-groups'; import {resizeTermGroup} from '../actions/term-groups';
import Term_ from './term'; import Term_ from './term';
import SplitPane_ from './split-pane'; import SplitPane_ from './split-pane';
import {HyperState, HyperDispatch, TermGroupProps, TermGroupOwnProps} from '../hyper'; import type {HyperState, HyperDispatch, TermGroupProps, TermGroupOwnProps} from '../hyper';
const Term = decorate(Term_, 'Term'); const Term = decorate(Term_, 'Term');
const SplitPane = decorate(SplitPane_, 'SplitPane'); const SplitPane = decorate(SplitPane_, 'SplitPane');

View file

@ -1,8 +1,10 @@
import React from 'react'; import React from 'react';
import {Terminal, ITerminalOptions, IDisposable} from 'xterm'; import type {ITerminalOptions, IDisposable} from 'xterm';
import {Terminal} from 'xterm';
import {FitAddon} from 'xterm-addon-fit'; import {FitAddon} from 'xterm-addon-fit';
import {WebLinksAddon} from 'xterm-addon-web-links'; import {WebLinksAddon} from 'xterm-addon-web-links';
import {SearchAddon, ISearchDecorationOptions} from 'xterm-addon-search'; import type {ISearchDecorationOptions} from 'xterm-addon-search';
import {SearchAddon} from 'xterm-addon-search';
import {WebglAddon} from 'xterm-addon-webgl'; import {WebglAddon} from 'xterm-addon-webgl';
import {CanvasAddon} from 'xterm-addon-canvas'; import {CanvasAddon} from 'xterm-addon-canvas';
import {LigaturesAddon} from 'xterm-addon-ligatures'; import {LigaturesAddon} from 'xterm-addon-ligatures';
@ -12,7 +14,7 @@ import Color from 'color';
import terms from '../terms'; import terms from '../terms';
import processClipboard from '../utils/paste'; import processClipboard from '../utils/paste';
import _SearchBox from './searchBox'; import _SearchBox from './searchBox';
import {TermProps} from '../hyper'; import type {TermProps} from '../hyper';
import {pickBy, isEqual} from 'lodash'; import {pickBy, isEqual} from 'lodash';
import {decorate} from '../utils/plugins'; import {decorate} from '../utils/plugins';
import 'xterm/css/xterm.css'; import 'xterm/css/xterm.css';

View file

@ -3,8 +3,8 @@ import {decorate, getTermGroupProps} from '../utils/plugins';
import {registerCommandHandlers} from '../command-registry'; import {registerCommandHandlers} from '../command-registry';
import TermGroup_ from './term-group'; import TermGroup_ from './term-group';
import StyleSheet_ from './style-sheet'; import StyleSheet_ from './style-sheet';
import {TermsProps, HyperDispatch} from '../hyper'; import type {TermsProps, HyperDispatch} from '../hyper';
import Term from './term'; import type Term from './term';
import {ObjectTypedKeys} from '../utils/object'; import {ObjectTypedKeys} from '../utils/object';
const TermGroup = decorate(TermGroup_, 'TermGroup'); const TermGroup = decorate(TermGroup_, 'TermGroup');

2
lib/config.d.ts vendored
View file

@ -1,4 +1,4 @@
import {FontWeight} from 'xterm'; import type {FontWeight} from 'xterm';
export type ColorMap = { export type ColorMap = {
black: string; black: string;

View file

@ -1,4 +1,4 @@
import {configOptions} from '../config'; import type {configOptions} from '../config';
export const CONFIG_LOAD = 'CONFIG_LOAD'; export const CONFIG_LOAD = 'CONFIG_LOAD';
export const CONFIG_RELOAD = 'CONFIG_RELOAD'; export const CONFIG_RELOAD = 'CONFIG_RELOAD';

View file

@ -4,7 +4,7 @@ import Header from '../components/header';
import {closeTab, changeTab, maximize, openHamburgerMenu, unmaximize, minimize, close} from '../actions/header'; import {closeTab, changeTab, maximize, openHamburgerMenu, unmaximize, minimize, close} from '../actions/header';
import {connect} from '../utils/plugins'; import {connect} from '../utils/plugins';
import {getRootGroups} from '../selectors'; import {getRootGroups} from '../selectors';
import {HyperState, HyperDispatch, ITab} from '../hyper'; import type {HyperState, HyperDispatch, ITab} from '../hyper';
const isMac = /Mac/.test(navigator.userAgent); const isMac = /Mac/.test(navigator.userAgent);

View file

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import Mousetrap, {MousetrapInstance} from 'mousetrap'; import type {MousetrapInstance} from 'mousetrap';
import Mousetrap from 'mousetrap';
import {connect} from '../utils/plugins'; import {connect} from '../utils/plugins';
import * as uiActions from '../actions/ui'; import * as uiActions from '../actions/ui';
@ -9,8 +10,8 @@ import stylis from 'stylis';
import {HeaderContainer} from './header'; import {HeaderContainer} from './header';
import TermsContainer from './terms'; import TermsContainer from './terms';
import NotificationsContainer from './notifications'; import NotificationsContainer from './notifications';
import {HyperState, HyperProps, HyperDispatch} from '../hyper'; import type {HyperState, HyperProps, HyperDispatch} from '../hyper';
import Terms from '../components/terms'; import type Terms from '../components/terms';
const isMac = /Mac/.test(navigator.userAgent); const isMac = /Mac/.test(navigator.userAgent);

View file

@ -2,7 +2,7 @@ import Notifications from '../components/notifications';
import {installUpdate} from '../actions/updater'; import {installUpdate} from '../actions/updater';
import {connect} from '../utils/plugins'; import {connect} from '../utils/plugins';
import {dismissNotification} from '../actions/notifications'; import {dismissNotification} from '../actions/notifications';
import {HyperState, HyperDispatch} from '../hyper'; import type {HyperState, HyperDispatch} from '../hyper';
const mapStateToProps = (state: HyperState) => { const mapStateToProps = (state: HyperState) => {
const {ui} = state; const {ui} = state;

View file

@ -11,7 +11,7 @@ import {
import {openContextMenu} from '../actions/ui'; import {openContextMenu} from '../actions/ui';
import {getRootGroups} from '../selectors'; import {getRootGroups} from '../selectors';
import {HyperState, HyperDispatch} from '../hyper'; import type {HyperState, HyperDispatch} from '../hyper';
const mapStateToProps = (state: HyperState) => { const mapStateToProps = (state: HyperState) => {
const {sessions} = state.sessions; const {sessions} = state.sessions;

48
lib/hyper.d.ts vendored
View file

@ -1,5 +1,5 @@
import {Immutable} from 'seamless-immutable'; import type {Immutable} from 'seamless-immutable';
import Client from './utils/rpc'; import type Client from './utils/rpc';
declare global { declare global {
interface Window { interface Window {
@ -38,8 +38,8 @@ export type ITermState = Immutable<{
}>; }>;
export type cursorShapes = 'BEAM' | 'UNDERLINE' | 'BLOCK'; export type cursorShapes = 'BEAM' | 'UNDERLINE' | 'BLOCK';
import {FontWeight, IWindowsPty, Terminal} from 'xterm'; import type {FontWeight, IWindowsPty, Terminal} from 'xterm';
import {ColorMap} from './config'; import type {ColorMap} from './config';
export type uiState = Immutable<{ export type uiState = Immutable<{
_lastUpdate: number | null; _lastUpdate: number | null;
@ -133,7 +133,7 @@ export type IUiReducer = Reducer<uiState, HyperActions>;
export type ISessionReducer = Reducer<sessionState, HyperActions>; export type ISessionReducer = Reducer<sessionState, HyperActions>;
import {Middleware, Reducer} from 'redux'; import type {Middleware, Reducer} from 'redux';
export type hyperPlugin = { export type hyperPlugin = {
getTabProps: any; getTabProps: any;
getTabsProps: any; getTabsProps: any;
@ -163,14 +163,14 @@ export type HyperState = {
termGroups: ITermState; termGroups: ITermState;
}; };
import {UIActions} from './constants/ui'; import type {UIActions} from './constants/ui';
import {ConfigActions} from './constants/config'; import type {ConfigActions} from './constants/config';
import {SessionActions} from './constants/sessions'; import type {SessionActions} from './constants/sessions';
import {NotificationActions} from './constants/notifications'; import type {NotificationActions} from './constants/notifications';
import {UpdateActions} from './constants/updater'; import type {UpdateActions} from './constants/updater';
import {TermGroupActions} from './constants/term-groups'; import type {TermGroupActions} from './constants/term-groups';
import {InitActions} from './constants'; import type {InitActions} from './constants';
import {TabActions} from './constants/tabs'; import type {TabActions} from './constants/tabs';
export type HyperActions = ( export type HyperActions = (
| UIActions | UIActions
@ -183,10 +183,10 @@ export type HyperActions = (
| TabActions | TabActions
) & {effect?: () => void}; ) & {effect?: () => void};
import configureStore from './store/configure-store'; import type configureStore from './store/configure-store';
export type HyperDispatch = ReturnType<typeof configureStore>['dispatch']; export type HyperDispatch = ReturnType<typeof configureStore>['dispatch'];
import {ReactChild} from 'react'; import type {ReactChild} from 'react';
type extensionProps = Partial<{ type extensionProps = Partial<{
customChildren: ReactChild | ReactChild[]; customChildren: ReactChild | ReactChild[];
customChildrenBefore: ReactChild | ReactChild[]; customChildrenBefore: ReactChild | ReactChild[];
@ -194,17 +194,17 @@ type extensionProps = Partial<{
customInnerChildren: ReactChild | ReactChild[]; customInnerChildren: ReactChild | ReactChild[];
}>; }>;
import {HeaderConnectedProps} from './containers/header'; import type {HeaderConnectedProps} from './containers/header';
export type HeaderProps = HeaderConnectedProps & extensionProps; export type HeaderProps = HeaderConnectedProps & extensionProps;
import {HyperConnectedProps} from './containers/hyper'; import type {HyperConnectedProps} from './containers/hyper';
export type HyperProps = HyperConnectedProps & extensionProps; export type HyperProps = HyperConnectedProps & extensionProps;
import {NotificationsConnectedProps} from './containers/notifications'; import type {NotificationsConnectedProps} from './containers/notifications';
export type NotificationsProps = NotificationsConnectedProps & extensionProps; export type NotificationsProps = NotificationsConnectedProps & extensionProps;
import Terms from './components/terms'; import type Terms from './components/terms';
import {TermsConnectedProps} from './containers/terms'; import type {TermsConnectedProps} from './containers/terms';
export type TermsProps = TermsConnectedProps & extensionProps & {ref_: (terms: Terms | null) => void}; export type TermsProps = TermsConnectedProps & extensionProps & {ref_: (terms: Terms | null) => void};
export type StyleSheetProps = { export type StyleSheetProps = {
@ -262,7 +262,7 @@ export type SplitPaneProps = {
sizes?: Immutable<number[]> | null; sizes?: Immutable<number[]> | null;
}; };
import Term from './components/term'; import type Term from './components/term';
export type TermGroupOwnProps = { export type TermGroupOwnProps = {
cursorAccentColor?: string; cursorAccentColor?: string;
@ -314,7 +314,7 @@ export type TermGroupOwnProps = {
| 'imageSupport' | 'imageSupport'
>; >;
import {TermGroupConnectedProps} from './components/term-group'; import type {TermGroupConnectedProps} from './components/term-group';
export type TermGroupProps = TermGroupConnectedProps & TermGroupOwnProps; export type TermGroupProps = TermGroupConnectedProps & TermGroupOwnProps;
export type SearchBoxProps = { export type SearchBoxProps = {
@ -335,8 +335,8 @@ export type SearchBoxProps = {
font: string; font: string;
}; };
import {FitAddon} from 'xterm-addon-fit'; import type {FitAddon} from 'xterm-addon-fit';
import {SearchAddon} from 'xterm-addon-search'; import type {SearchAddon} from 'xterm-addon-search';
export type TermProps = { export type TermProps = {
backgroundColor: string; backgroundColor: string;
bell: string; bell: string;

View file

@ -18,7 +18,7 @@ import {addNotificationMessage} from './actions/notifications';
import {loadConfig, reloadConfig} from './actions/config'; import {loadConfig, reloadConfig} from './actions/config';
import HyperContainer from './containers/hyper'; import HyperContainer from './containers/hyper';
import configureStore from './store/configure-store'; import configureStore from './store/configure-store';
import {configOptions} from './config'; import type {configOptions} from './config';
// On Linux, the default zoom was somehow changed with Electron 3 (or maybe 2). // On Linux, the default zoom was somehow changed with Electron 3 (or maybe 2).
// Setting zoom factor to 1.2 brings back the normal default size // Setting zoom factor to 1.2 brings back the normal default size

View file

@ -1,8 +1,9 @@
import {combineReducers, Reducer} from 'redux'; import type {Reducer} from 'redux';
import {combineReducers} from 'redux';
import ui from './ui'; import ui from './ui';
import sessions from './sessions'; import sessions from './sessions';
import termGroups from './term-groups'; import termGroups from './term-groups';
import {HyperActions, HyperState} from '../hyper'; import type {HyperActions, HyperState} from '../hyper';
export default combineReducers({ export default combineReducers({
ui, ui,

View file

@ -12,7 +12,7 @@ import {
SESSION_SET_CWD, SESSION_SET_CWD,
SESSION_SEARCH SESSION_SEARCH
} from '../constants/sessions'; } from '../constants/sessions';
import {sessionState, session, Mutable, ISessionReducer} from '../hyper'; import type {sessionState, session, Mutable, ISessionReducer} from '../hyper';
const initialState: sessionState = Immutable<Mutable<sessionState>>({ const initialState: sessionState = Immutable<Mutable<sessionState>>({
sessions: {}, sessions: {},

View file

@ -1,10 +1,12 @@
import {v4 as uuidv4} from 'uuid'; import {v4 as uuidv4} from 'uuid';
import Immutable, {Immutable as ImmutableType} from 'seamless-immutable'; import type {Immutable as ImmutableType} from 'seamless-immutable';
import Immutable from 'seamless-immutable';
import {TERM_GROUP_EXIT, TERM_GROUP_RESIZE} from '../constants/term-groups'; import {TERM_GROUP_EXIT, TERM_GROUP_RESIZE} from '../constants/term-groups';
import {SESSION_ADD, SESSION_SET_ACTIVE, SessionAddAction} from '../constants/sessions'; import type {SessionAddAction} from '../constants/sessions';
import {SESSION_ADD, SESSION_SET_ACTIVE} from '../constants/sessions';
import findBySession from '../utils/term-groups'; import findBySession from '../utils/term-groups';
import {decorateTermGroupsReducer} from '../utils/plugins'; import {decorateTermGroupsReducer} from '../utils/plugins';
import {ITermGroup, ITermState, ITermGroups, ITermGroupReducer, Mutable} from '../hyper'; import type {ITermGroup, ITermState, ITermGroups, ITermGroupReducer, Mutable} from '../hyper';
const MIN_SIZE = 0.05; const MIN_SIZE = 0.05;
const initialState: ITermState = Immutable<Mutable<ITermState>>({ const initialState: ITermState = Immutable<Mutable<ITermState>>({

View file

@ -1,4 +1,5 @@
import Immutable, {Immutable as ImmutableType} from 'seamless-immutable'; import type {Immutable as ImmutableType} from 'seamless-immutable';
import Immutable from 'seamless-immutable';
import {decorateUIReducer} from '../utils/plugins'; import {decorateUIReducer} from '../utils/plugins';
import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config'; import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config';
import { import {
@ -21,7 +22,7 @@ import {
SESSION_SET_CWD SESSION_SET_CWD
} from '../constants/sessions'; } from '../constants/sessions';
import {UPDATE_AVAILABLE} from '../constants/updater'; import {UPDATE_AVAILABLE} from '../constants/updater';
import {uiState, Mutable, IUiReducer} from '../hyper'; import type {uiState, Mutable, IUiReducer} from '../hyper';
import {release} from 'os'; import {release} from 'os';
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32'; const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32';

View file

@ -1,5 +1,5 @@
import {createSelector} from 'reselect'; import {createSelector} from 'reselect';
import {HyperState} from './hyper'; import type {HyperState} from './hyper';
const getTermGroups = ({termGroups}: Pick<HyperState, 'termGroups'>) => termGroups.termGroups; const getTermGroups = ({termGroups}: Pick<HyperState, 'termGroups'>) => termGroups.termGroups;
export const getRootGroups = createSelector(getTermGroups, (termGroups) => export const getRootGroups = createSelector(getTermGroups, (termGroups) =>

View file

@ -1,11 +1,12 @@
import {createStore, applyMiddleware} from 'redux'; import {createStore, applyMiddleware} from 'redux';
import _thunk, {ThunkMiddleware} from 'redux-thunk'; import type {ThunkMiddleware} from 'redux-thunk';
import _thunk from 'redux-thunk';
import rootReducer from '../reducers/index'; import rootReducer from '../reducers/index';
import effects from '../utils/effects'; import effects from '../utils/effects';
import * as plugins from '../utils/plugins'; import * as plugins from '../utils/plugins';
import writeMiddleware from './write-middleware'; import writeMiddleware from './write-middleware';
import {composeWithDevTools} from 'redux-devtools-extension'; import {composeWithDevTools} from 'redux-devtools-extension';
import {HyperState, HyperActions} from '../hyper'; import type {HyperState, HyperActions} from '../hyper';
const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk; const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk;
export default () => { export default () => {

View file

@ -1,10 +1,11 @@
import {createStore, applyMiddleware} from 'redux'; import {createStore, applyMiddleware} from 'redux';
import _thunk, {ThunkMiddleware} from 'redux-thunk'; import type {ThunkMiddleware} from 'redux-thunk';
import _thunk from 'redux-thunk';
import rootReducer from '../reducers/index'; import rootReducer from '../reducers/index';
import effects from '../utils/effects'; import effects from '../utils/effects';
import * as plugins from '../utils/plugins'; import * as plugins from '../utils/plugins';
import writeMiddleware from './write-middleware'; import writeMiddleware from './write-middleware';
import {HyperState, HyperActions} from '../hyper'; import type {HyperState, HyperActions} from '../hyper';
const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk; const thunk: ThunkMiddleware<HyperState, HyperActions> = _thunk;
export default () => export default () =>

View file

@ -1,6 +1,6 @@
import {HyperActions, HyperState} from '../hyper'; import type {HyperActions, HyperState} from '../hyper';
import terms from '../terms'; import terms from '../terms';
import {Dispatch, Middleware} from 'redux'; import type {Dispatch, Middleware} from 'redux';
// the only side effect we perform from middleware // the only side effect we perform from middleware
// is to write to the react term instance directly // is to write to the react term instance directly

View file

@ -1,4 +1,4 @@
import Term from './components/term'; import type Term from './components/term';
// react Term components add themselves // react Term components add themselves
// to this object upon mounting / unmounting // to this object upon mounting / unmounting

View file

@ -1,5 +1,5 @@
import {Dispatch, Middleware} from 'redux'; import type {Dispatch, Middleware} from 'redux';
import {HyperActions, HyperState} from '../hyper'; import type {HyperActions, HyperState} from '../hyper';
/** /**
* Simple redux middleware that executes * Simple redux middleware that executes
* the `effect` field if provided in an action * the `effect` field if provided in an action

View file

@ -10,7 +10,8 @@
* PR: https://github.com/kevva/executable/pull/10 * PR: https://github.com/kevva/executable/pull/10
*/ */
import fs, {Stats} from 'fs'; import type {Stats} from 'fs';
import fs from 'fs';
export function isExecutable(fileStat: Stats): boolean { export function isExecutable(fileStat: Stats): boolean {
if (process.platform === 'win32') { if (process.platform === 'win32') {

View file

@ -3,17 +3,19 @@
import {require as remoteRequire} from '@electron/remote'; import {require as remoteRequire} from '@electron/remote';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31 // TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
import {connect as reduxConnect, Options} from 'react-redux'; import type {Options} from 'react-redux';
import {connect as reduxConnect} from 'react-redux';
import {basename} from 'path'; import {basename} from 'path';
// patching Module._load // patching Module._load
// so plugins can `require` them without needing their own version // so plugins can `require` them without needing their own version
// https://github.com/vercel/hyper/issues/619 // https://github.com/vercel/hyper/issues/619
import React, {ComponentType, PureComponent} from 'react'; import type {ComponentType} from 'react';
import React, {PureComponent} from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import Notification from '../components/notification'; import Notification from '../components/notification';
import notify from './notify'; import notify from './notify';
import { import type {
hyperPlugin, hyperPlugin,
IUiReducer, IUiReducer,
ISessionReducer, ISessionReducer,
@ -27,7 +29,7 @@ import {
Assignable, Assignable,
HyperActions HyperActions
} from '../hyper'; } from '../hyper';
import {Dispatch, Middleware} from 'redux'; import type {Dispatch, Middleware} from 'redux';
import {ObjectTypedKeys} from './object'; import {ObjectTypedKeys} from './object';
import IPCChildProcess from './ipc-child-process'; import IPCChildProcess from './ipc-child-process';
import ChildProcess from 'child_process'; import ChildProcess from 'child_process';

View file

@ -1,7 +1,7 @@
import {EventEmitter} from 'events'; import {EventEmitter} from 'events';
import {IpcRenderer, IpcRendererEvent} from 'electron'; import type {IpcRenderer, IpcRendererEvent} from 'electron';
import electron from 'electron'; import electron from 'electron';
import {FilterNever, MainEvents, RendererEvents, TypedEmitter} from '../../common'; import type {FilterNever, MainEvents, RendererEvents, TypedEmitter} from '../../common';
export default class Client { export default class Client {
emitter: TypedEmitter<RendererEvents>; emitter: TypedEmitter<RendererEvents>;

View file

@ -1,4 +1,4 @@
import {ITermState} from '../hyper'; import type {ITermState} from '../hyper';
export default function findBySession(termGroupState: ITermState, sessionUid: string) { export default function findBySession(termGroupState: ITermState, sessionUid: string) {
const {termGroups} = termGroupState; const {termGroups} = termGroupState;

View file

@ -4,7 +4,8 @@ import fs from 'fs-extra';
// Packages // Packages
import test from 'ava'; import test from 'ava';
import {_electron, ElectronApplication} from 'playwright'; import type {ElectronApplication} from 'playwright';
import {_electron} from 'playwright';
let app: ElectronApplication; let app: ElectronApplication;