Add new tslint rules and fix rule breaks

This commit is contained in:
József Farkas
2017-03-18 23:43:32 +01:00
parent 0e8165a0b4
commit ca31e5bb4d
44 changed files with 127 additions and 142 deletions

View File

@@ -141,7 +141,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
constructor(
private mapper: MapperService,
private store: Store<AppState>,
store: Store<AppState>,
private element: ElementRef,
private captureService: CaptureService,
private renderer: Renderer
@@ -215,11 +215,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelType = LabelTypes.OneLineText;
if (this.keyAction instanceof KeystrokeAction) {
let keyAction: KeystrokeAction = this.keyAction as KeystrokeAction;
const keyAction: KeystrokeAction = this.keyAction as KeystrokeAction;
let newLabelSource: string[];
if (!keyAction.hasActiveModifier() && keyAction.hasScancode()) {
let scancode: number = keyAction.scancode;
const scancode: number = keyAction.scancode;
newLabelSource = this.mapper.scanCodeToText(scancode);
if (this.mapper.hasScancodeIcon(scancode)) {
this.labelSource = this.mapper.scanCodeToSvgImagePath(scancode);
@@ -262,7 +262,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelSource = this.keyAction;
}
} else if (this.keyAction instanceof SwitchLayerAction) {
let keyAction: SwitchLayerAction = this.keyAction as SwitchLayerAction;
const keyAction: SwitchLayerAction = this.keyAction as SwitchLayerAction;
let newLabelSource: string;
switch (keyAction.layer) {
case LayerName.mod:
@@ -289,11 +289,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.labelSource = newLabelSource;
}
} else if (this.keyAction instanceof SwitchKeymapAction) {
let keyAction: SwitchKeymapAction = this.keyAction as SwitchKeymapAction;
const keyAction: SwitchKeymapAction = this.keyAction as SwitchKeymapAction;
this.labelType = LabelTypes.SwitchKeymap;
this.labelSource = keyAction.keymapAbbreviation;
} else if (this.keyAction instanceof PlayMacroAction) {
let keyAction: PlayMacroAction = this.keyAction as PlayMacroAction;
const keyAction: PlayMacroAction = this.keyAction as PlayMacroAction;
const macro: Macro = this.macros.find((_macro: Macro) => _macro.id === keyAction.macroId);
this.labelType = LabelTypes.IconText;
this.labelSource = {

View File

@@ -20,10 +20,6 @@ class SvgAttributes {
}
}
enum Modifiers {
Shift, Control, Alt, Command
}
@Component({
selector: 'g[svg-keystroke-key]',
templateUrl: './svg-keystroke-key.component.html',
@@ -68,7 +64,7 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
this.modifierIconNames.option = this.mapper.getIcon('option');
this.modifierIconNames.command = this.mapper.getIcon('command');
let bottomSideMode: boolean = this.width < this.height * 1.8;
const bottomSideMode: boolean = this.width < this.height * 1.8;
const heightWidthRatio = this.height / this.width;
@@ -76,8 +72,8 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
const maxIconWidth = this.width / 4;
const maxIconHeight = this.height;
const iconScalingFactor = 0.8;
let iconWidth = iconScalingFactor * heightWidthRatio * maxIconWidth;
let iconHeight = iconScalingFactor * maxIconHeight;
const iconWidth = iconScalingFactor * heightWidthRatio * maxIconWidth;
const iconHeight = iconScalingFactor * maxIconHeight;
this.modifierContainer.width = this.width;
this.modifierContainer.height = this.height / 5;
this.modifierContainer.y = this.height - this.modifierContainer.height;
@@ -134,7 +130,7 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
ngOnChanges() {
let newLabelSource: string[];
if (this.keystrokeAction.hasScancode()) {
let scancode: number = this.keystrokeAction.scancode;
const scancode: number = this.keystrokeAction.scancode;
newLabelSource = this.mapper.scanCodeToText(scancode);
if (newLabelSource) {
if (newLabelSource.length === 1) {