From 41b1ac1852bec5e34a61c897a4b262073aa996a7 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Wed, 25 Mar 2020 15:45:08 +0530 Subject: [PATCH] fix prettier errors --- app/commands.ts | 58 +++++++++---------- app/config.ts | 10 ++-- app/config/open.ts | 14 ++--- app/index.ts | 4 +- app/menus/menu.ts | 2 +- app/notifications.ts | 4 +- app/plugins.ts | 30 +++++----- app/plugins/install.ts | 2 +- app/session.ts | 4 +- app/ui/contextmenu.ts | 2 +- app/ui/window.ts | 8 +-- app/updater.ts | 2 +- app/utils/cli-install.ts | 14 ++--- app/utils/colors.ts | 2 +- app/utils/map-keys.ts | 4 +- app/utils/to-electron-background-color.ts | 5 +- cli/api.ts | 10 ++-- cli/index.ts | 30 +++++----- lib/actions/term-groups.ts | 2 +- lib/actions/ui.ts | 2 +- lib/components/notifications.tsx | 6 +- lib/components/searchBox.tsx | 2 +- lib/components/term-group.tsx | 4 +- lib/components/term.tsx | 8 +-- lib/components/terms.tsx | 6 +- lib/containers/hyper.tsx | 2 +- lib/ext-modules.d.ts | 4 +- lib/index.tsx | 12 ++-- lib/reducers/term-groups.ts | 4 +- lib/selectors.ts | 4 +- lib/store/write-middleware.ts | 2 +- lib/utils/effects.ts | 2 +- lib/utils/plugins.ts | 16 ++--- lib/utils/term-groups.ts | 4 +- release.js | 2 +- test/index.ts | 2 +- test/unit/cli-api.test.ts | 4 +- .../unit/to-electron-background-color.test.ts | 4 +- test/unit/window-utils.test.ts | 6 +- 39 files changed, 150 insertions(+), 153 deletions(-) diff --git a/app/commands.ts b/app/commands.ts index 4b5fdf15..d1e08171 100644 --- a/app/commands.ts +++ b/app/commands.ts @@ -8,41 +8,41 @@ const commands: Record void> = { // If window is created on the same tick, it will consume event too setTimeout(app.createWindow, 0); }, - 'tab:new': focusedWindow => { + 'tab:new': (focusedWindow) => { if (focusedWindow) { focusedWindow.rpc.emit('termgroup add req', {}); } else { setTimeout(app.createWindow, 0); } }, - 'pane:splitRight': focusedWindow => { + 'pane:splitRight': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('split request vertical', {}); }, - 'pane:splitDown': focusedWindow => { + 'pane:splitDown': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('split request horizontal', {}); }, - 'pane:close': focusedWindow => { + 'pane:close': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('termgroup close req'); }, 'window:preferences': () => { openConfig(); }, - 'editor:clearBuffer': focusedWindow => { + 'editor:clearBuffer': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session clear req'); }, - 'editor:selectAll': focusedWindow => { + 'editor:selectAll': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('term selectAll'); }, 'plugins:update': () => { updatePlugins(); }, - 'window:reload': focusedWindow => { + 'window:reload': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('reload'); }, - 'window:reloadFull': focusedWindow => { + 'window:reloadFull': (focusedWindow) => { focusedWindow && focusedWindow.reload(); }, - 'window:devtools': focusedWindow => { + 'window:devtools': (focusedWindow) => { if (!focusedWindow) { return; } @@ -53,58 +53,58 @@ const commands: Record void> = { webContents.openDevTools({mode: 'detach'}); } }, - 'zoom:reset': focusedWindow => { + 'zoom:reset': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('reset fontSize req'); }, - 'zoom:in': focusedWindow => { + 'zoom:in': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('increase fontSize req'); }, - 'zoom:out': focusedWindow => { + 'zoom:out': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('decrease fontSize req'); }, - 'tab:prev': focusedWindow => { + 'tab:prev': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('move left req'); }, - 'tab:next': focusedWindow => { + 'tab:next': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('move right req'); }, - 'pane:prev': focusedWindow => { + 'pane:prev': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('prev pane req'); }, - 'pane:next': focusedWindow => { + 'pane:next': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('next pane req'); }, - 'editor:movePreviousWord': focusedWindow => { + 'editor:movePreviousWord': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session move word left req'); }, - 'editor:moveNextWord': focusedWindow => { + 'editor:moveNextWord': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session move word right req'); }, - 'editor:moveBeginningLine': focusedWindow => { + 'editor:moveBeginningLine': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session move line beginning req'); }, - 'editor:moveEndLine': focusedWindow => { + 'editor:moveEndLine': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session move line end req'); }, - 'editor:deletePreviousWord': focusedWindow => { + 'editor:deletePreviousWord': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session del word left req'); }, - 'editor:deleteNextWord': focusedWindow => { + 'editor:deleteNextWord': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session del word right req'); }, - 'editor:deleteBeginningLine': focusedWindow => { + 'editor:deleteBeginningLine': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session del line beginning req'); }, - 'editor:deleteEndLine': focusedWindow => { + 'editor:deleteEndLine': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session del line end req'); }, - 'editor:break': focusedWindow => { + 'editor:break': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session break req'); }, - 'editor:search': focusedWindow => { + 'editor:search': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session search'); }, - 'editor:search-close': focusedWindow => { + 'editor:search-close': (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('session search close'); }, 'cli:install': () => { @@ -118,9 +118,9 @@ const commands: Record void> = { }; //Special numeric command -([1, 2, 3, 4, 5, 6, 7, 8, 'last'] as const).forEach(cmdIndex => { +([1, 2, 3, 4, 5, 6, 7, 8, 'last'] as const).forEach((cmdIndex) => { const index = cmdIndex === 'last' ? cmdIndex : cmdIndex - 1; - commands[`tab:jump:${cmdIndex}`] = focusedWindow => { + commands[`tab:jump:${cmdIndex}`] = (focusedWindow) => { focusedWindow && focusedWindow.rpc.emit('move jump req', index); }; }); diff --git a/app/config.ts b/app/config.ts index ea0431db..183480ac 100644 --- a/app/config.ts +++ b/app/config.ts @@ -13,7 +13,7 @@ let _watcher: fs.FSWatcher; export const getDeprecatedCSS = (config: Record) => { const deprecated: string[] = []; const deprecatedCSS = ['x-screen', 'x-row', 'cursor-node', '::selection']; - deprecatedCSS.forEach(css => { + deprecatedCSS.forEach((css) => { if ((config.css && config.css.includes(css)) || (config.termCSS && config.termCSS.includes(css))) { deprecated.push(css); } @@ -43,7 +43,7 @@ const _watch = () => { setTimeout(() => { cfg = _import(); notify('Configuration updated', 'Hyper configuration reloaded!'); - watchers.forEach(fn => fn()); + watchers.forEach((fn) => fn()); checkDeprecatedConfig(); }, 100); }; @@ -64,7 +64,7 @@ const _watch = () => { // macOS/Linux function setWatcher() { try { - _watcher = fs.watch(cfgPath, eventType => { + _watcher = fs.watch(cfgPath, (eventType) => { if (eventType === 'rename') { _watcher.close(); // Ensure that new file has been written @@ -76,7 +76,7 @@ const _watch = () => { return; } _watcher.on('change', onChange); - _watcher.on('error', error => { + _watcher.on('error', (error) => { console.error('error watching config', error); }); } @@ -140,7 +140,7 @@ export const htermConfigTranslate = (config: Record) => { 'x-screen a([ {.[])': '.terminal a$1', 'x-row a([ {.[])': '.terminal a$1' }; - Object.keys(cssReplacements).forEach(pattern => { + Object.keys(cssReplacements).forEach((pattern) => { const searchvalue = new RegExp(pattern, 'g'); const newvalue = cssReplacements[pattern]; config.css = config.css && config.css.replace(searchvalue, newvalue); diff --git a/app/config/open.ts b/app/config/open.ts index 12cd3d55..7eb4fcbf 100644 --- a/app/config/open.ts +++ b/app/config/open.ts @@ -26,7 +26,7 @@ export default () => { Registry.closeKey(fileExtsKeys); // Find UserChoice key - const userChoice = keys.find(k => k.endsWith('UserChoice')); + const userChoice = keys.find((k) => k.endsWith('UserChoice')); return userChoice ? `Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.js\\${userChoice}` : userChoice; @@ -44,13 +44,13 @@ export default () => { // Load key values const userChoiceKey = Registry.openKey(Registry.HKCU, userChoice, Registry.Access.READ)!; const values: string[] = Registry.enumValueNames(userChoiceKey).map( - x => (Registry.queryValue(userChoiceKey, x) as string) || '' + (x) => (Registry.queryValue(userChoiceKey, x) as string) || '' ); Registry.closeKey(userChoiceKey); // Look for default program const hasDefaultProgramConfigured = values.every( - value => value && typeof value === 'string' && !value.includes('WScript.exe') && !value.includes('JSFile') + (value) => value && typeof value === 'string' && !value.includes('WScript.exe') && !value.includes('JSFile') ); return hasDefaultProgramConfigured; @@ -62,21 +62,21 @@ export default () => { // This mimics shell.openItem, true if it worked, false if not. const openNotepad = (file: string) => - new Promise(resolve => { - exec(`start notepad.exe ${file}`, error => { + new Promise((resolve) => { + exec(`start notepad.exe ${file}`, (error) => { resolve(!error); }); }); return hasDefaultSet() - .then(yes => { + .then((yes) => { if (yes) { return shell.openItem(cfgPath); } console.warn('No default app set for .js files, using notepad.exe fallback'); return openNotepad(cfgPath); }) - .catch(err => { + .catch((err) => { console.error('Open config with default app error:', err); return openNotepad(cfgPath); }); diff --git a/app/index.ts b/app/index.ts index 041f6be7..ef3a73f4 100644 --- a/app/index.ts +++ b/app/index.ts @@ -129,7 +129,7 @@ function installDevExtensions(isDev_: boolean) { const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'] as const; const forceDownload = Boolean(process.env.UPGRADE_EXTENSIONS); - return Promise.all(extensions.map(name => installer.default(installer[name], forceDownload))); + return Promise.all(extensions.map((name) => installer.default(installer[name], forceDownload))); } app.on('ready', () => @@ -249,7 +249,7 @@ app.on('ready', () => installCLI(false); } }) - .catch(err => { + .catch((err) => { console.error('Error while loading devtools extensions', err); }) ); diff --git a/app/menus/menu.ts b/app/menus/menu.ts index 35a31f97..a829b33f 100644 --- a/app/menus/menu.ts +++ b/app/menus/menu.ts @@ -41,7 +41,7 @@ export const createMenu = ( const showAbout = () => { const loadedPlugins = getLoadedPluginVersions(); const pluginList = - loadedPlugins.length === 0 ? 'none' : loadedPlugins.map(plugin => `\n ${plugin.name} (${plugin.version})`); + loadedPlugins.length === 0 ? 'none' : loadedPlugins.map((plugin) => `\n ${plugin.name} (${plugin.version})`); const rendererCounts = Object.values(getRendererTypes()).reduce((acc: Record, type) => { acc[type] = acc[type] ? acc[type] + 1 : 1; diff --git a/app/notifications.ts b/app/notifications.ts index 9ec23cd9..fa59a8e4 100644 --- a/app/notifications.ts +++ b/app/notifications.ts @@ -20,8 +20,8 @@ export default function fetchNotifications(win: BrowserWindow) { 'X-Hyper-Platform': process.platform } }) - .then(res => res.json()) - .then(data => { + .then((res) => res.json()) + .then((data) => { const {message} = data || {}; if (typeof message !== 'object' && message !== '') { throw new Error('Bad response'); diff --git a/app/plugins.ts b/app/plugins.ts index 46304267..ff384382 100644 --- a/app/plugins.ts +++ b/app/plugins.ts @@ -82,7 +82,7 @@ function patchModuleLoad() { } function checkDeprecatedExtendKeymaps() { - modules.forEach(plugin => { + modules.forEach((plugin) => { if (plugin.extendKeymaps) { notify('Plugin warning!', `"${plugin._name}" use deprecated "extendKeymaps" handler`); return; @@ -124,7 +124,7 @@ function updatePlugins({force = false} = {}) { cache.set('hyper.plugin-versions', pluginVersions); // notify watchers - watchers.forEach(fn => fn(err, {force})); + watchers.forEach((fn) => fn(err, {force})); if (force || changed) { if (changed) { @@ -140,7 +140,7 @@ function updatePlugins({force = false} = {}) { function getPluginVersions() { const paths_ = paths.plugins.concat(paths.localPlugins); - return paths_.map(path_ => { + return paths_.map((path_) => { let version = null; try { version = require(resolve(path_, 'package.json')).version; @@ -152,7 +152,7 @@ function getPluginVersions() { function clearCache() { // trigger unload hooks - modules.forEach(mod => { + modules.forEach((mod) => { if (mod.onUnload) { mod.onUnload(app); } @@ -169,7 +169,7 @@ function clearCache() { export {updatePlugins}; export const getLoadedPluginVersions = () => { - return modules.map(mod => ({name: mod._name, version: mod._version})); + return modules.map((mod) => ({name: mod._name, version: mod._version})); }; // we schedule the initial plugins update @@ -224,7 +224,7 @@ function alert(message: string) { function toDependencies(plugins_: {plugins: string[]}) { const obj: Record = {}; - plugins_.plugins.forEach(plugin => { + plugins_.plugins.forEach((plugin) => { const regex = /.(@|#)/; const match = regex.exec(plugin); @@ -251,10 +251,10 @@ export const subscribe = (fn: Function) => { function getPaths() { return { - plugins: plugins.plugins.map(name => { + plugins: plugins.plugins.map((name) => { return resolve(path, 'node_modules', name.split('#')[0]); }), - localPlugins: plugins.localPlugins.map(name => { + localPlugins: plugins.localPlugins.map((name) => { return resolve(localPath, name); }) }; @@ -275,7 +275,7 @@ function requirePlugins(): any[] { let mod: any; try { mod = require(path_); - const exposed = mod && Object.keys(mod).some(key => availableExtensions.has(key)); + const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key)); if (!exposed) { notify('Plugin error!', `${`Plugin "${basename(path_)}" does not expose any `}Hyper extension API methods`); return; @@ -303,11 +303,11 @@ function requirePlugins(): any[] { return plugins_ .map(load) .concat(localPlugins.map(load)) - .filter(v => Boolean(v)); + .filter((v) => Boolean(v)); } export const onApp = (app_: App) => { - modules.forEach(plugin => { + modules.forEach((plugin) => { if (plugin.onApp) { try { plugin.onApp(app_); @@ -321,7 +321,7 @@ export const onApp = (app_: App) => { }; export const onWindowClass = (win: BrowserWindow) => { - modules.forEach(plugin => { + modules.forEach((plugin) => { if (plugin.onWindowClass) { try { plugin.onWindowClass(win); @@ -335,7 +335,7 @@ export const onWindowClass = (win: BrowserWindow) => { }; export const onWindow = (win: BrowserWindow) => { - modules.forEach(plugin => { + modules.forEach((plugin) => { if (plugin.onWindow) { try { plugin.onWindow(win); @@ -352,7 +352,7 @@ export const onWindow = (win: BrowserWindow) => { // for all the available plugins function decorateEntity(base: any, key: string, type: 'object' | 'function') { let decorated = base; - modules.forEach(plugin => { + modules.forEach((plugin) => { if (plugin[key]) { let res; try { @@ -383,7 +383,7 @@ function decorateClass(base: any, key: string) { export const getDeprecatedConfig = () => { const deprecated: Record = {}; const baseConfig = config.getConfig(); - modules.forEach(plugin => { + modules.forEach((plugin) => { if (!plugin.decorateConfig) { return; } diff --git a/app/plugins/install.ts b/app/plugins/install.ts index bae77b78..b0b68162 100644 --- a/app/plugins/install.ts +++ b/app/plugins/install.ts @@ -10,7 +10,7 @@ export const install = (fn: Function) => { NODE_ENV: 'production', ELECTRON_RUN_AS_NODE: 'true' }; - spawnQueue.push(end => { + spawnQueue.push((end) => { const cmd = [process.execPath, yarn].concat(args).join(' '); console.log('Launching yarn:', cmd); diff --git a/app/session.ts b/app/session.ts index 2cca3bb2..b376f48b 100644 --- a/app/session.ts +++ b/app/session.ts @@ -146,14 +146,14 @@ export default class Session extends EventEmitter { } this.batcher = new DataBatcher(uid); - this.pty.onData(chunk => { + this.pty.onData((chunk) => { if (this.ended) { return; } this.batcher?.write(chunk as any); }); - this.batcher.on('flush', data => { + this.batcher.on('flush', (data) => { this.emit('data', data); }); diff --git a/app/ui/contextmenu.ts b/app/ui/contextmenu.ts index be004062..f6819811 100644 --- a/app/ui/contextmenu.ts +++ b/app/ui/contextmenu.ts @@ -29,5 +29,5 @@ export default ( const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection)); return _edit .concat(separator, _shell) - .filter(menuItem => !Object.prototype.hasOwnProperty.call(menuItem, 'enabled') || menuItem.enabled); + .filter((menuItem) => !Object.prototype.hasOwnProperty.call(menuItem, 'enabled') || menuItem.enabled); }; diff --git a/app/ui/window.ts b/app/ui/window.ts index 672c092b..175ae748 100644 --- a/app/ui/window.ts +++ b/app/ui/window.ts @@ -113,7 +113,7 @@ export function newWindow( function createSession(extraOptions: any = {}) { const uid = uuidv4(); const extraOptionsFiltered: any = {}; - Object.keys(extraOptions).forEach(key => { + Object.keys(extraOptions).forEach((key) => { if (extraOptions[key] !== undefined) extraOptionsFiltered[key] = extraOptions[key]; }); @@ -135,7 +135,7 @@ export function newWindow( return {session, options}; } - rpc.on('new', extraOptions => { + rpc.on('new', (extraOptions) => { const {session, options} = createSession(extraOptions); sessions.set(options.uid, session); @@ -202,7 +202,7 @@ export function newWindow( rpc.on('open external', ({url}) => { shell.openExternal(url); }); - rpc.on('open context menu', selection => { + rpc.on('open context menu', (selection) => { const {createWindow} = app; const {buildFromTemplate} = Menu; buildFromTemplate(contextMenuTemplate(createWindow, selection)).popup({window}); @@ -223,7 +223,7 @@ export function newWindow( rpc.on('close', () => { window.close(); }); - rpc.on('command', command => { + rpc.on('command', (command) => { const focusedWindow = BrowserWindow.getFocusedWindow(); execCommand(command, focusedWindow!); }); diff --git a/app/updater.ts b/app/updater.ts index 92e1703a..e157c755 100644 --- a/app/updater.ts +++ b/app/updater.ts @@ -25,7 +25,7 @@ const buildFeedUrl = (canary: boolean, currentVersion: string) => { const isCanary = (updateChannel: string) => updateChannel === 'canary'; async function init() { - autoUpdater.on('error', err => { + autoUpdater.on('error', (err) => { console.error('Error fetching updates', `${err.message} (${err.stack})`); }); diff --git a/app/utils/cli-install.ts b/app/utils/cli-install.ts index 24da9486..88ca8241 100644 --- a/app/utils/cli-install.ts +++ b/app/utils/cli-install.ts @@ -19,8 +19,8 @@ const symlink = pify(fs.symlink); const checkInstall = () => { return readlink(cliLinkPath) - .then(link => link === cliScriptPath) - .catch(err => { + .then((link) => link === cliScriptPath) + .catch((err) => { if (err.code === 'ENOENT') { return false; } @@ -29,7 +29,7 @@ const checkInstall = () => { }; const addSymlink = () => { - return checkInstall().then(isInstalled => { + return checkInstall().then((isInstalled) => { if (isInstalled) { console.log('Hyper CLI already in PATH'); return Promise.resolve(); @@ -50,7 +50,7 @@ const addBinToUserPath = () => { const basePath = path.resolve(binPath, '../../..'); const items = Registry.enumValueNames(envKey); - const pathItem = items.find(item => item.toUpperCase() === 'PATH'); + const pathItem = items.find((item) => item.toUpperCase() === 'PATH'); const pathItemName = pathItem || 'PATH'; let newPathValue = binPath; @@ -72,7 +72,7 @@ const addBinToUserPath = () => { // Because version is in path we need to remove old path if present and add current path newPathValue = pathParts - .filter(pathPart => !pathPart.startsWith(basePath)) + .filter((pathPart) => !pathPart.startsWith(basePath)) .concat([binPath]) .join(';'); } @@ -101,13 +101,13 @@ export const installCLI = (withNotification: boolean) => { 'You may need to restart your computer to complete this installation process.' ) ) - .catch(err => + .catch((err) => logNotify(withNotification, 'Hyper CLI installation failed', `Failed to add Hyper CLI path to user PATH ${err}`) ); } else if (process.platform === 'darwin') { addSymlink() .then(() => logNotify(withNotification, 'Hyper CLI installed', `Symlink created at ${cliLinkPath}`)) - .catch(err => { + .catch((err) => { // 'EINVAL' is returned by readlink, // 'EEXIST' is returned by symlink const error = diff --git a/app/utils/colors.ts b/app/utils/colors.ts index d4adc882..9ca3e0d1 100644 --- a/app/utils/colors.ts +++ b/app/utils/colors.ts @@ -21,7 +21,7 @@ const colorList = [ export const getColorMap: { (colors: T): T extends (infer U)[] ? {[k: string]: U} : T; -} = colors => { +} = (colors) => { if (!Array.isArray(colors)) { return colors; } diff --git a/app/utils/map-keys.ts b/app/utils/map-keys.ts index c7a3922b..e9c79423 100644 --- a/app/utils/map-keys.ts +++ b/app/utils/map-keys.ts @@ -4,7 +4,7 @@ const generatePrefixedCommand = (command: string, shortcuts: string[]) => { for (let i = 1; i <= 9; i++) { // 9 is a special number because it means 'last' const index = i === 9 ? 'last' : i; - const prefixedShortcuts = shortcuts.map(shortcut => `${shortcut}+${i}`); + const prefixedShortcuts = shortcuts.map((shortcut) => `${shortcut}+${i}`); result[`${baseCmd}:${index}`] = prefixedShortcuts; } @@ -20,7 +20,7 @@ export default (config: Record) => { const _shortcuts = config[command]; const shortcuts = Array.isArray(_shortcuts) ? _shortcuts : [_shortcuts]; const fixedShortcuts: string[] = []; - shortcuts.forEach(shortcut => { + shortcuts.forEach((shortcut) => { let newShortcut = shortcut; if (newShortcut.indexOf('cmd') !== -1) { // Mousetrap use `command` and not `cmd` diff --git a/app/utils/to-electron-background-color.ts b/app/utils/to-electron-background-color.ts index d9a5c988..1a526534 100644 --- a/app/utils/to-electron-background-color.ts +++ b/app/utils/to-electron-background-color.ts @@ -13,8 +13,5 @@ export default (bgColor: string) => { // http://stackoverflow.com/a/11019879/1202488 const alphaHex = Math.round(color.alpha() * 255).toString(16); - return `#${alphaHex}${color - .hex() - .toString() - .substr(1)}`; + return `#${alphaHex}${color.hex().toString().substr(1)}`; }; diff --git a/cli/api.ts b/cli/api.ts index ec4932e1..3fb8ace9 100644 --- a/cli/api.ts +++ b/cli/api.ts @@ -54,7 +54,7 @@ const getFileContents = memoize(() => { const getParsedFile = memoize(() => recast.parse(getFileContents()!)); -const getProperties = memoize(() => ((getParsedFile()?.program?.body as any[]) || []).map(obj => obj)); +const getProperties = memoize(() => ((getParsedFile()?.program?.body as any[]) || []).map((obj) => obj)); const getPluginsByKey = (key: string) => { const properties = getProperties(); @@ -84,7 +84,7 @@ function exists() { function isInstalled(plugin: string, locally?: boolean) { const array = (locally ? getLocalPlugins() : getPlugins()) || []; if (array && Array.isArray(array)) { - return array.some(entry => entry.value === plugin); + return array.some((entry) => entry.value === plugin); } return false; } @@ -108,7 +108,7 @@ function existsOnNpm(plugin: string) { const name = getPackageName(plugin); return got .get(registryUrl + name.toLowerCase(), {timeout: 10000, responseType: 'json'}) - .then(res => { + .then((res) => { if (!res.body.versions) { return Promise.reject(res); } else { @@ -142,7 +142,7 @@ function uninstall(plugin: string) { return Promise.reject(`${plugin} is not installed`); } - const index = getPlugins()!.findIndex(entry => entry.value === plugin); + const index = getPlugins()!.findIndex((entry) => entry.value === plugin); getPlugins()!.splice(index, 1); return save(); } @@ -150,7 +150,7 @@ function uninstall(plugin: string) { function list() { if (Array.isArray(getPlugins())) { return getPlugins()! - .map(plugin => plugin.value) + .map((plugin) => plugin.value) .join('\n'); } return false; diff --git a/cli/index.ts b/cli/index.ts index 7701a075..836f1c3e 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -59,7 +59,7 @@ args.command( commandPromise = api .uninstall(pluginName) .then(() => console.log(chalk.green(`${pluginName} uninstalled successfully!`))) - .catch(err => console.log(chalk.red(err))); + .catch((err) => console.log(chalk.red(err))); }, ['u', 'rm', 'remove'] ); @@ -85,16 +85,16 @@ const lsRemote = (pattern?: string) => { // note that no errors are catched by this function const URL = `https://api.npms.io/v2/search?q=${(pattern && `${pattern}+`) || ''}keywords:hyper-plugin,hyper-theme`; return got(URL) - .then(response => JSON.parse(response.body).results as any[]) - .then(entries => entries.map(entry => entry.package)) - .then(entries => entries.filter(entry => entry.name.indexOf(PLUGIN_PREFIX) === 0)) - .then(entries => + .then((response) => JSON.parse(response.body).results as any[]) + .then((entries) => entries.map((entry) => entry.package)) + .then((entries) => entries.filter((entry) => entry.name.indexOf(PLUGIN_PREFIX) === 0)) + .then((entries) => entries.map(({name, description}) => { return {name, description}; }) ) - .then(entries => - entries.map(entry => { + .then((entries) => + entries.map((entry) => { entry.name = chalk.green(entry.name); return entry; }) @@ -109,7 +109,7 @@ args.command( const query = args_[0] ? args_[0].toLowerCase() : ''; commandPromise = lsRemote(query) - .then(entries => { + .then((entries) => { if (entries.length === 0) { spinner.fail(); console.error(chalk.red(`Your search '${query}' did not match any plugins`)); @@ -122,7 +122,7 @@ args.command( console.log(msg); } }) - .catch(err => { + .catch((err) => { spinner.fail(); console.error(chalk.red(err)); // TODO }); @@ -137,14 +137,14 @@ args.command( const spinner = ora('Searching').start(); commandPromise = lsRemote() - .then(entries => { + .then((entries) => { let msg = columnify(entries); spinner.succeed(); msg = msg.substring(msg.indexOf('\n') + 1); // remove header console.log(msg); }) - .catch(err => { + .catch((err) => { spinner.fail(); console.error(chalk.red(err)); // TODO }); @@ -208,7 +208,7 @@ const main = (argv: string[]) => { env }; - const args_ = args.sub.map(arg => { + const args_ = args.sub.map((arg) => { const cwd = isAbsolute(arg) ? arg : resolve(process.cwd(), arg); if (!existsSync(cwd)) { console.error(chalk.red(`Error! Directory or file does not exist: ${cwd}`)); @@ -232,11 +232,11 @@ const main = (argv: string[]) => { const child = spawn(process.execPath, args_, options); if (flags.verbose) { - child.stdout.on('data', data => console.log(data.toString('utf8'))); - child.stderr.on('data', data => console.error(data.toString('utf8'))); + child.stdout.on('data', (data) => console.log(data.toString('utf8'))); + child.stderr.on('data', (data) => console.error(data.toString('utf8'))); } if (flags.verbose) { - return new Promise(c => child.once('exit', () => c(null))); + return new Promise((c) => child.once('exit', () => c(null))); } child.unref(); return Promise.resolve(); diff --git a/lib/actions/term-groups.ts b/lib/actions/term-groups.ts index f9e90c6a..57a04e23 100644 --- a/lib/actions/term-groups.ts +++ b/lib/actions/term-groups.ts @@ -152,7 +152,7 @@ export function userExitTermGroup(uid: string) { if (group.sessionUid) { dispatch(userExitSession(group.sessionUid)); } else { - group.children.forEach(childUid => { + group.children.forEach((childUid) => { dispatch(userExitTermGroup(childUid)); }); } diff --git a/lib/actions/ui.ts b/lib/actions/ui.ts index dd7ed58e..9838ee7a 100644 --- a/lib/actions/ui.ts +++ b/lib/actions/ui.ts @@ -209,7 +209,7 @@ export function moveTo(i: number | 'last') { const {termGroups} = getState().termGroups; i = Object.keys(termGroups) - .map(uid => termGroups[uid]) + .map((uid) => termGroups[uid]) .filter(({parentUid}) => !parentUid).length - 1; } dispatch({ diff --git a/lib/components/notifications.tsx b/lib/components/notifications.tsx index f605ff1b..63a14cda 100644 --- a/lib/components/notifications.tsx +++ b/lib/components/notifications.tsx @@ -50,7 +50,7 @@ export default class Notifications extends React.PureComponent { + onClick={(ev) => { window.require('electron').shell.openExternal(ev.currentTarget.href); ev.preventDefault(); }} @@ -77,7 +77,7 @@ export default class Notifications extends React.PureComponent { + onClick={(ev) => { window.require('electron').shell.openExternal(ev.currentTarget.href); ev.preventDefault(); }} @@ -105,7 +105,7 @@ export default class Notifications extends React.PureComponent { + onClick={(ev) => { window.require('electron').shell.openExternal(ev.currentTarget.href); ev.preventDefault(); }} diff --git a/lib/components/searchBox.tsx b/lib/components/searchBox.tsx index 201ce12d..a1cc9040 100644 --- a/lib/components/searchBox.tsx +++ b/lib/components/searchBox.tsx @@ -31,7 +31,7 @@ export default class SearchBox extends React.PureComponent { render() { return (
- input && input.focus()} /> + input && input.focus()} /> this.props.prev(this.searchTerm)}> {' '} ←{' '} diff --git a/lib/components/term-group.tsx b/lib/components/term-group.tsx index 1c1f6f10..7be1d6a9 100644 --- a/lib/components/term-group.tsx +++ b/lib/components/term-group.tsx @@ -119,7 +119,7 @@ class TermGroup_ extends React.PureComponent { return this.renderTerm(termGroup.sessionUid); } - const groups = childGroups.asMutable().map(child => { + const groups = childGroups.asMutable().map((child) => { const props = getTermGroupProps( child.uid, this.props.parentProps, @@ -134,7 +134,7 @@ class TermGroup_ extends React.PureComponent { } const mapStateToProps = (state: HyperState, ownProps: TermGroupOwnProps) => ({ - childGroups: ownProps.termGroup.children.map(uid => state.termGroups.termGroups[uid]) + childGroups: ownProps.termGroup.children.map((uid) => state.termGroups.termGroups[uid]) }); const mapDispatchToProps = (dispatch: HyperDispatch, ownProps: TermGroupOwnProps) => ({ diff --git a/lib/components/term.tsx b/lib/components/term.tsx index c915cf78..050543e6 100644 --- a/lib/components/term.tsx +++ b/lib/components/term.tsx @@ -326,8 +326,8 @@ export default class Term extends React.PureComponent { // Update only options that have changed. ObjectTypedKeys(nextTermOptions) - .filter(option => option !== 'theme' && nextTermOptions[option] !== this.termOptions[option]) - .forEach(option => { + .filter((option) => option !== 'theme' && nextTermOptions[option] !== this.termOptions[option]) + .forEach((option) => { try { this.term.setOption(option, nextTermOptions[option]); } catch (e) { @@ -344,7 +344,7 @@ export default class Term extends React.PureComponent { !this.termOptions.theme || nextTermOptions.rendererType !== this.termOptions.rendererType || ObjectTypedKeys(nextTermOptions.theme!).some( - option => nextTermOptions.theme![option] !== this.termOptions.theme![option] + (option) => nextTermOptions.theme![option] !== this.termOptions.theme![option] ); if (shouldUpdateTheme) { this.term.setOption('theme', nextTermOptions.theme); @@ -392,7 +392,7 @@ export default class Term extends React.PureComponent { // instead of invoking `destroy`, since it will make the // term insta un-attachable in the future (which we need // to do in case of splitting, see `componentDidMount` - this.disposableListeners.forEach(handler => handler.dispose()); + this.disposableListeners.forEach((handler) => handler.dispose()); this.disposableListeners = []; window.removeEventListener('paste', this.onWindowPaste, { diff --git a/lib/components/terms.tsx b/lib/components/terms.tsx index a41e1634..fac1a09f 100644 --- a/lib/components/terms.tsx +++ b/lib/components/terms.tsx @@ -24,8 +24,8 @@ export default class Terms extends React.Component { shouldComponentUpdate(nextProps: TermsProps & {children: any}) { return ( - ObjectTypedKeys(nextProps).some(i => i !== 'write' && this.props[i] !== nextProps[i]) || - ObjectTypedKeys(this.props).some(i => i !== 'write' && this.props[i] !== nextProps[i]) + ObjectTypedKeys(nextProps).some((i) => i !== 'write' && this.props[i] !== nextProps[i]) || + ObjectTypedKeys(this.props).some((i) => i !== 'write' && this.props[i] !== nextProps[i]) ); } @@ -75,7 +75,7 @@ export default class Terms extends React.Component { return (
{this.props.customChildrenBefore} - {this.props.termGroups.map(termGroup => { + {this.props.termGroups.map((termGroup) => { const {uid} = termGroup; const isActive = uid === this.props.activeRootGroup; const props = getTermGroupProps(uid, this.props, { diff --git a/lib/containers/hyper.tsx b/lib/containers/hyper.tsx index 57a6d8b6..3b503e16 100644 --- a/lib/containers/hyper.tsx +++ b/lib/containers/hyper.tsx @@ -61,7 +61,7 @@ class Hyper extends React.PureComponent { } const keys = getRegisteredKeys(); - Object.keys(keys).forEach(commandKeys => { + Object.keys(keys).forEach((commandKeys) => { this.mousetrap.bind( commandKeys, (e: any) => { diff --git a/lib/ext-modules.d.ts b/lib/ext-modules.d.ts index 3fd79edf..2289791c 100644 --- a/lib/ext-modules.d.ts +++ b/lib/ext-modules.d.ts @@ -4,9 +4,9 @@ declare module 'php-escape-shell' { } declare module 'parse-url' { - export default function(...args: any[]): any; + export default function (...args: any[]): any; } declare module 'react-deep-force-update' { - export default function(...args: any[]): any; + export default function (...args: any[]): any; } diff --git a/lib/index.tsx b/lib/index.tsx index 66469404..81c37b49 100644 --- a/lib/index.tsx +++ b/lib/index.tsx @@ -38,7 +38,7 @@ const fetchFileData = (configData: any) => { return; } - getBase64FileData(configInfo.bellSoundURL).then(base64FileData => { + getBase64FileData(configInfo.bellSoundURL).then((base64FileData) => { // prepend "base64," to the result of this method in order for this to work properly within xterm.js const bellSound = !base64FileData ? null : 'base64,' + base64FileData; configInfo.bellSound = bellSound; @@ -71,11 +71,11 @@ rpc.on('ready', () => { store_.dispatch(uiActions.setFontSmoothing()); }); -rpc.on('session add', data => { +rpc.on('session add', (data) => { store_.dispatch(sessionActions.addSession(data)); }); -rpc.on('session data', d => { +rpc.on('session data', (d) => { // the uid is a uuid v4 so it's 36 chars long const uid = d.slice(0, 36); const data = d.slice(36); @@ -174,7 +174,7 @@ rpc.on('move right req', () => { store_.dispatch(uiActions.moveRight()); }); -rpc.on('move jump req', index => { +rpc.on('move jump req', (index) => { store_.dispatch(uiActions.moveTo(index)); }); @@ -190,7 +190,7 @@ rpc.on('open file', ({path}) => { store_.dispatch(uiActions.openFile(path)); }); -rpc.on('open ssh', url => { +rpc.on('open ssh', (url) => { store_.dispatch(uiActions.openSSH(url)); }); @@ -198,7 +198,7 @@ rpc.on('update available', ({releaseName, releaseNotes, releaseUrl, canInstall}) store_.dispatch(updaterActions.updateAvailable(releaseName, releaseNotes, releaseUrl, canInstall)); }); -rpc.on('move', window => { +rpc.on('move', (window) => { store_.dispatch(uiActions.windowMove(window)); }); diff --git a/lib/reducers/term-groups.ts b/lib/reducers/term-groups.ts index 769b27d6..7e8955ce 100644 --- a/lib/reducers/term-groups.ts +++ b/lib/reducers/term-groups.ts @@ -50,7 +50,7 @@ const insertRebalance = (oldSizes: ImmutableType, index: any) => { const newSize = 1 / (oldSizes.length + 1); // We spread out how much each pane should be reduced // with based on their existing size: - const balanced = oldSizes.map(size => size - newSize * size); + const balanced = oldSizes.map((size) => size - newSize * size); return [...balanced.slice(0, index).asMutable(), newSize, ...balanced.slice(index).asMutable()]; }; @@ -190,7 +190,7 @@ const removeGroup = (state: ImmutableType, uid: string) => { const resizeGroup = (state: ImmutableType, uid: any, sizes: number[]) => { // Make sure none of the sizes fall below MIN_SIZE: - if (sizes.find(size => size < MIN_SIZE)) { + if (sizes.find((size) => size < MIN_SIZE)) { return state; } diff --git a/lib/selectors.ts b/lib/selectors.ts index ad583e65..21d98353 100644 --- a/lib/selectors.ts +++ b/lib/selectors.ts @@ -2,8 +2,8 @@ import {createSelector} from 'reselect'; import {HyperState} from './hyper'; const getTermGroups = ({termGroups}: Pick) => termGroups.termGroups; -export const getRootGroups = createSelector(getTermGroups, termGroups => +export const getRootGroups = createSelector(getTermGroups, (termGroups) => Object.keys(termGroups) - .map(uid => termGroups[uid]) + .map((uid) => termGroups[uid]) .filter(({parentUid}) => !parentUid) ); diff --git a/lib/store/write-middleware.ts b/lib/store/write-middleware.ts index a13fdd93..bd0855d5 100644 --- a/lib/store/write-middleware.ts +++ b/lib/store/write-middleware.ts @@ -4,7 +4,7 @@ import {Middleware} from 'redux'; // the only side effect we perform from middleware // is to write to the react term instance directly // to avoid a performance hit -const writeMiddleware: Middleware = () => next => action => { +const writeMiddleware: Middleware = () => (next) => (action) => { if (action.type === 'SESSION_PTY_DATA') { const term = terms[action.uid]; if (term) { diff --git a/lib/utils/effects.ts b/lib/utils/effects.ts index ae0bddb8..0d94a998 100644 --- a/lib/utils/effects.ts +++ b/lib/utils/effects.ts @@ -7,7 +7,7 @@ * as the result of an action being triggered. */ import {Middleware} from 'redux'; -const effectsMiddleware: Middleware = () => next => action => { +const effectsMiddleware: Middleware = () => (next) => (action) => { const ret = next(action); if (action.effect) { action.effect(); diff --git a/lib/utils/plugins.ts b/lib/utils/plugins.ts index c7b728cd..b9c0b43d 100644 --- a/lib/utils/plugins.ts +++ b/lib/utils/plugins.ts @@ -271,7 +271,7 @@ const loadModules = () => { return undefined; } - ObjectTypedKeys(mod).forEach(i => { + ObjectTypedKeys(mod).forEach((i) => { if (Object.hasOwnProperty.call(mod, i)) { mod[i]._pluginName = pluginName; mod[i]._pluginVersion = pluginVersion; @@ -364,7 +364,7 @@ const loadModules = () => { .filter((mod: any) => Boolean(mod)); const deprecatedPlugins: Record = plugins.getDeprecatedConfig(); - Object.keys(deprecatedPlugins).forEach(name => { + Object.keys(deprecatedPlugins).forEach((name) => { const {css} = deprecatedPlugins[name]; if (css) { console.warn(`Warning: "${name}" plugin uses some deprecated CSS classes (${css.join(', ')}).`); @@ -387,7 +387,7 @@ function getProps(name: keyof typeof propsDecorators, props: any, ...fnArgs: any const decorators = propsDecorators[name]; let props_: typeof props; - decorators.forEach(fn => { + decorators.forEach((fn) => { let ret_; if (!props_) { @@ -445,9 +445,9 @@ export function connect( ) { return (Class: any, name: keyof typeof connectors) => { return reduxConnect( - state => { + (state) => { let ret = stateFn(state); - connectors[name].state.forEach(fn => { + connectors[name].state.forEach((fn) => { let ret_; try { @@ -470,9 +470,9 @@ export function connect( }); return ret; }, - dispatch => { + (dispatch) => { let ret = dispatchFn(dispatch); - connectors[name].dispatch.forEach(fn => { + connectors[name].dispatch.forEach((fn) => { let ret_; try { @@ -550,7 +550,7 @@ export function decorateSessionsReducer(fn: ISessionReducer) { } // redux middleware generator -export const middleware: Middleware = store => next => action => { +export const middleware: Middleware = (store) => (next) => (action) => { const nextMiddleware = (remaining: Middleware[]) => (action_: any) => remaining.length ? remaining[0](store)(nextMiddleware(remaining.slice(1)))(action_) : next(action_); nextMiddleware(middlewares)(action); diff --git a/lib/utils/term-groups.ts b/lib/utils/term-groups.ts index f012f5ea..b59731a3 100644 --- a/lib/utils/term-groups.ts +++ b/lib/utils/term-groups.ts @@ -4,6 +4,6 @@ import {Immutable} from 'seamless-immutable'; export default function findBySession(termGroupState: Immutable, sessionUid: string) { const {termGroups} = termGroupState; return Object.keys(termGroups) - .map(uid => termGroups[uid]) - .find(group => group.sessionUid === sessionUid); + .map((uid) => termGroups[uid]) + .find((group) => group.sessionUid === sessionUid); } diff --git a/release.js b/release.js index 3abec6a4..7274ef9f 100644 --- a/release.js +++ b/release.js @@ -1,7 +1,7 @@ // Packages const {prompt} = require('inquirer'); -module.exports = async markdown => { +module.exports = async (markdown) => { const answers = await prompt([ { name: 'intro', diff --git a/test/index.ts b/test/index.ts index b67442e3..c9acb02f 100644 --- a/test/index.ts +++ b/test/index.ts @@ -38,7 +38,7 @@ test.after(async () => { await app.stop(); }); -test('see if dev tools are open', async t => { +test('see if dev tools are open', async (t) => { await app.client.waitUntilWindowLoaded(); t.false(await app.webContents.isDevToolsOpened()); }); diff --git a/test/unit/cli-api.test.ts b/test/unit/cli-api.test.ts index 62b560fc..e32d7d0f 100644 --- a/test/unit/cli-api.test.ts +++ b/test/unit/cli-api.test.ts @@ -1,7 +1,7 @@ import test from 'ava'; const proxyquire = require('proxyquire').noCallThru(); -test('existsOnNpm() builds the url for non-scoped packages', t => { +test('existsOnNpm() builds the url for non-scoped packages', (t) => { let getUrl: string; const {existsOnNpm} = proxyquire('../../cli/api', { got: { @@ -22,7 +22,7 @@ test('existsOnNpm() builds the url for non-scoped packages', t => { }); }); -test('existsOnNpm() builds the url for scoped packages', t => { +test('existsOnNpm() builds the url for scoped packages', (t) => { let getUrl: string; const {existsOnNpm} = proxyquire('../../cli/api', { got: { diff --git a/test/unit/to-electron-background-color.test.ts b/test/unit/to-electron-background-color.test.ts index 181943d5..e7421fc1 100644 --- a/test/unit/to-electron-background-color.test.ts +++ b/test/unit/to-electron-background-color.test.ts @@ -2,11 +2,11 @@ import test from 'ava'; import toElectronBackgroundColor from '../../app/utils/to-electron-background-color'; import {isHexColor} from '../testUtils/is-hex-color'; -test('toElectronBackgroundColor', t => { +test('toElectronBackgroundColor', (t) => { t.false(false); }); -test(`returns a color that's in hex`, t => { +test(`returns a color that's in hex`, (t) => { const hexColor = '#BADA55'; const rgbColor = 'rgb(0,0,0)'; const rgbaColor = 'rgb(0,0,0, 55)'; diff --git a/test/unit/window-utils.test.ts b/test/unit/window-utils.test.ts index 597b942a..af3bad89 100644 --- a/test/unit/window-utils.test.ts +++ b/test/unit/window-utils.test.ts @@ -1,7 +1,7 @@ import test from 'ava'; const proxyquire = require('proxyquire').noCallThru(); -test('positionIsValid() returns true when window is on only screen', t => { +test('positionIsValid() returns true when window is on only screen', (t) => { const position = [50, 50]; const windowUtils = proxyquire('../../app/utils/window-utils', { electron: { @@ -27,7 +27,7 @@ test('positionIsValid() returns true when window is on only screen', t => { t.true(result); }); -test('positionIsValid() returns true when window is on second screen', t => { +test('positionIsValid() returns true when window is on second screen', (t) => { const position = [750, 50]; const windowUtils = proxyquire('../../app/utils/window-utils', { electron: { @@ -61,7 +61,7 @@ test('positionIsValid() returns true when window is on second screen', t => { t.true(result); }); -test('positionIsValid() returns false when position isnt valid', t => { +test('positionIsValid() returns false when position isnt valid', (t) => { const primaryDisplay = { workArea: { x: 0,