Skip to content

Commit 8ab3107

Browse files
committed
Add codelyzer l-lin#983
1 parent e13e627 commit 8ab3107

25 files changed

+72
-49
lines changed

demo/src/app/advanced/dt-instance-snippet.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'dt-instance-snippet',
4+
selector: 'app-dt-instance-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>

demo/src/app/advanced/dt-instance.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h4 class="header">Preview</h4>
3333
</blockquote>
3434
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
3535
</div>
36-
<dt-instance-snippet></dt-instance-snippet>
36+
<app-dt-instance-snippet></app-dt-instance-snippet>
3737
</div>
3838
</div>
3939
</div>

demo/src/app/advanced/dt-instance.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
33
import { DataTableDirective } from 'angular-datatables';
44

55
@Component({
6-
selector: 'dt-instance',
6+
selector: 'app-dt-instance',
77
templateUrl: 'dt-instance.component.html'
88
})
99
export class DtInstanceComponent implements OnInit {

demo/src/app/advanced/load-dt-options-with-promise-snippet.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'load-dt-options-with-promise-snippet',
4+
selector: 'app-load-dt-options-with-promise-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>
@@ -78,5 +78,6 @@ export class LoadDtOptionsWithPromiseComponent implements OnInit {
7878
}
7979
]
8080
}</code>
81-
</pre>`
81+
</pre>
82+
`;
8283
}

demo/src/app/advanced/load-dt-options-with-promise.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="header center-on-small-only">Load DataTables options with promise</h1
2626
<h4 class="header">Preview</h4>
2727
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
2828
</div>
29-
<load-dt-options-with-promise-snippet></load-dt-options-with-promise-snippet>
29+
<app-load-dt-options-with-promise-snippet></app-load-dt-options-with-promise-snippet>
3030
</div>
3131
</div>
3232
</div>

demo/src/app/advanced/load-dt-options-with-promise.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Http } from '@angular/http';
44
import 'rxjs/add/operator/toPromise';
55

66
@Component({
7-
selector: 'load-dt-options-with-promise',
7+
selector: 'app-load-dt-options-with-promise',
88
templateUrl: 'load-dt-options-with-promise.component.html'
99
})
1010
export class LoadDtOptionsWithPromiseComponent implements OnInit {

demo/src/app/advanced/row-click-event-snippet.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'row-click-event-snippet',
4+
selector: 'app-row-click-event-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>

demo/src/app/advanced/row-click-event.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h4 class="header">Preview</h4>
2828
<br />
2929
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
3030
</div>
31-
<row-click-event-snippet></row-click-event-snippet>
31+
<ap-row-click-event-snippet></app-row-click-event-snippet>
3232
</div>
3333
</div>
3434
</div>

demo/src/app/advanced/row-click-event.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Component, NgZone, OnInit } from '@angular/core';
33
declare var $: any;
44

55
@Component({
6-
selector: 'row-click-event',
6+
selector: 'app-row-click-event',
77
templateUrl: 'row-click-event.component.html'
88
})
99
export class RowClickEventComponent implements OnInit {
10-
message: string = '';
10+
message = '';
1111
dtOptions: any = {};
1212

1313
constructor(private zone: NgZone) { }
@@ -30,7 +30,7 @@ export class RowClickEventComponent implements OnInit {
3030
data: 'lastName'
3131
}],
3232
rowCallback: (nRow: number, aData: any, iDisplayIndex: number, iDisplayIndexFull: number) => {
33-
let self = this;
33+
const self = this;
3434
// Unbind first in order to avoid any duplicate handler
3535
// (see https://github.com/l-lin/angular-datatables/issues/87)
3636
$('td', nRow).unbind('click');

demo/src/app/app.component.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ describe('AppComponent', () => {
1313
});
1414

1515
it('should create the app', async(() => {
16-
let fixture = TestBed.createComponent(AppComponent);
17-
let app = fixture.debugElement.componentInstance;
16+
const fixture = TestBed.createComponent(AppComponent);
17+
const app = fixture.debugElement.componentInstance;
1818
expect(app).toBeTruthy();
1919
}));
2020

2121
it(`should have as title 'app works!'`, async(() => {
22-
let fixture = TestBed.createComponent(AppComponent);
23-
let app = fixture.debugElement.componentInstance;
22+
const fixture = TestBed.createComponent(AppComponent);
23+
const app = fixture.debugElement.componentInstance;
2424
expect(app.title).toEqual('app works!');
2525
}));
2626

2727
it('should render title in a h1 tag', async(() => {
28-
let fixture = TestBed.createComponent(AppComponent);
28+
const fixture = TestBed.createComponent(AppComponent);
2929
fixture.detectChanges();
30-
let compiled = fixture.debugElement.nativeElement;
30+
const compiled = fixture.debugElement.nativeElement;
3131
expect(compiled.querySelector('h1').textContent).toContain('app works!');
3232
}));
3333
});

