Fix @typescript-eslint/no-floating-promises errors

This commit is contained in:
Labhansh Agrawal 2021-03-28 22:12:20 +05:30
parent b9aa271bfc
commit 76912a3d27
13 changed files with 27 additions and 23 deletions

View file

@ -104,7 +104,6 @@
"@typescript-eslint/ban-types": "off", "@typescript-eslint/ban-types": "off",
"no-shadow": "off", "no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"], "@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off", "@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off", "@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-assignment": "off",

View file

@ -26,7 +26,7 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
focusedWindow?.rpc.emit('termgroup close req'); focusedWindow?.rpc.emit('termgroup close req');
}, },
'window:preferences': () => { 'window:preferences': () => {
openConfig(); void openConfig();
}, },
'editor:clearBuffer': (focusedWindow) => { 'editor:clearBuffer': (focusedWindow) => {
focusedWindow?.rpc.emit('session clear req'); focusedWindow?.rpc.emit('session clear req');
@ -118,7 +118,7 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
focusedWindow?.rpc.emit('session search close'); focusedWindow?.rpc.emit('session search close');
}, },
'cli:install': () => { 'cli:install': () => {
installCLI(true); void installCLI(true);
}, },
'window:hamburgerMenu': () => { 'window:hamburgerMenu': () => {
if (process.platform !== 'darwin' && ['', true].includes(getConfig().showHamburgerMenu)) { if (process.platform !== 'darwin' && ['', true].includes(getConfig().showHamburgerMenu)) {

View file

@ -59,7 +59,12 @@ const _watch = () => {
app.on('before-quit', (e) => { app.on('before-quit', (e) => {
if (Object.keys(_watcher.getWatched()).length > 0) { if (Object.keys(_watcher.getWatched()).length > 0) {
e.preventDefault(); e.preventDefault();
_watcher.close().then(() => { _watcher
.close()
.catch((err) => {
console.warn(err);
})
.finally(() => {
app.quit(); app.quit();
}); });
} }

View file

@ -127,7 +127,7 @@ app.on('ready', () =>
const hwin = newWindow({width, height, x: startX, y: startY}, cfg, fn); const hwin = newWindow({width, height, x: startX, y: startY}, cfg, fn);
windowSet.add(hwin); windowSet.add(hwin);
hwin.loadURL(url); void hwin.loadURL(url);
// the window can be closed by the browser process itself // the window can be closed by the browser process itself
hwin.on('close', () => { hwin.on('close', () => {
@ -191,7 +191,7 @@ app.on('ready', () =>
console.log('Removing Hyper from default client for ssh:// protocol'); console.log('Removing Hyper from default client for ssh:// protocol');
app.removeAsDefaultProtocolClient('ssh'); app.removeAsDefaultProtocolClient('ssh');
} }
installCLI(false); void installCLI(false);
} }
}) })
.catch((err) => { .catch((err) => {

View file

@ -51,7 +51,7 @@ export const createMenu = (
.map(([type, count]) => type + (count > 1 ? ` (${count})` : '')) .map(([type, count]) => type + (count > 1 ? ` (${count})` : ''))
.join(', '); .join(', ');
dialog.showMessageBox({ void dialog.showMessageBox({
title: `About ${appName}`, title: `About ${appName}`,
message: `${appName} ${appVersion} (${updateChannel})`, message: `${appName} ${appVersion} (${updateChannel})`,
detail: `Renderers: ${renderers}\nPlugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2020 Vercel, Inc.`, detail: `Renderers: ${renderers}\nPlugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2020 Vercel, Inc.`,

View file

@ -9,7 +9,7 @@ export default (commands: Record<string, string>, showAbout: () => void): MenuIt
{ {
label: `${app.name} Website`, label: `${app.name} Website`,
click() { click() {
shell.openExternal('https://hyper.is'); void shell.openExternal('https://hyper.is');
} }
}, },
{ {
@ -60,7 +60,7 @@ ${JSON.stringify(getPlugins(), null, 2)}
const issueURL = `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(body)}`; const issueURL = `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(body)}`;
const copyAndSend = () => { const copyAndSend = () => {
clipboard.writeText(body); clipboard.writeText(body);
shell.openExternal( void shell.openExternal(
`https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent( `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(
'<!-- We have written the needed data into your clipboard because it was too large to send. ' + '<!-- We have written the needed data into your clipboard because it was too large to send. ' +
'Please paste. -->\n' 'Please paste. -->\n'
@ -70,7 +70,7 @@ ${JSON.stringify(getPlugins(), null, 2)}
if (!focusedWindow) { if (!focusedWindow) {
copyAndSend(); copyAndSend();
} else if (issueURL.length > 6144) { } else if (issueURL.length > 6144) {
dialog void dialog
.showMessageBox(focusedWindow, { .showMessageBox(focusedWindow, {
message: message:
'There is too much data to send to GitHub directly. The data will be copied to the clipboard, ' + 'There is too much data to send to GitHub directly. The data will be copied to the clipboard, ' +
@ -84,7 +84,7 @@ ${JSON.stringify(getPlugins(), null, 2)}
} }
}); });
} else { } else {
shell.openExternal(issueURL); void shell.openExternal(issueURL);
} }
} }
} }

View file

@ -213,7 +213,7 @@ function syncPackageJSON() {
} }
function alert(message: string) { function alert(message: string) {
dialog.showMessageBox({ void dialog.showMessageBox({
message, message,
buttons: ['Ok'] buttons: ['Ok']
}); });

View file

@ -206,7 +206,7 @@ export function newWindow(
setRendererType(uid, type); setRendererType(uid, type);
}); });
rpc.on('open external', ({url}) => { rpc.on('open external', ({url}) => {
shell.openExternal(url); void shell.openExternal(url);
}); });
rpc.on('open context menu', (selection) => { rpc.on('open context menu', (selection) => {
const {createWindow} = app; const {createWindow} = app;
@ -277,7 +277,7 @@ export function newWindow(
const protocol = typeof url === 'string' && parseUrl(url).protocol; const protocol = typeof url === 'string' && parseUrl(url).protocol;
if (protocol === 'http:' || protocol === 'https:') { if (protocol === 'http:' || protocol === 'https:') {
event.preventDefault(); event.preventDefault();
shell.openExternal(url); void shell.openExternal(url);
} }
}); });

View file

@ -61,7 +61,7 @@ async function init() {
export default (win: BrowserWindow) => { export default (win: BrowserWindow) => {
if (!isInit) { if (!isInit) {
init(); void init();
} }
const {rpc} = win; const {rpc} = win;

View file

@ -157,7 +157,7 @@ args.command(
(name, args_) => { (name, args_) => {
const pluginName = args_[0]; const pluginName = args_[0];
assertPluginName(pluginName); assertPluginName(pluginName);
open(`http://ghub.io/${pluginName}`, {wait: false}); void open(`http://ghub.io/${pluginName}`, {wait: false});
process.exit(0); process.exit(0);
}, },
['d', 'h', 'home'] ['d', 'h', 'home']

View file

@ -51,7 +51,7 @@ export default class Notifications extends React.PureComponent<NotificationsProp
key="link" key="link"
style={{color: '#fff'}} style={{color: '#fff'}}
onClick={(ev) => { onClick={(ev) => {
window.require('electron').shell.openExternal(ev.currentTarget.href); void window.require('electron').shell.openExternal(ev.currentTarget.href);
ev.preventDefault(); ev.preventDefault();
}} }}
href={this.props.messageURL} href={this.props.messageURL}
@ -78,7 +78,7 @@ export default class Notifications extends React.PureComponent<NotificationsProp
<a <a
style={{color: '#000'}} style={{color: '#000'}}
onClick={(ev) => { onClick={(ev) => {
window.require('electron').shell.openExternal(ev.currentTarget.href); void window.require('electron').shell.openExternal(ev.currentTarget.href);
ev.preventDefault(); ev.preventDefault();
}} }}
href={`https://github.com/vercel/hyper/releases/tag/${this.props.updateVersion}`} href={`https://github.com/vercel/hyper/releases/tag/${this.props.updateVersion}`}
@ -106,7 +106,7 @@ export default class Notifications extends React.PureComponent<NotificationsProp
fontWeight: 'bold' fontWeight: 'bold'
}} }}
onClick={(ev) => { onClick={(ev) => {
window.require('electron').shell.openExternal(ev.currentTarget.href); void window.require('electron').shell.openExternal(ev.currentTarget.href);
ev.preventDefault(); ev.preventDefault();
}} }}
href={this.props.updateReleaseUrl!} href={this.props.updateReleaseUrl!}

View file

@ -158,7 +158,7 @@ export default class Term extends React.PureComponent<TermProps> {
this.term.loadAddon( this.term.loadAddon(
new WebLinksAddon( new WebLinksAddon(
(event: MouseEvent | undefined, uri: string) => { (event: MouseEvent | undefined, uri: string) => {
if (shallActivateWebLink(event)) shell.openExternal(uri); if (shallActivateWebLink(event)) void shell.openExternal(uri);
}, },
{ {
// prevent default electron link handling to allow selection, e.g. via double-click // prevent default electron link handling to allow selection, e.g. via double-click

View file

@ -39,7 +39,7 @@ const fetchFileData = (configData: configOptions) => {
return; return;
} }
getBase64FileData(configInfo.bellSoundURL).then((base64FileData) => { void getBase64FileData(configInfo.bellSoundURL).then((base64FileData) => {
// prepend "base64," to the result of this method in order for this to work properly within xterm.js // prepend "base64," to the result of this method in order for this to work properly within xterm.js
const bellSound = !base64FileData ? null : 'base64,' + base64FileData; const bellSound = !base64FileData ? null : 'base64,' + base64FileData;
configInfo.bellSound = bellSound; configInfo.bellSound = bellSound;