diff --git a/.eslintrc.js b/.eslintrc.js index b8f8b181..e7fbf6eb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,6 +87,7 @@ module.exports = { "error", "always" ], + "keyword-spacing": "error", "new-parens": "error", "no-duplicate-imports": "error", "no-else-return": [ @@ -104,6 +105,7 @@ module.exports = { ] } ], + "no-irregular-whitespace": "error", "no-trailing-spaces": "error", "no-unsafe-finally": "error", "no-var": "error", @@ -134,6 +136,7 @@ module.exports = { { "selector": "typeLike", "format": ["PascalCase"] }, { "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] }, ], + "@typescript-eslint/type-annotation-spacing": "error", "@typescript-eslint/explicit-function-return-type": [ "error", { diff --git a/addons/xterm-addon-fit/src/FitAddon.ts b/addons/xterm-addon-fit/src/FitAddon.ts index ca7e24b1..8e963253 100644 --- a/addons/xterm-addon-fit/src/FitAddon.ts +++ b/addons/xterm-addon-fit/src/FitAddon.ts @@ -38,7 +38,7 @@ export class FitAddon implements ITerminalAddon { } // TODO: Remove reliance on private API - const core = (this._terminal)._core; + const core = (this._terminal as any)._core; // Force a full render if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) { @@ -57,7 +57,7 @@ export class FitAddon implements ITerminalAddon { } // TODO: Remove reliance on private API - const core = (this._terminal)._core; + const core = (this._terminal as any)._core; const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement); const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')); diff --git a/addons/xterm-addon-web-links/src/WebLinksAddon.ts b/addons/xterm-addon-web-links/src/WebLinksAddon.ts index 8d0e40ee..dbc664a8 100644 --- a/addons/xterm-addon-web-links/src/WebLinksAddon.ts +++ b/addons/xterm-addon-web-links/src/WebLinksAddon.ts @@ -56,7 +56,7 @@ export class WebLinksAddon implements ITerminalAddon { this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler)); } else { // TODO: This should be removed eventually - this._linkMatcherId = (this._terminal).registerLinkMatcher(strictUrlRegex, this._handler, this._options); + this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, this._options); } } diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index 3cf45f35..77812a6f 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -21,7 +21,7 @@ export class WebglAddon implements ITerminalAddon { throw new Error('Cannot activate WebglAddon before Terminal.open'); } this._terminal = terminal; - const renderService: IRenderService = (terminal)._core._renderService; + const renderService: IRenderService = (terminal)._core._renderService; const colors: IColorSet = (terminal)._core._colorManager.colors; this._renderer = new WebglRenderer(terminal, colors, this._preserveDrawingBuffer); renderService.setRenderer(this._renderer); @@ -31,8 +31,8 @@ export class WebglAddon implements ITerminalAddon { if (!this._terminal) { throw new Error('Cannot dispose WebglAddon because it is activated'); } - const renderService: IRenderService = (this._terminal)._core._renderService; - renderService.setRenderer((this._terminal)._core._createRenderer()); + const renderService: IRenderService = (this._terminal as any)._core._renderService; + renderService.setRenderer((this._terminal as any)._core._createRenderer()); renderService.onResize(this._terminal.cols, this._terminal.rows); this._renderer = undefined; } diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 5ce71bb3..6ae52c4c 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -49,7 +49,7 @@ export class WebglRenderer extends Disposable implements IRenderer { ) { super(); - this._core = (this._terminal)._core; + this._core = (this._terminal as any)._core; this._renderLayers = [ new LinkRenderLayer(this._core.screenElement, 2, this._colors, this._core), @@ -226,7 +226,7 @@ export class WebglRenderer extends Disposable implements IRenderer { public renderRows(start: number, end: number): void { if (!this._isAttached) { - if (document.body.contains(this._core.screenElement) && (this._core)._charSizeService.width && (this._core)._charSizeService.height) { + if (document.body.contains(this._core.screenElement) && (this._core as any)._charSizeService.width && (this._core as any)._charSizeService.height) { this._updateDimensions(); this._refreshCharAtlas(); this._isAttached = true; @@ -329,7 +329,7 @@ export class WebglRenderer extends Disposable implements IRenderer { // TODO: Acquire CharSizeService properly // Perform a new measure if the CharMeasure dimensions are not yet available - if (!(this._core)._charSizeService.width || !(this._core)._charSizeService.height) { + if (!(this._core as any)._charSizeService.width || !(this._core as any)._charSizeService.height) { return; } @@ -340,12 +340,12 @@ export class WebglRenderer extends Disposable implements IRenderer { // NOTE: ceil fixes sometime, floor does others :s - this.dimensions.scaledCharWidth = Math.floor((this._core)._charSizeService.width * this._devicePixelRatio); + this.dimensions.scaledCharWidth = Math.floor((this._core as any)._charSizeService.width * this._devicePixelRatio); // Calculate the scaled character height. Height is ceiled in case // devicePixelRatio is a floating point number in order to ensure there is // enough space to draw the character to the cell. - this.dimensions.scaledCharHeight = Math.ceil((this._core)._charSizeService.height * this._devicePixelRatio); + this.dimensions.scaledCharHeight = Math.ceil((this._core as any)._charSizeService.height * this._devicePixelRatio); // Calculate the scaled cell height, if lineHeight is not 1 then the value // will be floored because since lineHeight can never be lower then 1, there diff --git a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts index c9276f7a..93f84492 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts @@ -74,7 +74,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { const oldCanvas = this._canvas; this._alpha = alpha; // Cloning preserves properties - this._canvas = this._canvas.cloneNode(); + this._canvas = this._canvas.cloneNode() as HTMLCanvasElement; this._initCanvas(); this._container.replaceChild(this._canvas, oldCanvas); diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index e4cdb306..595aa1a5 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -93,7 +93,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { const oldCanvas = this._canvas; this._alpha = alpha; // Cloning preserves properties - this._canvas = this._canvas.cloneNode(); + this._canvas = this._canvas.cloneNode() as HTMLCanvasElement; this._initCanvas(); this._container.replaceChild(this._canvas, oldCanvas); diff --git a/src/common/services/InstantiationService.ts b/src/common/services/InstantiationService.ts index ade3bbe3..dd011d98 100644 --- a/src/common/services/InstantiationService.ts +++ b/src/common/services/InstantiationService.ts @@ -56,7 +56,7 @@ export class InstantiationService implements IInstantiationService { return this._services.get(id); } - public createInstance(ctor: any, ...args: any[]): any { + public createInstance(ctor: any, ...args: any[]): T { const serviceDependencies = getServiceDependencies(ctor).sort((a, b) => a.index - b.index); const serviceArgs: any[] = []; @@ -76,6 +76,6 @@ export class InstantiationService implements IInstantiationService { } // now create the instance - return new ctor(...[...args, ...serviceArgs]); + return new ctor(...[...args, ...serviceArgs]); } } diff --git a/src/common/services/ServiceRegistry.ts b/src/common/services/ServiceRegistry.ts index 450af492..6510fb8e 100644 --- a/src/common/services/ServiceRegistry.ts +++ b/src/common/services/ServiceRegistry.ts @@ -25,7 +25,7 @@ export function createDecorator(id: string): IServiceIdentifier { return serviceRegistry.get(id)!; } - const decorator = function (target: Function, key: string, index: number): any { + const decorator: any = function (target: Function, key: string, index: number): any { if (arguments.length !== 3) { throw new Error('@IServiceName-decorator can only be used to decorate a parameter'); }