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