Skip to content

Commit

Permalink
fix prettier errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal authored and Stanzilla committed Mar 25, 2020
1 parent d2d31e3 commit 41b1ac1
Show file tree
Hide file tree
Showing 39 changed files with 150 additions and 153 deletions.
58 changes: 29 additions & 29 deletions app/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => 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;
}
Expand All @@ -53,58 +53,58 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => 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': () => {
Expand All @@ -118,9 +118,9 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => 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);
};
});
Expand Down
10 changes: 5 additions & 5 deletions app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let _watcher: fs.FSWatcher;
export const getDeprecatedCSS = (config: Record<string, any>) => {
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);
}
Expand Down Expand Up @@ -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);
};
Expand All @@ -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
Expand All @@ -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);
});
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export const htermConfigTranslate = (config: Record<string, any>) => {
'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);
Expand Down
14 changes: 7 additions & 7 deletions app/config/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -62,21 +62,21 @@ export default () => {

// This mimics shell.openItem, true if it worked, false if not.
const openNotepad = (file: string) =>
new Promise<boolean>(resolve => {
exec(`start notepad.exe ${file}`, error => {
new Promise<boolean>((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);
});
Expand Down
4 changes: 2 additions & 2 deletions app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () =>
Expand Down Expand Up @@ -249,7 +249,7 @@ app.on('ready', () =>
installCLI(false);
}
})
.catch(err => {
.catch((err) => {
console.error('Error while loading devtools extensions', err);
})
);
Expand Down
2 changes: 1 addition & 1 deletion app/menus/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, number>, type) => {
acc[type] = acc[type] ? acc[type] + 1 : 1;
Expand Down
4 changes: 2 additions & 2 deletions app/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
30 changes: 15 additions & 15 deletions app/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -152,7 +152,7 @@ function getPluginVersions() {

function clearCache() {
// trigger unload hooks
modules.forEach(mod => {
modules.forEach((mod) => {
if (mod.onUnload) {
mod.onUnload(app);
}
Expand All @@ -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
Expand Down Expand Up @@ -224,7 +224,7 @@ function alert(message: string) {

function toDependencies(plugins_: {plugins: string[]}) {
const obj: Record<string, string> = {};
plugins_.plugins.forEach(plugin => {
plugins_.plugins.forEach((plugin) => {
const regex = /.(@|#)/;
const match = regex.exec(plugin);

Expand All @@ -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);
})
};
Expand All @@ -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;
Expand Down Expand Up @@ -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_);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -383,7 +383,7 @@ function decorateClass(base: any, key: string) {
export const getDeprecatedConfig = () => {
const deprecated: Record<string, any> = {};
const baseConfig = config.getConfig();
modules.forEach(plugin => {
modules.forEach((plugin) => {
if (!plugin.decorateConfig) {
return;
}
Expand Down
Loading

0 comments on commit 41b1ac1

Please sign in to comment.