Skip to content

Commit 163ac19

Browse files
committed
Add lint to build process and fixed lint problems
1 parent 3453c33 commit 163ac19

20 files changed

+318
-176
lines changed

lib/components/adhoc-component-factory.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class AdHocComponentFactoryCreator {
99
}
1010

1111
getFactory(component: any): ComponentFactory<any> {
12-
let factory = this.factories.find(factory => factory.componentType === component);
12+
let factory = this.factories.find(f => f.componentType === component);
1313
if (!factory) {
1414
factory = this._createAdHocComponentFactory(component);
1515
}
@@ -24,8 +24,8 @@ export class AdHocComponentFactoryCreator {
2424
})
2525
class AdHocModule {}
2626
let factory = this.compiler.compileModuleAndAllComponentsSync(AdHocModule).componentFactories
27-
.find(factory => factory.componentType === component);
27+
.find(f => f.componentType === component);
2828
this.factories.push(factory);
2929
return factory;
3030
}
31-
}
31+
}

lib/components/deprecated-loading.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewContainerRef, ComponentFactoryResolver, Input, ComponentFactory, TemplateRef, AfterViewInit } from '@angular/core'
1+
import { Component, ViewContainerRef, ComponentFactoryResolver, Input, ComponentFactory, TemplateRef, AfterViewInit } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { TreeModel } from '../models/tree.model';
44
import { AdHocComponentFactoryCreator } from './adhoc-component-factory.service';
@@ -24,10 +24,10 @@ export class LoadingComponent implements AfterViewInit {
2424
let componentFactory;
2525
try {
2626
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.treeModel.loadingComponent);
27-
} catch(error) {
27+
} catch (error) {
2828
componentFactory = this.adHocComponentFactoryCreator.getFactory(this.treeModel.loadingComponent);
2929
}
3030
let componentRef = this.viewContainerRef.createComponent(componentFactory);
3131
componentRef.changeDetectorRef.detectChanges();
3232
}
33-
}
33+
}

lib/components/deprecated-tree-node-content.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Component, Input, ComponentFactoryResolver, ComponentFactory, ComponentRef, AfterViewInit, ViewContainerRef, TemplateRef } from '@angular/core';
1+
import {
2+
Component, Input, ComponentFactoryResolver, ComponentFactory, ComponentRef, AfterViewInit,
3+
ViewContainerRef, TemplateRef
4+
} from '@angular/core';
25
import { CommonModule } from '@angular/common';
36
import { TreeNode } from '../models/tree-node.model';
47
import { TreeModel } from '../models/tree.model';
@@ -33,7 +36,7 @@ export class TreeNodeContent implements AfterViewInit {
3336
let componentFactory;
3437
try {
3538
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.treeModel.treeNodeContentComponent);
36-
} catch(error) {
39+
} catch (error) {
3740
componentFactory = this.adHocComponentFactoryCreator.getFactory(this.treeModel.treeNodeContentComponent);
3841
}
3942
let componentRef: ComponentRef<ITreeNodeTemplate>
@@ -43,4 +46,4 @@ export class TreeNodeContent implements AfterViewInit {
4346

4447
componentRef.changeDetectorRef.detectChanges();
4548
}
46-
}
49+
}

lib/components/loading.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, TemplateRef } from '@angular/core'
1+
import { Component, Input, TemplateRef } from '@angular/core';
22
import { TreeModel } from '../models/tree.model';
33

