Fix @typescript-eslint/no-unsafe-return errors

This commit is contained in:
Labhansh Agrawal 2021-03-29 01:43:49 +05:30
parent c347ce8483
commit e266dd00f2
15 changed files with 41 additions and 16 deletions

View file

@ -106,7 +106,6 @@
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/restrict-template-expressions": "off"
}
}

View file

@ -44,7 +44,9 @@ const _watch = () => {
setTimeout(() => {
cfg = _import();
notify('Configuration updated', 'Hyper configuration reloaded!');
watchers.forEach((fn) => fn());
watchers.forEach((fn) => {
fn();
});
checkDeprecatedConfig();
}, 100);
};

View file

@ -9,6 +9,7 @@ const _extract = (script?: vm.Script): Record<string, any> => {
if (!module.exports) {
throw new Error('Error reading configuration: `module.exports` not set');
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return module.exports;
};

View file

@ -205,7 +205,9 @@ app.on('ready', () =>
app.on('open-file', (event, path) => {
const lastWindow = app.getLastFocusedWindow();
const callback = (win: BrowserWindow) => win.rpc.emit('open file', {path});
const callback = (win: BrowserWindow) => {
win.rpc.emit('open file', {path});
};
if (lastWindow) {
callback(lastWindow);
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {
@ -219,7 +221,9 @@ app.on('open-file', (event, path) => {
app.on('open-url', (event, sshUrl) => {
const lastWindow = app.getLastFocusedWindow();
const callback = (win: BrowserWindow) => win.rpc.emit('open ssh', sshUrl);
const callback = (win: BrowserWindow) => {
win.rpc.emit('open ssh', sshUrl);
};
if (lastWindow) {
callback(lastWindow);
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {

View file

@ -1,4 +1,5 @@
// eslint-disable-next-line 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-call */
import {app, dialog, BrowserWindow, App} from 'electron';
import {resolve, basename} from 'path';
@ -100,7 +101,7 @@ function updatePlugins({force = false} = {}) {
updating = true;
syncPackageJSON();
const id_ = id;
install((err: any) => {
install((err) => {
updating = false;
if (err) {
@ -125,7 +126,9 @@ 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) {
@ -142,7 +145,7 @@ function updatePlugins({force = false} = {}) {
function getPluginVersions() {
const paths_ = paths.plugins.concat(paths.localPlugins);
return paths_.map((path_) => {
let version = null;
let version: string | null = null;
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
version = require(resolve(path_, 'package.json')).version;

View file

@ -3,9 +3,9 @@ import queue from 'queue';
import ms from 'ms';
import {yarn, plugs} from '../config/paths';
export const install = (fn: Function) => {
export const install = (fn: (err: string | null) => void) => {
const spawnQueue = queue({concurrency: 1});
function yarnFn(args: string[], cb: Function) {
function yarnFn(args: string[], cb: (err: string | null) => void) {
const env = {
NODE_ENV: 'production',
ELECTRON_RUN_AS_NODE: 'true'
@ -38,7 +38,7 @@ export const install = (fn: Function) => {
spawnQueue.start();
}
yarnFn(['install', '--no-emoji', '--no-lockfile', '--cache-folder', plugs.cache], (err: any) => {
yarnFn(['install', '--no-emoji', '--no-lockfile', '--cache-folder', plugs.cache], (err) => {
if (err) {
return fn(err);
}

View file

@ -98,7 +98,9 @@ export function newWindow(
// If no callback is passed to createWindow,
// a new session will be created by default.
if (!fn) {
fn = (win: BrowserWindow) => win.rpc.emit('termgroup add req', {});
fn = (win: BrowserWindow) => {
win.rpc.emit('termgroup add req', {});
};
}
// app.windowCallback is the createWindow callback
@ -219,7 +221,9 @@ export function newWindow(
// is maximized on Windows results in unmaximize, without hitting any
// app buttons
for (const ev of ['maximize', 'unmaximize', 'minimize', 'restore'] as any) {
window.on(ev, () => rpc.emit('windowGeometry change', {}));
window.on(ev, () => {
rpc.emit('windowGeometry change', {});
});
}
window.on('move', () => {
const position = window.getPosition();

View file

@ -25,10 +25,12 @@ export const getColorMap: {
if (!Array.isArray(colors)) {
return colors;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return colors.reduce((result, color, index) => {
if (index < colorList.length) {
result[colorList[index]] = color;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return result;
}, {});
};

View file

@ -1,3 +1,5 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-return */
import fs from 'fs';
import os from 'os';
import got from 'got';

View file

@ -84,8 +84,9 @@ const lsRemote = (pattern?: string) => {
const URL = `https://api.npms.io/v2/search?q=${
(pattern && `${pattern}+`) || ''
}keywords:hyper-plugin,hyper-theme&size=250`;
type npmResult = {package: {name: string; description: string}};
return got(URL)
.then((response) => JSON.parse(response.body).results as any[])
.then((response) => JSON.parse(response.body).results as npmResult[])
.then((entries) => entries.map((entry) => entry.package))
.then((entries) =>
entries.map(({name, description}) => {

View file

@ -148,7 +148,8 @@ export default class Term extends React.PureComponent<TermProps> {
}
Term.reportRenderer(props.uid, useWebGL ? 'WebGL' : 'Canvas');
const shallActivateWebLink = (event: Record<string, any> | undefined) => {
const shallActivateWebLink = (event: Record<string, any> | undefined): boolean => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return event && (!props.webLinksActivationKey || event[`${props.webLinksActivationKey}Key`]);
};

View file

@ -14,6 +14,7 @@ const effectsMiddleware: Middleware = () => (next) => (action) => {
action.effect();
delete action.effect;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return ret;
};
export default effectsMiddleware;

View file

@ -1,3 +1,5 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-return */
const valsCache = new WeakMap();
export function values(imm: Record<string, any>) {

View file

@ -1,3 +1,5 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-return */
import {remote} from 'electron';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31

View file

@ -1,4 +1,5 @@
// eslint-disable-next-line 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-call */
import test from 'ava';
// eslint-disable-next-line @typescript-eslint/no-var-requires