From 9e863d037742346e6dbe201ab60a10e819c5fd31 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 23 Apr 2018 11:52:42 -0700 Subject: [PATCH] Add no else return tslint rule --- package.json | 1 + src/CompositionHelper.ts | 7 +++---- src/handlers/AltClickHandler.ts | 15 ++++++--------- tslint.json | 9 ++++++++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 49ccc38766..d4a06f826a 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "npm-run-all": "^4.1.2", "sorcery": "^0.10.0", "tslint": "^5.9.1", + "tslint-consistent-codestyle": "^1.13.0", "typescript": "~2.7.1", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", diff --git a/src/CompositionHelper.ts b/src/CompositionHelper.ts index 389cb782be..b721b7f19d 100644 --- a/src/CompositionHelper.ts +++ b/src/CompositionHelper.ts @@ -92,11 +92,10 @@ export class CompositionHelper { } else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) { // Continue composing if the keyCode is a modifier key return false; - } else { - // Finish composition immediately. This is mainly here for the case where enter is - // pressed and the handler needs to be triggered before the command is executed. - this._finalizeComposition(false); } + // Finish composition immediately. This is mainly here for the case where enter is + // pressed and the handler needs to be triggered before the command is executed. + this._finalizeComposition(false); } if (ev.keyCode === 229) { diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index f77637ea17..221a993f6f 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -73,12 +73,11 @@ export class AltClickHandler { private _resetStartingRow(): string { if (this._moveToRequestedRow().length === 0) { return ''; - } else { - return repeat(this._bufferLine( - this._startCol, this._startRow, this._startCol, - this._startRow - this._wrappedRowsForRow(this._startRow), false - ).length, this._sequence(Direction.Left)); } + return repeat(this._bufferLine( + this._startCol, this._startRow, this._startCol, + this._startRow - this._wrappedRowsForRow(this._startRow), false + ).length, this._sequence(Direction.Left)); } /** @@ -180,9 +179,8 @@ export class AltClickHandler { (this._startCol >= this._endCol && startRow < this._endRow)) { // down/left or same y/left return Direction.Right; - } else { - return Direction.Left; } + return Direction.Left; } /** @@ -191,9 +189,8 @@ export class AltClickHandler { private _verticalDirection(): Direction { if (this._startRow > this._endRow) { return Direction.Up; - } else { - return Direction.Down; } + return Direction.Down; } /** diff --git a/tslint.json b/tslint.json index d42fda719b..5cd44ecf89 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,7 @@ { + "rulesDirectory": [ + "tslint-consistent-codestyle" + ], "rules": { "array-type": [ true, @@ -86,6 +89,10 @@ "check-type", "check-type-operator", "check-preblock" - ] + ], + + "no-else-after-return": { + "options": "allow-else-if" + } } }