44
@Component({

lib/components/tree-node-children.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ import { TreeNode } from '../models/tree-node.model';
3030
`
3131
})
3232
export class TreeNodeChildrenComponent {
33-
@Input() node:TreeNode;
33+
@Input() node: TreeNode;
3434
@Input() templates: any;
3535
}

lib/components/tree-node-expander.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TreeNode } from '../models/tree-node.model';
1010
`.toggle-children-wrapper {
1111
padding: 2px 3px 5px 1px;
1212
}`,
13+
/* tslint:disable */
1314
`.toggle-children {
1415
background-image: url(\'data:image/png;base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E1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MTk5NzA1OGEtZDI3OC00NDZkLWE4ODgtNGM4MGQ4YWI1NzNmIiBzdFJlZjpkb2N1bWVudElEPSJhZG9iZTpkb2NpZDpwaG90b3Nob3A6YzRkZmQxMGMtY2NlNS0xMTc4LWE5OGQtY2NkZmM5ODk5YWYwIi8+IDxkYzp0aXRsZT4gPHJkZjpBbHQ+IDxyZGY6bGkgeG1sOmxhbmc9IngtZGVmYXVsdCI+Z2x5cGhpY29uczwvcmRmOmxpPiA8L3JkZjpBbHQ+IDwvZGM6dGl0bGU+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+5iogFwAAAGhJREFUeNpiYGBgKABigf///zOQg0EARH4A4gZyDIIZ8B/JoAJKDIDhB0CcQIkBRBtEyABkgxwoMQCGD6AbRKoBGAYxQgXIBRuZGKgAKPIC3QLxArnRSHZCIjspk52ZKMrOFBUoAAEGAKnq593MQAZtAAAAAElFTkSuQmCC\');
1516
height: 8px;
@@ -21,6 +22,7 @@ import { TreeNode } from '../models/tree-node.model';
2122
background-repeat: no-repeat;
2223
background-position: center;
2324
}`,
25+
/* tslint:enable */
2426
`.toggle-children-placeholder {
2527
display: inline-block;
2628
height: 10px;
@@ -47,7 +49,7 @@ import { TreeNode } from '../models/tree-node.model';
4749
`
4850
})
4951
export class TreeNodeExpanderComponent {
50-
@Input() node:TreeNode;
52+
@Input() node: TreeNode;
5153

5254
constructor() {
5355
}

lib/components/tree-node.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import { TreeNode } from '../models/tree-node.model';
1616
'.tree-node-active.tree-node-focused > .node-wrapper > .node-content-wrapper { background: #beebff }',
1717
'.tree-node-focused > .node-wrapper > .node-content-wrapper { background: #e7f4f9 }',
1818
'.node-content-wrapper:hover { background: #f7fbff }',
19-
'.tree-node-active > .node-wrapper > .node-content-wrapper, .tree-node-focused > .node-content-wrapper, .node-content-wrapper:hover { box-shadow: inset 0 0 1px #999; }',
19+
`.tree-node-active > .node-wrapper > .node-content-wrapper, .tree-node-focused > .node-content-wrapper, .node-content-wrapper:hover {
20+
box-shadow: inset 0 0 1px #999;
21+
}`,
2022
'.node-content-wrapper.is-dragging-over { background: #ddffee; box-shadow: inset 0 0 1px #999; }',
2123
'.node-content-wrapper.is-dragging-over-disabled { opacity: 0.5 }'
2224
],
@@ -59,8 +61,8 @@ import { TreeNode } from '../models/tree-node.model';
5961
})
6062

6163
export class TreeNodeComponent implements AfterViewInit {
62-
@Input() node:TreeNode;
63-
@Input() index:number;
64+
@Input() node: TreeNode;
65+
@Input() index: number;
6466
@Input() templates: any;
6567

6668
constructor(private elementRef: ElementRef) {

lib/components/tree.component.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import { Component, Input, Output, OnChanges, SimpleChange, EventEmitter, ViewEncapsulation, ContentChild, TemplateRef } from '@angular/core';
1+
import {
2+
Component, Input, Output, OnChanges, SimpleChange, EventEmitter,
3+
ViewEncapsulation, ContentChild, TemplateRef, HostListener
4+
} from '@angular/core';
25
import { TreeModel } from '../models/tree.model';
36
import { TreeDraggedElement } from '../models/tree-dragged-element.model';
47
import { TreeOptions } from '../models/tree-options.model';
58
import { KEYS } from '../constants/keys';
69

7-
import * as _ from 'lodash'
10+
import * as _ from 'lodash';
811

912
@Component({
1013
selector: 'Tree',
1114
encapsulation: ViewEncapsulation.None,
12-
host: {
13-
'(body: keydown)': "onKeydown($event)",
14-
'(body: mousedown)': "onMousedown($event)"
15-
},
1615
providers: [TreeModel],
1716
styles: [
1817
'.tree-children { padding-left: 20px }',
@@ -50,22 +49,18 @@ import * as _ from 'lodash'
5049
`
5150
})
5251
export class TreeComponent implements OnChanges {
53-
constructor(public treeModel:TreeModel, public treeDraggedElement:TreeDraggedElement) {
54-
treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
55-
}
56-
57-
_nodes:any[];
58-
_options:TreeOptions;
52+
_nodes: any[];
53+
_options: TreeOptions;
5954

6055
@ContentChild('loadingTemplate') loadingTemplate: TemplateRef<any>;
6156
@ContentChild('treeNodeTemplate') treeNodeTemplate: TemplateRef<any>;
6257
@ContentChild('treeNodeFullTemplate') treeNodeFullTemplate: TemplateRef<any>;
6358

6459
// Will be handled in ngOnChanges
65-
@Input() set nodes(nodes:any[]) { };
66-
@Input() set options(options:TreeOptions) { };
60+
@Input() set nodes(nodes: any[]) { };
61+
@Input() set options(options: TreeOptions) { };
6762

68-
@Input() set focused(value:boolean) {
63+
@Input() set focused(value: boolean) {
6964
this.treeModel.setFocus(value);
7065
}
7166

@@ -83,6 +78,11 @@ export class TreeComponent implements OnChanges {
8378
@Output() onMoveNode;
8479
@Output() onEvent;
8580

81+
constructor(public treeModel: TreeModel, public treeDraggedElement: TreeDraggedElement) {
82+
treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
83+
}
84+
85+
@HostListener('body: keydown', ['$event'])
8686
onKeydown($event) {
8787
if (!this.treeModel.isFocused) return;
8888
if (_.includes(['input', 'textarea'],
@@ -93,6 +93,7 @@ export class TreeComponent implements OnChanges {
9393
this.treeModel.performKeyAction(focusedNode, $event);
9494
}
9595

96+
@HostListener('body: mousedown', ['$event'])
9697
onMousedown($event) {
9798
let insideClick = $event.target.closest('Tree');
9899
if (!insideClick) {

lib/constants/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export const TREE_EVENTS = {
1212
onUpdateData: 'onUpdateData',
1313
onMoveNode: 'onMoveNode',
1414
onEvent: 'onEvent'
15-
}
15+
};

lib/constants/keys.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export const KEYS = {
1+
export const KEYS = {
22
LEFT: 37,
33
UP: 38,
44
RIGHT: 39,
55
DOWN: 40,
66
ENTER: 13,
77
SPACE: 32
8-
}
8+
};

0 commit comments

Comments
 (0)