demo/src/app/app.module.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ import { WelcomeComponent } from './welcome.component';
1616
import { GettingStartedComponent } from './getting-started.component';
1717

1818
// Basic examples
19-
import { ZeroConfigComponent } from './basic/zero-config.component';
20-
import { ZeroConfigSnippetComponent } from './basic/zero-config-snippet.component';
21-
import { WithOptionsComponent } from './basic/with-options.component';
22-
import { WithOptionsSnippetComponent } from './basic/with-options-snippet.component';
23-
import { WithAjaxComponent } from './basic/with-ajax.component';
24-
import { WithAjaxSnippetComponent } from './basic/with-ajax-snippet.component';
19+
import { ZeroConfigComponent } from './basic/zero-config.component';
20+
import { ZeroConfigSnippetComponent } from './basic/zero-config-snippet.component';
21+
import { WithOptionsComponent } from './basic/with-options.component';
22+
import { WithOptionsSnippetComponent } from './basic/with-options-snippet.component';
23+
import { WithAjaxComponent } from './basic/with-ajax.component';
24+
import { WithAjaxSnippetComponent } from './basic/with-ajax-snippet.component';
2525

2626
// Advanced examples
27-
import { DtInstanceComponent } from './advanced/dt-instance.component';
28-
import { DtInstanceSnippetComponent } from './advanced/dt-instance-snippet.component';
27+
import {  DtInstanceComponent } from './advanced/dt-instance.component';
28+
import {  DtInstanceSnippetComponent } from './advanced/dt-instance-snippet.component';
2929
import { LoadDtOptionsWithPromiseComponent } from './advanced/load-dt-options-with-promise.component';
3030
import { LoadDtOptionsWithPromiseSnippetComponent } from './advanced/load-dt-options-with-promise-snippet.component';
3131
import { RowClickEventComponent } from './advanced/row-click-event.component';
@@ -45,7 +45,7 @@ import { RowClickEventSnippetComponent } from './advanced/row-click-event-snippe
4545
WithAjaxSnippetComponent,
4646

4747
DtInstanceComponent,
48-
  DtInstanceSnippetComponent,
48+
DtInstanceSnippetComponent,
4949
LoadDtOptionsWithPromiseComponent,
5050
LoadDtOptionsWithPromiseSnippetComponent,
5151
RowClickEventComponent,
@@ -63,6 +63,6 @@ import { RowClickEventSnippetComponent } from './advanced/row-click-event-snippe
6363
providers: [
6464
HighlightJsService
6565
],
66-
bootstrap: [ AppComponent ]
66+
bootstrap: [AppComponent]
6767
})
68-
export class AppModule {}
68+
export class AppModule { }

demo/src/app/basic/with-ajax-snippet.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'with-ajax-snippet',
4+
selector: 'app-with-ajax-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>

demo/src/app/basic/with-ajax.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="header center-on-small-only">With ajax</h1>
2626
<h4 class="header">Preview</h4>
2727
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
2828
</div>
29-
<with-ajax-snippet></with-ajax-snippet>
29+
<app-with-ajax-snippet></app-with-ajax-snippet>
3030
</div>
3131

3232
</div>

demo/src/app/basic/with-ajax.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22

