mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Fix @typescript-eslint/no-unsafe-call errors
This commit is contained in:
parent
9b0a57db13
commit
c347ce8483
15 changed files with 40 additions and 20 deletions
|
|
@ -105,7 +105,6 @@
|
|||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": ["error"],
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-call": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/no-unsafe-return": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {rawConfig} from '../../lib/config';
|
|||
|
||||
let defaultConfig: rawConfig;
|
||||
|
||||
const _write = (path: string, data: any) => {
|
||||
const _write = (path: string, data: string) => {
|
||||
// This method will take text formatted as Unix line endings and transform it
|
||||
// to text formatted with DOS line endings. We do this because the default
|
||||
// text editor on Windows (notepad) doesn't Deal with LF files. Still. In 2017.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import {app, dialog, BrowserWindow, App} from 'electron';
|
||||
import {resolve, basename} from 'path';
|
||||
import {writeFileSync} from 'fs';
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export function newWindow(
|
|||
window.uid = classOpts.uid;
|
||||
|
||||
const rpc = createRPC(window);
|
||||
const sessions = new Map();
|
||||
const sessions = new Map<string, Session>();
|
||||
|
||||
const updateBackgroundColor = () => {
|
||||
const cfg_ = app.plugins.getDecoratedConfig();
|
||||
|
|
@ -187,11 +187,11 @@ export function newWindow(
|
|||
session.resize({cols, rows});
|
||||
}
|
||||
});
|
||||
rpc.on('data', ({uid, data, escaped}) => {
|
||||
rpc.on('data', ({uid, data, escaped}: {uid: string; data: string; escaped: boolean}) => {
|
||||
const session = sessions.get(uid);
|
||||
if (session) {
|
||||
if (escaped) {
|
||||
const escapedData = session.shell.endsWith('cmd.exe')
|
||||
const escapedData = session.shell?.endsWith('cmd.exe')
|
||||
? `"${data}"` // This is how cmd.exe does it
|
||||
: `'${data.replace(/'/g, `'\\''`)}'`; // Inside a single-quoted string nothing is interpreted
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,9 @@ const main = (argv: string[]) => {
|
|||
const child = spawn(process.execPath, args_, options);
|
||||
|
||||
if (flags.verbose) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
child.stdout?.on('data', (data) => console.log(data.toString('utf8')));
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
child.stderr?.on('data', (data) => console.error(data.toString('utf8')));
|
||||
}
|
||||
if (flags.verbose) {
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ import {
|
|||
import {setActiveGroup} from './term-groups';
|
||||
import parseUrl from 'parse-url';
|
||||
import {HyperState, HyperDispatch, HyperActions} from '../hyper';
|
||||
import {Stats} from 'fs';
|
||||
|
||||
const {stat} = window.require('fs');
|
||||
import {stat, Stats} from 'fs';
|
||||
|
||||
export function openContextMenu(uid: string, selection: any) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export default class SplitPane extends React.PureComponent<SplitPaneProps, {drag
|
|||
};
|
||||
|
||||
handleDragStart = (ev: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
ev.preventDefault();
|
||||
this.setState({dragging: true});
|
||||
window.addEventListener('mousemove', this.onDrag);
|
||||
|
|
@ -65,6 +66,7 @@ export default class SplitPane extends React.PureComponent<SplitPaneProps, {drag
|
|||
|
||||
this.dragTarget = ev.target;
|
||||
this.dragPanePosition = this.dragTarget.getBoundingClientRect()[this.d2];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
this.panesSize = ev.target.parentNode.getBoundingClientRect()[this.d1];
|
||||
this.setupPanes(ev);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -254,13 +254,14 @@ export default class Term extends React.PureComponent<TermProps> {
|
|||
|
||||
// intercepting paste event for any necessary processing of
|
||||
// clipboard data, if result is falsy, paste event continues
|
||||
onWindowPaste = (e: any) => {
|
||||
onWindowPaste = (e: Event) => {
|
||||
if (!this.props.isTermActive) return;
|
||||
|
||||
const processed = processClipboard();
|
||||
if (processed) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
(this.term as any)._core.handler(processed);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class Hyper extends React.PureComponent<HyperProps> {
|
|||
|
||||
attachKeyListeners() {
|
||||
if (!this.mousetrap) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
this.mousetrap = new (Mousetrap as any)(window, true);
|
||||
this.mousetrap.stopCallback = () => {
|
||||
// All events should be intercepted even if focus is in an input/textarea
|
||||
|
|
@ -65,10 +66,10 @@ class Hyper extends React.PureComponent<HyperProps> {
|
|||
Object.keys(keys).forEach((commandKeys) => {
|
||||
this.mousetrap.bind(
|
||||
commandKeys,
|
||||
(e: any) => {
|
||||
(e) => {
|
||||
const command = keys[commandKeys];
|
||||
// We should tell to xterm that it should ignore this event.
|
||||
e.catched = true;
|
||||
(e as any).catched = true;
|
||||
this.props.execCommand(command, getCommandHandler(command), e);
|
||||
shouldPreventDefault(command) && e.preventDefault();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -304,12 +304,12 @@ const reducer = (state = initial, action: HyperActions) => {
|
|||
|
||||
case SESSION_PTY_EXIT:
|
||||
state_ = state
|
||||
.updateIn(['openAt'], (times: ImmutableType<any>) => {
|
||||
.updateIn(['openAt'], (times: ImmutableType<Record<string, number>>) => {
|
||||
const times_ = times.asMutable();
|
||||
delete times_[action.uid];
|
||||
return times_;
|
||||
})
|
||||
.updateIn(['activityMarkers'], (markers: ImmutableType<any>) => {
|
||||
.updateIn(['activityMarkers'], (markers: ImmutableType<Record<string, boolean>>) => {
|
||||
const markers_ = markers.asMutable();
|
||||
delete markers_[action.uid];
|
||||
return markers_;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {Middleware} from 'redux';
|
|||
const effectsMiddleware: Middleware = () => (next) => (action) => {
|
||||
const ret = next(action);
|
||||
if (action.effect) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
action.effect();
|
||||
delete action.effect;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import {ObjectTypedKeys} from './object';
|
|||
const plugins = remote.require('./plugins') as typeof import('../../app/plugins');
|
||||
|
||||
// `require`d modules
|
||||
let modules: any;
|
||||
let modules: hyperPlugin[];
|
||||
|
||||
// cache of decorated components
|
||||
let decorated: Record<string, React.ComponentClass<any>> = {};
|
||||
|
|
@ -74,6 +74,7 @@ function exposeDecorated<P extends Record<string, any>>(
|
|||
onRef = (decorated_: any) => {
|
||||
if (this.props.onDecorated) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
this.props.onDecorated(decorated_);
|
||||
} catch (e) {
|
||||
notify('Plugin error', `Error occurred. Check Developer Tools for details`, {error: e});
|
||||
|
|
@ -93,7 +94,7 @@ function getDecorated<P>(parent: React.ComponentType<P>, name: string): React.Co
|
|||
|
||||
modules.forEach((mod: any) => {
|
||||
const method = 'decorate' + name;
|
||||
const fn = mod[method];
|
||||
const fn: Function & {_pluginName: string} = mod[method];
|
||||
|
||||
if (fn) {
|
||||
let class__;
|
||||
|
|
@ -190,8 +191,9 @@ const clearModulesCache = () => {
|
|||
const {path, localPath} = plugins.getBasePaths();
|
||||
|
||||
// trigger unload hooks
|
||||
modules.forEach((mod: any) => {
|
||||
modules.forEach((mod) => {
|
||||
if (mod.onRendererUnload) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
mod.onRendererUnload(window);
|
||||
}
|
||||
});
|
||||
|
|
@ -255,8 +257,8 @@ const loadModules = () => {
|
|||
const loadedPlugins = plugins.getLoadedPluginVersions().map((plugin: any) => plugin.name);
|
||||
modules = paths.plugins
|
||||
.concat(paths.localPlugins)
|
||||
.filter((plugin: any) => loadedPlugins.indexOf(basename(plugin)) !== -1)
|
||||
.map((path: any) => {
|
||||
.filter((plugin) => loadedPlugins.indexOf(basename(plugin)) !== -1)
|
||||
.map((path) => {
|
||||
let mod: hyperPlugin;
|
||||
const pluginName = getPluginName(path);
|
||||
const pluginVersion = getPluginVersion(path);
|
||||
|
|
@ -264,7 +266,7 @@ const loadModules = () => {
|
|||
// window.require allows us to ensure this doesn't get
|
||||
// in the way of our build
|
||||
try {
|
||||
mod = window.require(path) as any;
|
||||
mod = window.require(path);
|
||||
} catch (err) {
|
||||
notify(
|
||||
'Plugin load error',
|
||||
|
|
@ -358,13 +360,14 @@ const loadModules = () => {
|
|||
}
|
||||
|
||||
if (mod.onRendererWindow) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
mod.onRendererWindow(window);
|
||||
}
|
||||
console.log(`Plugin ${pluginName} (${pluginVersion}) loaded.`);
|
||||
|
||||
return mod;
|
||||
})
|
||||
.filter((mod: any) => Boolean(mod));
|
||||
.filter((mod): mod is hyperPlugin => Boolean(mod));
|
||||
|
||||
const deprecatedPlugins = plugins.getDeprecatedConfig();
|
||||
Object.keys(deprecatedPlugins).forEach((name) => {
|
||||
|
|
@ -398,6 +401,7 @@ function getProps(name: keyof typeof propsDecorators, props: any, ...fnArgs: any
|
|||
}
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
ret_ = fn(...fnArgs, props_);
|
||||
} catch (err) {
|
||||
notify('Plugin error', `${fn._pluginName}: Error occurred in \`${name}\`. Check Developer Tools for details.`, {
|
||||
|
|
@ -454,6 +458,7 @@ export function connect<stateProps, dispatchProps>(
|
|||
let ret_;
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
ret_ = fn(state, ret);
|
||||
} catch (err) {
|
||||
notify(
|
||||
|
|
@ -479,6 +484,7 @@ export function connect<stateProps, dispatchProps>(
|
|||
let ret_;
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
ret_ = fn(dispatch, ret);
|
||||
} catch (err) {
|
||||
notify(
|
||||
|
|
@ -514,12 +520,14 @@ const decorateReducer: {
|
|||
} = <T extends keyof typeof reducersDecorators>(name: T, fn: any) => {
|
||||
const reducers = reducersDecorators[name];
|
||||
return (state: any, action: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
let state_ = fn(state, action);
|
||||
|
||||
reducers.forEach((pluginReducer: any) => {
|
||||
let state__;
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
state__ = pluginReducer(state_, action);
|
||||
} catch (err) {
|
||||
notify('Plugin error', `${fn._pluginName}: Error occurred in \`${name}\`. Check Developer Tools for details.`, {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import test from 'ava';
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import test from 'ava';
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ const config: webpack.Configuration[] = [
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
new Copy({
|
||||
patterns: [
|
||||
{
|
||||
|
|
@ -98,6 +99,7 @@ const config: webpack.Configuration[] = [
|
|||
NODE_ENV: JSON.stringify(nodeEnv)
|
||||
}
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
new Copy({
|
||||
patterns: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue