chore: lint using putout
This commit is contained in:
@@ -20,7 +20,7 @@ export class AttachAddon implements ITerminalAddon {
|
|||||||
this._socket = socket;
|
this._socket = socket;
|
||||||
// always set binary type to arraybuffer, we do not handle blobs
|
// always set binary type to arraybuffer, we do not handle blobs
|
||||||
this._socket.binaryType = 'arraybuffer';
|
this._socket.binaryType = 'arraybuffer';
|
||||||
this._bidirectional = (options && options.bidirectional === false) ? false : true;
|
this._bidirectional = !(options && options.bidirectional === false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public activate(terminal: Terminal): void {
|
public activate(terminal: Terminal): void {
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
// If it is not in the viewport then we scroll else it just gets selected
|
// If it is not in the viewport then we scroll else it just gets selected
|
||||||
if (result.row >= (terminal.buffer.active.viewportY + terminal.rows) || result.row < terminal.buffer.active.viewportY) {
|
if (result.row >= (terminal.buffer.active.viewportY + terminal.rows) || result.row < terminal.buffer.active.viewportY) {
|
||||||
let scroll = result.row - terminal.buffer.active.viewportY;
|
let scroll = result.row - terminal.buffer.active.viewportY;
|
||||||
scroll = scroll - Math.floor(terminal.rows / 2);
|
scroll -= Math.floor(terminal.rows / 2);
|
||||||
terminal.scrollLines(scroll);
|
terminal.scrollLines(scroll);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -487,9 +487,9 @@ function newArray<T>(initial: T | ((index: number) => T), count: number): T[] {
|
|||||||
const array: T[] = new Array<T>(count);
|
const array: T[] = new Array<T>(count);
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
if (typeof initial === 'function') {
|
if (typeof initial === 'function') {
|
||||||
array[i] = (<(index: number) => T>initial)(i);
|
array[i] = (initial as (index: number) => T)(i);
|
||||||
} else {
|
} else {
|
||||||
array[i] = <T>initial;
|
array[i] = initial as T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ export class GlyphRenderer {
|
|||||||
// Get attributes from fg (excluding inverse) and resolve inverse by pullibng rgb colors
|
// Get attributes from fg (excluding inverse) and resolve inverse by pullibng rgb colors
|
||||||
// from bg. This is needed since the inverse fg color should be based on the original bg
|
// from bg. This is needed since the inverse fg color should be based on the original bg
|
||||||
// color, not on the selection color
|
// color, not on the selection color
|
||||||
fg = (fg & ~(Attributes.CM_MASK | Attributes.RGB_MASK | FgFlags.INVERSE));
|
fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK | FgFlags.INVERSE);
|
||||||
switch (workCell.getBgColorMode()) {
|
switch (workCell.getBgColorMode()) {
|
||||||
case Attributes.CM_P16:
|
case Attributes.CM_P16:
|
||||||
case Attributes.CM_P256:
|
case Attributes.CM_P256:
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ export class WebglAddon implements ITerminalAddon {
|
|||||||
throw new Error('Cannot activate WebglAddon before Terminal.open');
|
throw new Error('Cannot activate WebglAddon before Terminal.open');
|
||||||
}
|
}
|
||||||
this._terminal = terminal;
|
this._terminal = terminal;
|
||||||
const renderService: IRenderService = (<any>terminal)._core._renderService;
|
const renderService: IRenderService = (terminal as any)._core._renderService;
|
||||||
const characterJoinerService: ICharacterJoinerService = (<any>terminal)._core._characterJoinerService;
|
const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService;
|
||||||
const colors: IColorSet = (<any>terminal)._core._colorManager.colors;
|
const colors: IColorSet = (terminal as any)._core._colorManager.colors;
|
||||||
this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, this._preserveDrawingBuffer);
|
this._renderer = new WebglRenderer(terminal, colors, characterJoinerService, this._preserveDrawingBuffer);
|
||||||
this._renderer.onContextLoss(() => this._onContextLoss.fire());
|
this._renderer.onContextLoss(() => this._onContextLoss.fire());
|
||||||
renderService.setRenderer(this._renderer);
|
renderService.setRenderer(this._renderer);
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
// Flag combined chars with a bit mask so they're easily identifiable
|
// Flag combined chars with a bit mask so they're easily identifiable
|
||||||
if (chars.length > 1) {
|
if (chars.length > 1) {
|
||||||
code = code | COMBINED_CHAR_BIT_MASK;
|
code |= COMBINED_CHAR_BIT_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the results in the model
|
// Cache the results in the model
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class AccessibilityManager extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
|
private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
|
||||||
const boundaryElement = <HTMLElement>e.target;
|
const boundaryElement = e.target as HTMLElement;
|
||||||
const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];
|
const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];
|
||||||
|
|
||||||
// Don't scroll if the buffer top has reached the end in that direction
|
// Don't scroll if the buffer top has reached the end in that direction
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ describe('ColorManager', () => {
|
|||||||
dom = new jsdom.JSDOM('');
|
dom = new jsdom.JSDOM('');
|
||||||
window = dom.window;
|
window = dom.window;
|
||||||
document = window.document;
|
document = window.document;
|
||||||
(<any>window).HTMLCanvasElement.prototype.getContext = () => ({
|
(window as any).HTMLCanvasElement.prototype.getContext = () => ({
|
||||||
createLinearGradient(): any {
|
createLinearGradient(): any {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -36,7 +36,7 @@ describe('ColorManager', () => {
|
|||||||
for (const key of Object.keys(cm.colors)) {
|
for (const key of Object.keys(cm.colors)) {
|
||||||
if (key !== 'ansi' && key !== 'contrastCache') {
|
if (key !== 'ansi' && key !== 'contrastCache') {
|
||||||
// A #rrggbb or rgba(...)
|
// A #rrggbb or rgba(...)
|
||||||
assert.ok((<any>cm.colors)[key].css.length >= 7);
|
assert.ok((cm.colors as any)[key].css.length >= 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert.equal(cm.colors.ansi.length, 256);
|
assert.equal(cm.colors.ansi.length, 256);
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ describe('Linkifier', () => {
|
|||||||
assert.equal(mouseZoneManager.zones[0].y1, 1);
|
assert.equal(mouseZoneManager.zones[0].y1, 1);
|
||||||
assert.equal(mouseZoneManager.zones[0].y2, 1);
|
assert.equal(mouseZoneManager.zones[0].y2, 1);
|
||||||
// Fires done()
|
// Fires done()
|
||||||
mouseZoneManager.zones[0].clickCallback(<any>{});
|
mouseZoneManager.zones[0].clickCallback({} as any);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
linkifier.linkifyRows();
|
linkifier.linkifyRows();
|
||||||
@@ -210,7 +210,7 @@ describe('Linkifier', () => {
|
|||||||
let count = 0;
|
let count = 0;
|
||||||
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
||||||
validationCallback: (url, cb) => {
|
validationCallback: (url, cb) => {
|
||||||
count += 1;
|
++count;
|
||||||
if (count === 2) {
|
if (count === 2) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class Linkifier implements ILinkifier {
|
|||||||
if (this._rowsTimeoutId) {
|
if (this._rowsTimeoutId) {
|
||||||
clearTimeout(this._rowsTimeoutId);
|
clearTimeout(this._rowsTimeoutId);
|
||||||
}
|
}
|
||||||
this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency);
|
this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency) as any as number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ describe('Terminal', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
term = new TestTerminal(termOptions);
|
term = new TestTerminal(termOptions);
|
||||||
term.refresh = () => { };
|
term.refresh = () => { };
|
||||||
(<any>term).renderer = new MockRenderer();
|
(term as any).renderer = new MockRenderer();
|
||||||
term.viewport = new MockViewport();
|
term.viewport = new MockViewport();
|
||||||
(<any>term)._compositionHelper = new MockCompositionHelper();
|
(term as any)._compositionHelper = new MockCompositionHelper();
|
||||||
(<any>term).element = {
|
(term as any).element = {
|
||||||
classList: {
|
classList: {
|
||||||
toggle: () => { },
|
toggle: () => { },
|
||||||
remove: () => { }
|
remove: () => { }
|
||||||
@@ -86,12 +86,12 @@ describe('Terminal', () => {
|
|||||||
assert.equal(e.domEvent instanceof Object, true);
|
assert.equal(e.domEvent instanceof Object, true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
const evKeyPress = <KeyboardEvent>{
|
const evKeyPress = {
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keypress',
|
type: 'keypress',
|
||||||
keyCode: 13
|
keyCode: 13
|
||||||
};
|
} as KeyboardEvent;
|
||||||
term.keyPress(evKeyPress);
|
term.keyPress(evKeyPress);
|
||||||
});
|
});
|
||||||
it('should fire a key event after a keydown DOM event', (done) => {
|
it('should fire a key event after a keydown DOM event', (done) => {
|
||||||
@@ -100,13 +100,13 @@ describe('Terminal', () => {
|
|||||||
assert.equal(e.domEvent instanceof Object, true);
|
assert.equal(e.domEvent instanceof Object, true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
(<any>term).textarea = { value: '' };
|
(term as any).textarea = { value: '' };
|
||||||
const evKeyDown = <KeyboardEvent>{
|
const evKeyDown = {
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keydown',
|
type: 'keydown',
|
||||||
keyCode: 13
|
keyCode: 13
|
||||||
};
|
} as KeyboardEvent;
|
||||||
term.keyDown(evKeyDown);
|
term.keyDown(evKeyDown);
|
||||||
});
|
});
|
||||||
it('should fire the onResize event', (done) => {
|
it('should fire the onResize event', (done) => {
|
||||||
@@ -140,18 +140,18 @@ describe('Terminal', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('attachCustomKeyEventHandler', () => {
|
describe('attachCustomKeyEventHandler', () => {
|
||||||
const evKeyDown = <KeyboardEvent>{
|
const evKeyDown = {
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keydown',
|
type: 'keydown',
|
||||||
keyCode: 77
|
keyCode: 77
|
||||||
};
|
} as KeyboardEvent;
|
||||||
const evKeyPress = <KeyboardEvent>{
|
const evKeyPress = {
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keypress',
|
type: 'keypress',
|
||||||
keyCode: 77
|
keyCode: 77
|
||||||
};
|
} as KeyboardEvent;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
term.clearSelection = () => { };
|
term.clearSelection = () => { };
|
||||||
@@ -374,13 +374,13 @@ describe('Terminal', () => {
|
|||||||
|
|
||||||
describe('keyPress', () => {
|
describe('keyPress', () => {
|
||||||
it('should scroll down, when a key is pressed and terminal is scrolled up', () => {
|
it('should scroll down, when a key is pressed and terminal is scrolled up', () => {
|
||||||
const event = <KeyboardEvent>{
|
const event = {
|
||||||
type: 'keydown',
|
type: 'keydown',
|
||||||
key: 'a',
|
key: 'a',
|
||||||
keyCode: 65,
|
keyCode: 65,
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { }
|
stopPropagation: () => { }
|
||||||
};
|
} as KeyboardEvent;
|
||||||
|
|
||||||
term.buffer.ydisp = 0;
|
term.buffer.ydisp = 0;
|
||||||
term.buffer.ybase = 40;
|
term.buffer.ybase = 40;
|
||||||
@@ -403,7 +403,7 @@ describe('Terminal', () => {
|
|||||||
assert.equal(term.buffer.ydisp, startYDisp);
|
assert.equal(term.buffer.ydisp, startYDisp);
|
||||||
term.scrollLines(-1);
|
term.scrollLines(-1);
|
||||||
assert.equal(term.buffer.ydisp, startYDisp - 1);
|
assert.equal(term.buffer.ydisp, startYDisp - 1);
|
||||||
term.keyPress(<KeyboardEvent>{ keyCode: 0 });
|
term.keyPress({ keyCode: 0 } as KeyboardEvent);
|
||||||
assert.equal(term.buffer.ydisp, startYDisp - 1);
|
assert.equal(term.buffer.ydisp, startYDisp - 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
|
|
||||||
// private _visualBellTimer: number;
|
// private _visualBellTimer: number;
|
||||||
|
|
||||||
public browser: IBrowser = <any>Browser;
|
public browser: IBrowser = Browser as any;
|
||||||
|
|
||||||
// TODO: We should remove options once components adopt optionsService
|
// TODO: We should remove options once components adopt optionsService
|
||||||
public get options(): IInitializedTerminalOptions { return this.optionsService.options; }
|
public get options(): IInitializedTerminalOptions { return this.optionsService.options; }
|
||||||
@@ -601,7 +601,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
|
|
||||||
let but: CoreMouseButton;
|
let but: CoreMouseButton;
|
||||||
let action: CoreMouseAction | undefined;
|
let action: CoreMouseAction | undefined;
|
||||||
switch ((<any>ev).overrideType || ev.type) {
|
switch ((ev as any).overrideType || ev.type) {
|
||||||
case 'mousemove':
|
case 'mousemove':
|
||||||
action = CoreMouseAction.MOVE;
|
action = CoreMouseAction.MOVE;
|
||||||
if (ev.buttons === undefined) {
|
if (ev.buttons === undefined) {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ function formatError(input: string, output: string, expected: string): string {
|
|||||||
function addLineNumber(start: number, color: string): (s: string) => string {
|
function addLineNumber(start: number, color: string): (s: string) => string {
|
||||||
let counter = start || 0;
|
let counter = start || 0;
|
||||||
return (s: string): string => {
|
return (s: string): string => {
|
||||||
counter += 1;
|
++counter;
|
||||||
return '\x1b[33m' + (' ' + counter).slice(-2) + color + s;
|
return '\x1b[33m' + (' ' + counter).slice(-2) + color + s;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ export class MockTerminal implements ITerminal {
|
|||||||
public textarea!: HTMLTextAreaElement;
|
public textarea!: HTMLTextAreaElement;
|
||||||
public rows!: number;
|
public rows!: number;
|
||||||
public cols!: number;
|
public cols!: number;
|
||||||
public browser: IBrowser = <any>Browser;
|
public browser: IBrowser = Browser as any;
|
||||||
public writeBuffer!: string[];
|
public writeBuffer!: string[];
|
||||||
public children!: HTMLElement[];
|
public children!: HTMLElement[];
|
||||||
public cursorHidden!: boolean;
|
public cursorHidden!: boolean;
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ export function clone<T>(val: T, depth: number = 5): T {
|
|||||||
|
|
||||||
for (const key in val) {
|
for (const key in val) {
|
||||||
// Recursively clone eack item unless we're at the maximum depth
|
// Recursively clone eack item unless we're at the maximum depth
|
||||||
clonedObject[key] = depth <= 1 ? val[key] : (val[key] ? clone(val[key], depth - 1) : val[key]);
|
clonedObject[key] = depth <= 1 ? val[key] : (val[key] && clone(val[key], depth - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedObject as T;
|
return clonedObject as T;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ describe('InputHandler', () => {
|
|||||||
optionsService.options.scrollback = 1;
|
optionsService.options.scrollback = 1;
|
||||||
bufferService.reset();
|
bufferService.reset();
|
||||||
});
|
});
|
||||||
it('SL (scrollLeft)', async () => {
|
it('SL (scrollLeft)', () => {
|
||||||
inputHandler.parseP('12345'.repeat(6));
|
inputHandler.parseP('12345'.repeat(6));
|
||||||
inputHandler.parseP('\x1b[ @');
|
inputHandler.parseP('\x1b[ @');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['12345', '2345', '2345', '2345', '2345', '2345']);
|
assert.deepEqual(getLines(bufferService, 6), ['12345', '2345', '2345', '2345', '2345', '2345']);
|
||||||
@@ -86,7 +86,7 @@ describe('InputHandler', () => {
|
|||||||
inputHandler.parseP('\x1b[2 @');
|
inputHandler.parseP('\x1b[2 @');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['12345', '5', '5', '5', '5', '5']);
|
assert.deepEqual(getLines(bufferService, 6), ['12345', '5', '5', '5', '5', '5']);
|
||||||
});
|
});
|
||||||
it('SR (scrollRight)', async () => {
|
it('SR (scrollRight)', () => {
|
||||||
inputHandler.parseP('12345'.repeat(6));
|
inputHandler.parseP('12345'.repeat(6));
|
||||||
inputHandler.parseP('\x1b[ A');
|
inputHandler.parseP('\x1b[ A');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']);
|
assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1234', ' 1234', ' 1234', ' 1234', ' 1234']);
|
||||||
@@ -95,7 +95,7 @@ describe('InputHandler', () => {
|
|||||||
inputHandler.parseP('\x1b[2 A');
|
inputHandler.parseP('\x1b[2 A');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']);
|
assert.deepEqual(getLines(bufferService, 6), ['12345', ' 1', ' 1', ' 1', ' 1', ' 1']);
|
||||||
});
|
});
|
||||||
it('insertColumns (DECIC)', async () => {
|
it('insertColumns (DECIC)', () => {
|
||||||
inputHandler.parseP('12345'.repeat(6));
|
inputHandler.parseP('12345'.repeat(6));
|
||||||
inputHandler.parseP('\x1b[3;3H');
|
inputHandler.parseP('\x1b[3;3H');
|
||||||
inputHandler.parseP('\x1b[\'}');
|
inputHandler.parseP('\x1b[\'}');
|
||||||
@@ -111,7 +111,7 @@ describe('InputHandler', () => {
|
|||||||
inputHandler.parseP('\x1b[2\'}');
|
inputHandler.parseP('\x1b[2\'}');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']);
|
assert.deepEqual(getLines(bufferService, 6), ['12345', '12 3', '12 3', '12 3', '12 3', '12 3']);
|
||||||
});
|
});
|
||||||
it('deleteColumns (DECDC)', async () => {
|
it('deleteColumns (DECDC)', () => {
|
||||||
inputHandler.parseP('12345'.repeat(6));
|
inputHandler.parseP('12345'.repeat(6));
|
||||||
inputHandler.parseP('\x1b[3;3H');
|
inputHandler.parseP('\x1b[3;3H');
|
||||||
inputHandler.parseP('\x1b[\'~');
|
inputHandler.parseP('\x1b[\'~');
|
||||||
@@ -137,7 +137,7 @@ describe('InputHandler', () => {
|
|||||||
bufferService.reset();
|
bufferService.reset();
|
||||||
});
|
});
|
||||||
describe('reverseWraparound set', () => {
|
describe('reverseWraparound set', () => {
|
||||||
it('should not reverse outside of scroll margins', async () => {
|
it('should not reverse outside of scroll margins', () => {
|
||||||
// prepare buffer content
|
// prepare buffer content
|
||||||
inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy');
|
inputHandler.parseP('#####abcdefghijklmnopqrstuvwxy');
|
||||||
assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']);
|
assert.deepEqual(getLines(bufferService, 6), ['#####', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']);
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export class MockOptionsService implements IOptionsService {
|
|||||||
constructor(testOptions?: IPartialTerminalOptions) {
|
constructor(testOptions?: IPartialTerminalOptions) {
|
||||||
if (testOptions) {
|
if (testOptions) {
|
||||||
for (const key of Object.keys(testOptions)) {
|
for (const key of Object.keys(testOptions)) {
|
||||||
this.options[key] = (<any>testOptions)[key];
|
this.options[key] = (testOptions as any)[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user