summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-06-09 02:59:53 +0200
committerErik Larkö <erik@mullvad.net>2017-06-09 02:59:53 +0200
commit4137ee6d93061992880cf78a8eeeffe37efef2b3 (patch)
treedd15aa8553cd9b5a192607279f88eb66921b6cc4
parent2e49dd1a621f3aea5c92f69eaf3f6338bc0e8784 (diff)
parent5f9a035125504f42e45535ad536db901f0ad00da (diff)
downloadmullvadvpn-4137ee6d93061992880cf78a8eeeffe37efef2b3.tar.xz
mullvadvpn-4137ee6d93061992880cf78a8eeeffe37efef2b3.zip
Merge branch 'remove-any'
-rw-r--r--.eslintrc1
-rw-r--r--app/app.js2
-rw-r--r--app/lib/backend-routing.js4
-rw-r--r--app/lib/ipc-facade.js16
-rw-r--r--app/lib/jsonrpc-ws-ipc.js34
-rw-r--r--app/main.js2
6 files changed, 39 insertions, 20 deletions
diff --git a/.eslintrc b/.eslintrc
index a931b6a269..70248418cd 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -24,6 +24,7 @@
"func-names": [ 0 ],
"comma-dangle": [ 0 ],
"no-unused-expressions" : [ 0 ], // until fixed https://github.com/babel/babel-eslint/issues/158
+ "no-unused-vars": ["error", {"args": all, "argsIgnorePattern": "_.*"}],
"block-scoped-var": [ 0 ], // until fixed https://github.com/eslint/eslint/issues/2253
"react/prop-types": [ 0 ]
},
diff --git a/app/app.js b/app/app.js
index 935c6da28c..7eef8f3685 100644
--- a/app/app.js
+++ b/app/app.js
@@ -62,7 +62,7 @@ mapBackendEventsToReduxActions(backend, store);
// Setup routing based on backend events
mapBackendEventsToRouter(backend, store);
-ipcRenderer.on('backend-info', (event, args) => {
+ipcRenderer.on('backend-info', (_event, args) => {
backend.setLocation(args.addr);
backend.sync();
});
diff --git a/app/lib/backend-routing.js b/app/lib/backend-routing.js
index 7a39c80f05..11c9f349eb 100644
--- a/app/lib/backend-routing.js
+++ b/app/lib/backend-routing.js
@@ -10,7 +10,7 @@ import Backend from './backend';
*/
export default function mapBackendEventsToRouter(backend, store) {
// redirect user to main screen after login
- backend.on(Backend.EventType.login, (account, error) => {
+ backend.on(Backend.EventType.login, (_account, error) => {
if(error) { return; } // no-op on error
setTimeout(() => {
@@ -28,4 +28,4 @@ export default function mapBackendEventsToRouter(backend, store) {
// redirect user to login page on logout
backend.on(Backend.EventType.logout, () => store.dispatch(replace('/')));
-} \ No newline at end of file
+}
diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js
index 57305e9cab..e24a89dd65 100644
--- a/app/lib/ipc-facade.js
+++ b/app/lib/ipc-facade.js
@@ -49,19 +49,27 @@ export class RealIpc implements IpcFacade {
}
setAccount(accountNumber: AccountNumber): Promise<void> {
- return this._ipc.send('set_account', accountNumber);
+ return this._ipc.send('set_account', accountNumber)
+ .then(this._ignoreResponse);
+ }
+
+ _ignoreResponse(_response: mixed): void {
+ return;
}
setCountry(address: string): Promise<void> {
- return this._ipc.send('set_country', address);
+ return this._ipc.send('set_country', address)
+ .then(this._ignoreResponse);
}
connect(): Promise<void> {
- return this._ipc.send('connect');
+ return this._ipc.send('connect')
+ .then(this._ignoreResponse);
}
disconnect(): Promise<void> {
- return this._ipc.send('disconnect');
+ return this._ipc.send('disconnect')
+ .then(this._ignoreResponse);
}
getIp(): Promise<Ip> {
diff --git a/app/lib/jsonrpc-ws-ipc.js b/app/lib/jsonrpc-ws-ipc.js
index b31e683635..89964cb48f 100644
--- a/app/lib/jsonrpc-ws-ipc.js
+++ b/app/lib/jsonrpc-ws-ipc.js
@@ -4,9 +4,9 @@ import jsonrpc from 'jsonrpc-lite';
import uuid from 'uuid';
import log from 'electron-log';
-export type UnansweredRequest<T, E> = {
- resolve: (T) => void,
- reject: (E) => void,
+export type UnansweredRequest = {
+ resolve: (mixed) => void,
+ reject: (mixed) => void,
timeout: number,
}
@@ -25,7 +25,7 @@ export type JsonRpcNotification = {
method: string,
params: {
subscription: string,
- result: any,
+ result: mixed,
}
}
}
@@ -33,7 +33,7 @@ export type JsonRpcSuccess = {
type: 'success',
payload: {
id: string,
- result: any,
+ result: mixed,
}
}
export type JsonRpcMessage = JsonRpcError | JsonRpcNotification | JsonRpcSuccess;
@@ -61,8 +61,8 @@ export default class Ipc {
_connectionString: ?string;
_onConnect: Array<{resolve: ()=>void}>;
- _unansweredRequests: {[string]: UnansweredRequest<any, any>};
- _subscriptions: {[string]: (any) => void};
+ _unansweredRequests: {[string]: UnansweredRequest};
+ _subscriptions: {[string|number]: (mixed) => void};
_websocket: WebSocket;
_backoff: ReconnectionBackoff;
_websocketFactory: (string) => WebSocket;
@@ -84,7 +84,7 @@ export default class Ipc {
this._sendTimeoutMillis = millis;
}
- on(event: string, listener: (any) => void): Promise<*> {
+ on(event: string, listener: (mixed) => void): Promise<*> {
// We're currently not actually using the event parameter.
// This is because we aren't sure if the backend will use
// one subscription per event or one subscription per
@@ -92,10 +92,16 @@ export default class Ipc {
log.info('Adding a listener to', event);
return this.send('event_subscribe')
- .then(subscriptionId => this._subscriptions[subscriptionId] = listener);
+ .then(subscriptionId => {
+ if (typeof subscriptionId === 'string' || typeof subscriptionId === 'number') {
+ this._subscriptions[subscriptionId] = listener;
+ } else {
+ throw new InvalidReply(subscriptionId);
+ }
+ });
}
- send(action: string, ...data: Array<any>): Promise<any> {
+ send(action: string, ...data: Array<mixed>): Promise<mixed> {
return this._getWebSocket()
.then(ws => this._send(ws, action, data))
.catch(e => {
@@ -207,8 +213,12 @@ export default class Ipc {
};
this._websocket.onmessage = (evt) => {
- const data: string = (evt.data: any);
- this._onMessage(data);
+ const data = evt.data;
+ if (typeof data === 'string') {
+ this._onMessage(data);
+ } else {
+ log.error('Got invalid reply from the server', evt);
+ }
};
this._websocket.onclose = () => {
diff --git a/app/main.js b/app/main.js
index 48102da00f..b3c028c9b9 100644
--- a/app/main.js
+++ b/app/main.js
@@ -112,7 +112,7 @@ const createContextMenu = () => {
];
// add inspect element on right click menu
- window.webContents.on('context-menu', (e, props) => {
+ window.webContents.on('context-menu', (_e, props) => {
let inspectTemplate = [{
label: 'Inspect element',
click() {