chore: lint using putout

This commit is contained in:
coderaiser
2020-06-01 00:04:17 +03:00
parent 4e6151d011
commit f63f1f7b95
16 changed files with 50 additions and 31 deletions
+1
View File
@@ -32,6 +32,7 @@
"@typescript-eslint"
],
"rules": {
"no-extra-semi": "error",
"@typescript-eslint/array-type": [
"warn",
{
+2 -2
View File
@@ -60,7 +60,7 @@ describe('Escape Sequence Files', function(): void {
ptyTerm._master.destroy();
});
FILES.forEach(filename => {
for (const filename of FILES) {
(process.platform === 'win32' ? it.skip : it)(filename.split('/').slice(-1)[0], async () => {
// reset terminal and handler
if (customHandler) {
@@ -93,7 +93,7 @@ describe('Escape Sequence Files', function(): void {
throw new Error(formatError(fs.readFileSync(filename, 'utf8'), content, expected));
}
});
});
}
});
/**
+2 -2
View File
@@ -204,11 +204,11 @@ export class Terminal implements ITerminalApi {
}
private _verifyIntegers(...values: number[]): void {
values.forEach(value => {
for (const value of values) {
if (value === Infinity || isNaN(value) || value % 1 !== 0) {
throw new Error('This API only accepts integers');
}
});
}
}
}
+14 -6
View File
@@ -71,7 +71,9 @@ export class Renderer extends Disposable implements IRenderer {
}
public dispose(): void {
this._renderLayers.forEach(l => l.dispose());
for (const l of this._renderLayers) {
l.dispose();
}
super.dispose();
removeTerminalFromCache(this._id);
}
@@ -89,10 +91,10 @@ export class Renderer extends Disposable implements IRenderer {
this._colors = colors;
// Clear layers and force a full render
this._renderLayers.forEach(l => {
for (const l of this._renderLayers) {
l.setColors(this._colors);
l.reset();
});
}
}
public onResize(cols: number, rows: number): void {
@@ -100,7 +102,9 @@ export class Renderer extends Disposable implements IRenderer {
this._updateDimensions();
// Resize all render layers
this._renderLayers.forEach(l => l.resize(this.dimensions));
for (const l of this._renderLayers) {
l.resize(this.dimensions);
}
// Resize the screen
this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;
@@ -136,7 +140,9 @@ export class Renderer extends Disposable implements IRenderer {
}
private _runOperation(operation: (layer: IRenderLayer) => void): void {
this._renderLayers.forEach(l => operation(l));
for (const l of this._renderLayers) {
operation(l);
}
}
/**
@@ -144,7 +150,9 @@ export class Renderer extends Disposable implements IRenderer {
* necessary before queueing up the next one.
*/
public renderRows(start: number, end: number): void {
this._renderLayers.forEach(l => l.onGridChanged(start, end));
for (const l of this._renderLayers) {
l.onGridChanged(start, end);
}
}
/**
+2 -2
View File
@@ -188,13 +188,13 @@ export class TextRenderLayer extends BaseRenderLayer {
if (y !== startY) {
// our row changed, draw the previous row
ctx.fillStyle = prevFillStyle ? prevFillStyle : '';
ctx.fillStyle = prevFillStyle || '';
this._fillCells(startX, startY, cols - startX, 1);
startX = x;
startY = y;
} else if (prevFillStyle !== nextFillStyle) {
// our color changed, draw the previous characters in this row
ctx.fillStyle = prevFillStyle ? prevFillStyle : '';
ctx.fillStyle = prevFillStyle || '';
this._fillCells(startX, startY, x - startX, 1);
startX = x;
startY = y;
+5 -3
View File
@@ -116,13 +116,13 @@ export class DomRenderer extends Disposable implements IRenderer {
this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;
this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;
this._rowElements.forEach(element => {
for (const element of this._rowElements) {
element.style.width = `${this.dimensions.canvasWidth}px`;
element.style.height = `${this.dimensions.actualCellHeight}px`;
element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;
// Make sure rows don't overflow onto following row
element.style.overflow = 'hidden';
});
}
if (!this._dimensionsStyleElement) {
this._dimensionsStyleElement = document.createElement('style');
@@ -346,7 +346,9 @@ export class DomRenderer extends Disposable implements IRenderer {
}
public clear(): void {
this._rowElements.forEach(e => e.innerHTML = '');
for (const e of this._rowElements) {
e.innerHTML = '';
}
}
public renderRows(start: number, end: number): void {
+3 -1
View File
@@ -328,7 +328,9 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
}));
this._windowsMode = {
dispose: () => {
disposables.forEach(d => d.dispose());
for (const d of disposables) {
d.dispose();
}
}
};
}
+6 -2
View File
@@ -21,7 +21,9 @@ export abstract class Disposable implements IDisposable {
*/
public dispose(): void {
this._isDisposed = true;
this._disposables.forEach(d => d.dispose());
for (const d of this._disposables) {
d.dispose();
}
this._disposables.length = 0;
}
@@ -52,7 +54,9 @@ export abstract class Disposable implements IDisposable {
* Dispose of all disposables in an array and set its length to 0.
*/
export function disposeArray(disposables: IDisposable[]): void {
disposables.forEach(d => d.dispose());
for (const d of disposables) {
d.dispose();
}
disposables.length = 0;
}
+3 -1
View File
@@ -104,7 +104,9 @@ export class MockOptionsService implements IOptionsService {
public onOptionChange: IEvent<string> = new EventEmitter<string>().event;
constructor(testOptions?: IPartialTerminalOptions) {
if (testOptions) {
Object.keys(testOptions).forEach(key => this.options[key] = (<any>testOptions)[key]);
for (const key of Object.keys(testOptions)) {
this.options[key] = (<any>testOptions)[key];
}
}
}
public setOption<T>(key: string, value: T): void {
+3 -3
View File
@@ -666,11 +666,11 @@ export class BufferStringIterator implements IBufferStringIterator {
// limit to current buffer length
range.first = Math.max(range.first, 0);
range.last = Math.min(range.last, this._buffer.lines.length);
let result = '';
let content = '';
for (let i = range.first; i <= range.last; ++i) {
result += this._buffer.translateBufferLineToString(i, this._trimRight);
content += this._buffer.translateBufferLineToString(i, this._trimRight);
}
this._current = range.last + 1;
return {range: range, content: result};
return {range: range, content};
}
}
+1 -1
View File
@@ -139,7 +139,7 @@ describe('Keyboard', () => {
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 40 }, { isMac: true }).key, '\x1b[1;3B'); // CSI 5 C
});
it('should return undefined for alt+a', () => {
assert.strictEqual(testEvaluateKeyboardEvent({ altKey: true, keyCode: 65 }, { isMac: true }).key, undefined), { isMac: true };
assert.strictEqual(testEvaluateKeyboardEvent({ altKey: true, keyCode: 65 }, { isMac: true }).key, undefined);
});
});
+1 -1
View File
@@ -136,7 +136,7 @@ export class DcsHandler implements IDcsHandler {
if (this._hitLimit) {
ret = false;
} else if (success) {
ret = this._handler(this._data, this._params ? this._params : new Params());
ret = this._handler(this._data, this._params || new Params());
}
this._params = undefined;
this._data = '';
@@ -1589,9 +1589,9 @@ describe('EscapeSequenceParser', function (): void {
});
it('final ESC range 0x30 .. 0x7e, one byte', () => {
for (let i = 0x30; i <= 0x7e; ++i) {
const c = String.fromCharCode(i);
const final = String.fromCharCode(i);
let handler: IDisposable | undefined;
chai.assert.doesNotThrow(() => { handler = parser.addEscHandler({final: c}, () => {}); }, 'final must be in range 48 .. 126');
chai.assert.doesNotThrow(() => { handler = parser.addEscHandler({final}, () => {}); }, 'final must be in range 48 .. 126');
if (handler) handler.dispose();
}
chai.assert.throws(() => { parser.addEscHandler({final: '\x2f'}, () => {}); }, 'final must be in range 48 .. 126');
+2 -2
View File
@@ -174,8 +174,8 @@ export class CoreMouseService implements ICoreMouseService {
@ICoreService private readonly _coreService: ICoreService
) {
// register default protocols and encodings
Object.keys(DEFAULT_PROTOCOLS).forEach(name => this.addProtocol(name, DEFAULT_PROTOCOLS[name]));
Object.keys(DEFAULT_ENCODINGS).forEach(name => this.addEncoding(name, DEFAULT_ENCODINGS[name]));
for (const name of Object.keys(DEFAULT_PROTOCOLS)) this.addProtocol(name, DEFAULT_PROTOCOLS[name]);
for (const name of Object.keys(DEFAULT_ENCODINGS)) this.addEncoding(name, DEFAULT_ENCODINGS[name]);
// call reset to set defaults
this.reset();
}
+2 -2
View File
@@ -71,12 +71,12 @@ export class OptionsService implements IOptionsService {
constructor(options: IPartialTerminalOptions) {
this.options = clone(DEFAULT_OPTIONS);
Object.keys(options).forEach(k => {
for (const k of Object.keys(options)) {
if (k in this.options) {
const newValue = options[k as keyof IPartialTerminalOptions] as any;
this.options[k] = newValue;
}
});
}
}
public setOption(key: string, value: any): void {
+1 -1
View File
@@ -136,7 +136,7 @@ export interface IServiceIdentifier<T> {
export interface IBrandedService {
serviceBrand: undefined;
};
}
type GetLeadingNonServiceArgs<Args> =
Args extends [...IBrandedService[]] ? []