33
@Component({
4-
selector: 'with-ajax',
4+
selector: 'app-with-ajax',
55
templateUrl: 'with-ajax.component.html'
66
})
77
export class WithAjaxComponent implements OnInit {

demo/src/app/basic/with-options-snippet.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'with-options-snippet',
4+
selector: 'app-with-options-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>

demo/src/app/basic/with-options.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h4 class="header">Preview</h4>
9595
</tbody>
9696
</table>
9797
</div>
98-
<with-options-snippet></with-options-snippet>
98+
<app-with-options-snippet></app-with-options-snippet>
9999
</div>
100100
</div>
101101
</div>

demo/src/app/basic/with-options.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22

33
@Component({
4-
selector: 'with-options',
4+
selector: 'app-with-options',
55
templateUrl: 'with-options.component.html'
66
})
77
export class WithOptionsComponent implements OnInit {

demo/src/app/basic/zero-config-snippet.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'zero-config-snippet',
4+
selector: 'app-zero-config-snippet',
55
template: `
66
<div id="html" class="col s12 m9 l12">
77
<h4 class="header">HTML</h4>

demo/src/app/basic/zero-config.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h4 class="header">Preview</h4>
9595
</tbody>
9696
</table>
9797
</div>
98-
<zero-config-snippet></zero-config-snippet>
98+
<app-zero-config-snippet></app-zero-config-snippet>
9999
</div>
100100
</div>
101101
</div>

demo/src/app/basic/zero-config.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'zero-config',
4+
selector: 'app-zero-config',
55
templateUrl: 'zero-config.component.html'
66
})
77
export class ZeroConfigComponent {

demo/src/app/getting-started.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'getting-started',
4+
selector: 'app-getting-started',
55
templateUrl: 'getting-started.component.html'
66
})
77
export class GettingStartedComponent {

demo/src/app/welcome.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'welcome',
4+
selector: 'app-welcome',
55
templateUrl: 'welcome.component.html',
66
styleUrls: ['./welcome.component.css']
77
})

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@types/jasmine": "2.5.40",
4848
"@types/node": "~6.0.46",
4949
"canonical-path": "0.0.2",
50+
"codelyzer": "~2.0.1",
5051
"concat-cli": "4.0.0",
5152
"concurrently": "~2.2.0",
5253
"http-server": "~0.9.0",
@@ -61,7 +62,7 @@
6162
"rollup": "~0.41.4",
6263
"rollup-plugin-uglify": "~1.0.1",
6364
"systemjs": "0.19.41",
64-
"tslint": "~3.7.4",
65+
"tslint": "~4.5.1",
6566
"typescript": "~2.0.10"
6667
},
6768
"engines": {

src/angular-datatables.directive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* found in the LICENSE file at https://raw.githubusercontent.com/l-lin/angular-datatables/master/LICENSE
66
*/
77

8-
import { Directive, ElementRef, Inject, OnInit, Input } from '@angular/core';
8+
import { Directive, ElementRef, Inject, OnInit, Input, Component } from '@angular/core';
99
import 'jquery';
1010
import 'datatables.net';
1111
declare var $: any;
@@ -35,7 +35,7 @@ export class DataTableDirective implements OnInit {
3535
ngOnInit() {
3636
this.dtInstance = new Promise((resolve, reject) => {
3737
Promise.resolve(this.dtOptions).then(dtOptions => {
38-
let dt = $(this.el.nativeElement).DataTable(dtOptions);
38+
const dt = $(this.el.nativeElement).DataTable(dtOptions);
3939
resolve(dt);
4040
});
4141
});

tslint.json

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2+
"rulesDirectory": [
3+
"node_modules/codelyzer"
4+
],
25
"rules": {
6+
"callable-types": true,
37
"class-name": true,
48
"comment-format": [
59
true,
@@ -8,12 +12,14 @@
812
"curly": true,
913
"eofline": true,
1014
"forin": true,
15+
"import-blacklist": [true, "rxjs"],
16+
"import-spacing": true,
1117
"indent": [
1218
true,
1319
"spaces"
1420
],
21+
"interface-over-type-literal": true,
1522
"label-position": true,
16-
"label-undefined": true,
1723
"max-line-length": [
1824
true,
1925
140
@@ -36,18 +42,17 @@
3642
],
3743
"no-construct": true,
3844
"no-debugger": true,
39-
"no-duplicate-key": true,
4045
"no-duplicate-variable": true,
4146
"no-empty": false,
47+
"no-empty-interface": true,
4248
"no-eval": true,
43-
"no-inferrable-types": true,
49+
"no-inferrable-types": [true, "ignore-params"],
4450
"no-shadowed-variable": true,
4551
"no-string-literal": false,
52+
"no-string-throw": true,
4653
"no-switch-case-fall-through": true,
4754
"no-trailing-whitespace": true,
4855
"no-unused-expression": true,
49-
"no-unused-variable": true,
50-
"no-unreachable": true,
5156
"no-use-before-declare": true,
5257
"no-var-keyword": true,
5358
"object-literal-sort-keys": false,
@@ -58,6 +63,7 @@
5863
"check-else",
5964
"check-whitespace"
6065
],
66+
"prefer-const": true,
6167
"quotemark": [
6268
true,
6369
"single"
@@ -80,6 +86,8 @@
8086
"variable-declaration": "nospace"
8187
}
8288
],
89+
"typeof-compare": true,
90+
"unified-signatures": true,
8391
"variable-name": false,
8492
"whitespace": [
8593
true,
@@ -89,6 +97,19 @@
8997
"check-separator",
9098
"check-type"
9199
],
92-
"no-unused-variable": [false]
100+
101+
"component-selector": [true, "element", "app", "kebab-case"],
102+
"use-input-property-decorator": true,
103+
"use-output-property-decorator": true,
104+
"use-host-property-decorator": true,
105+
"no-input-rename": true,
106+
"no-output-rename": true,
107+
"use-life-cycle-interface": true,
108+
"use-pipe-transform-interface": true,
109+
"component-class-suffix": true,
110+
"directive-class-suffix": true,
111+
"no-access-missing-member": true,
112+
"templates-use-public": true,
113+
"invoke-injectable": true
93114
}
94115
}

0 commit comments

Comments
 (0)