Fix addon lint

This commit is contained in:
Daniel Imms
2018-01-17 10:20:04 -08:00
parent 5888cd7938
commit 70236f6818
13 changed files with 94 additions and 97 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert, expect } from 'chai';
import * as terminado from './terminado'
import * as terminado from './terminado';
class MockTerminal {}
+14 -14
View File
@@ -17,16 +17,16 @@
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
export function terminadoAttach(term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
export function terminadoAttach(term: any, socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
term.socket = socket;
term._flushBuffer = function() {
term._flushBuffer = () => {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
};
term._pushToBuffer = function(data) {
term._pushToBuffer = (data) => {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
} else {
@@ -35,9 +35,9 @@ export function terminadoAttach(term, socket, bidirectional, buffered) {
}
};
term._getMessage = function(ev) {
var data = JSON.parse(ev.data)
if( data[0] == "stdout" ) {
term._getMessage = (ev: MessageEvent) => {
const data = JSON.parse(ev.data);
if (data[0] === 'stdout') {
if (buffered) {
term._pushToBuffer(data[1]);
} else {
@@ -46,11 +46,11 @@ export function terminadoAttach(term, socket, bidirectional, buffered) {
}
};
term._sendData = function(data) {
term._sendData = (data: string) => {
socket.send(JSON.stringify(['stdin', data]));
};
term._setSize = function(size) {
term._setSize = (size: {rows: number, cols: number}) => {
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
};
@@ -72,10 +72,10 @@ export function terminadoAttach(term, socket, bidirectional, buffered) {
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
export function terminadoDetach(term, socket) {
export function terminadoDetach(term: any, socket: WebSocket): void {
term.off('data', term._sendData);
socket = (typeof socket == 'undefined') ? term.socket : socket;
socket = (typeof socket === 'undefined') ? term.socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
@@ -84,7 +84,7 @@ export function terminadoDetach(term, socket) {
delete term.socket;
};
export function apply(terminalConstructor) {
export function apply(terminalConstructor: any): void {
/**
* Attaches the current terminal to the given socket
*
@@ -95,7 +95,7 @@ export function apply(terminalConstructor) {
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
terminalConstructor.prototype.terminadoAttach = function(socket, bidirectional, buffered) {
terminalConstructor.prototype.terminadoAttach = function(socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
return terminadoAttach(this, socket, bidirectional, buffered);
};
@@ -105,7 +105,7 @@ export function apply(terminalConstructor) {
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
terminalConstructor.prototype.terminadoDetach = function(socket) {
terminalConstructor.prototype.terminadoDetach = function(socket: WebSocket): void {
return terminadoDetach(this, socket);
};
}