aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-04-08 20:58:07 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-04-08 21:03:47 +0200
commit44124980c55d5a5ec7dfb8e71bf14d10f0fe975d (patch)
tree795191ff37d862a4bcf9cbc57cdb60b909b038d1
parent0dde91ff15ec3cb73d39da50b388e5e525160cb4 (diff)
downloadPeerTube-44124980c55d5a5ec7dfb8e71bf14d10f0fe975d.tar.gz
PeerTube-44124980c55d5a5ec7dfb8e71bf14d10f0fe975d.tar.zst
PeerTube-44124980c55d5a5ec7dfb8e71bf14d10f0fe975d.zip
Add typescript (and angular2) linter
-rw-r--r--client/angular/app/app.component.ts11
-rw-r--r--client/angular/friends/services/friends.service.ts6
-rw-r--r--client/angular/users/services/auth.service.ts7
-rw-r--r--client/angular/videos/components/add/videos-add.component.ts5
-rw-r--r--client/angular/videos/components/list/videos-list.component.ts4
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.ts4
-rw-r--r--client/package.json5
-rw-r--r--client/tslint.json46
-rw-r--r--package.json2
9 files changed, 69 insertions, 21 deletions
diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts
index 1648b8870..68c9ba009 100644
--- a/client/angular/app/app.component.ts
+++ b/client/angular/app/app.component.ts
@@ -53,8 +53,11 @@ export class AppComponent {
53 private _authService: AuthService, 53 private _authService: AuthService,
54 private _router: Router 54 private _router: Router
55 ) { 55 ) {
56 if (localStorage.getItem('access_token')) this.isLoggedIn = true; 56 if (localStorage.getItem('access_token')) {
57 else this.isLoggedIn = false; 57 this.isLoggedIn = true;
58 } else {
59 this.isLoggedIn = false;
60 }
58 61
59 this._authService.loginChanged$.subscribe( 62 this._authService.loginChanged$.subscribe(
60 status => { 63 status => {
@@ -87,7 +90,7 @@ export class AppComponent {
87 } 90 }
88 }, 91 },
89 error => alert(error) 92 error => alert(error)
90 ) 93 );
91 } 94 }
92 95
93 quitFriends() { 96 quitFriends() {
@@ -96,6 +99,6 @@ export class AppComponent {
96 alert('Quit friends!'); 99 alert('Quit friends!');
97 }, 100 },
98 error => alert(error) 101 error => alert(error)
99 ) 102 );
100 } 103 }
101} 104}
diff --git a/client/angular/friends/services/friends.service.ts b/client/angular/friends/services/friends.service.ts
index a34ef0d6f..4eb1fc67b 100644
--- a/client/angular/friends/services/friends.service.ts
+++ b/client/angular/friends/services/friends.service.ts
@@ -1,6 +1,6 @@
1import {Injectable} from 'angular2/core'; 1import { Injectable } from 'angular2/core';
2import {Http, Response, Headers, RequestOptions} from 'angular2/http'; 2import { Http, Response } from 'angular2/http';
3import {Observable} from 'rxjs/Rx'; 3import { Observable } from 'rxjs/Rx';
4 4
5@Injectable() 5@Injectable()
6export class FriendsService { 6export class FriendsService {
diff --git a/client/angular/users/services/auth.service.ts b/client/angular/users/services/auth.service.ts
index a512c3d9c..80886346c 100644
--- a/client/angular/users/services/auth.service.ts
+++ b/client/angular/users/services/auth.service.ts
@@ -2,19 +2,18 @@ import { Injectable } from 'angular2/core';
2import { Http, Response, Headers, URLSearchParams } from 'angular2/http'; 2import { Http, Response, Headers, URLSearchParams } from 'angular2/http';
3import { Observable, Subject } from 'rxjs/Rx'; 3import { Observable, Subject } from 'rxjs/Rx';
4 4
5import { Token } from '../models/token';
6import { AuthStatus } from '../models/authStatus'; 5import { AuthStatus } from '../models/authStatus';
7 6
8@Injectable() 7@Injectable()
9export class AuthService { 8export class AuthService {
9 loginChanged$ = this._loginChanged.asObservable();
10
10 private _loginChanged = new Subject<AuthStatus>(); 11 private _loginChanged = new Subject<AuthStatus>();
11 12
12 private _baseLoginUrl = '/api/v1/users/token'; 13 private _baseLoginUrl = '/api/v1/users/token';
13 private _clientId = '56f055587305d40b21904240'; 14 private _clientId = '56f055587305d40b21904240';
14 private _clientSecret = 'megustalabanana'; 15 private _clientSecret = 'megustalabanana';
15 16
16 loginChanged$ = this._loginChanged.asObservable();
17
18 constructor (private http: Http) {} 17 constructor (private http: Http) {}
19 18
20 login(username: string, password: string) { 19 login(username: string, password: string) {
@@ -32,7 +31,7 @@ export class AuthService {
32 31
33 let options = { 32 let options = {
34 headers: headers 33 headers: headers
35 } 34 };
36 35
37 return this.http.post(this._baseLoginUrl, body.toString(), options) 36 return this.http.post(this._baseLoginUrl, body.toString(), options)
38 .map(res => res.json()) 37 .map(res => res.json())
diff --git a/client/angular/videos/components/add/videos-add.component.ts b/client/angular/videos/components/add/videos-add.component.ts
index 0004cfa20..7ae11db22 100644
--- a/client/angular/videos/components/add/videos-add.component.ts
+++ b/client/angular/videos/components/add/videos-add.component.ts
@@ -1,8 +1,5 @@
1import { Component, ElementRef, Inject, OnInit } from 'angular2/core'; 1import { Component, ElementRef, OnInit } from 'angular2/core';
2import { Router } from 'angular2/router'; 2import { Router } from 'angular2/router';
3import { NgForm } from 'angular2/common';
4
5import { Video } from '../../models/video';
6 3
7// TODO: import it with systemjs 4// TODO: import it with systemjs
8declare var jQuery:any; 5declare var jQuery:any;
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts
index eb23ed1ff..ae58f4d7e 100644
--- a/client/angular/videos/components/list/videos-list.component.ts
+++ b/client/angular/videos/components/list/videos-list.component.ts
@@ -33,7 +33,7 @@ export class VideosListComponent implements OnInit {
33 if (this.search !== null) { 33 if (this.search !== null) {
34 observable = this._videosService.searchVideos(this.search); 34 observable = this._videosService.searchVideos(this.search);
35 } else { 35 } else {
36 observable = this._videosService.getVideos() 36 observable = this._videosService.getVideos();
37 } 37 }
38 38
39 observable.subscribe( 39 observable.subscribe(
@@ -46,7 +46,7 @@ export class VideosListComponent implements OnInit {
46 this._videosService.removeVideo(id).subscribe( 46 this._videosService.removeVideo(id).subscribe(
47 status => this.getVideos(), 47 status => this.getVideos(),
48 error => alert(error) 48 error => alert(error)
49 ) 49 );
50 } 50 }
51 51
52} 52}
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts
index 1a17e2b1a..28786ebb9 100644
--- a/client/angular/videos/components/watch/videos-watch.component.ts
+++ b/client/angular/videos/components/watch/videos-watch.component.ts
@@ -47,8 +47,8 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
47 alert('Cannot append the file.'); 47 alert('Cannot append the file.');
48 console.error(err); 48 console.error(err);
49 } 49 }
50 }) 50 });
51 }) 51 });
52 } 52 }
53 53
54 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { 54 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
diff --git a/client/package.json b/client/package.json
index 31c92f8cc..5fd5beca4 100644
--- a/client/package.json
+++ b/client/package.json
@@ -16,7 +16,8 @@
16 "tsc": "tsc", 16 "tsc": "tsc",
17 "tsc:w": "tsc -w", 17 "tsc:w": "tsc -w",
18 "typings": "typings", 18 "typings": "typings",
19 "postinstall": "typings install" 19 "postinstall": "typings install",
20 "test": "tslint -c ./tslint.json angular/**/*.ts angular/**/**/*.ts"
20 }, 21 },
21 "license": "ISC", 22 "license": "ISC",
22 "dependencies": { 23 "dependencies": {
@@ -34,6 +35,8 @@
34 "zone.js": "0.5.15" 35 "zone.js": "0.5.15"
35 }, 36 },
36 "devDependencies": { 37 "devDependencies": {
38 "codelyzer": "0.0.12",
39 "tslint": "^3.7.1",
37 "typescript": "^1.8.2", 40 "typescript": "^1.8.2",
38 "typings": "^0.6.8" 41 "typings": "^0.6.8"
39 } 42 }
diff --git a/client/tslint.json b/client/tslint.json
new file mode 100644
index 000000000..6a40b5b11
--- /dev/null
+++ b/client/tslint.json
@@ -0,0 +1,46 @@
1{
2 "rulesDirectory": ["./node_modules/codelyzer/dist/src"],
3 "rules": {
4 "class-name": true,
5 "curly": false,
6 "eofline": true,
7 "indent": ["spaces"],
8 "max-line-length": [true, 140],
9 "member-ordering": [true,
10 "public-before-private",
11 "static-before-instance",
12 "variables-before-functions"
13 ],
14 "no-arg": true,
15 "no-construct": true,
16 "no-duplicate-key": true,
17 "no-duplicate-variable": true,
18 "no-empty": true,
19 "no-eval": true,
20 "no-trailing-whitespace": true,
21 "no-unused-expression": true,
22 "no-unused-variable": true,
23 "no-unreachable": true,
24 "no-use-before-declare": true,
25 "one-line": [true,
26 "check-open-brace",
27 "check-catch",
28 "check-else",
29 "check-whitespace"
30 ],
31 "quotemark": [true, "single"],
32 "semicolon": true,
33 "trailing-comma": true,
34 "triple-equals": true,
35 "variable-name": false,
36
37 "component-selector-name": [true, "kebab-case"],
38 "component-selector-type": [true, "element"],
39 "host-parameter-decorator": true,
40 "input-parameter-decorator": true,
41 "output-parameter-decorator": true,
42 "attribute-parameter-decorator": true,
43 "input-property-directive": true,
44 "output-property-directive": true
45 }
46}
diff --git a/package.json b/package.json
index 42e79aae2..076cf6fdb 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
34 "dev": "npm run build && NODE_ENV=test concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"", 34 "dev": "npm run build && NODE_ENV=test concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"",
35 "livereload": "livereload ./client", 35 "livereload": "livereload ./client",
36 "start": "node server", 36 "start": "node server",
37 "test": "standard && mocha server/tests", 37 "test": "cd client && npm test && cd .. && standard && mocha server/tests",
38 "postinstall": "cd client && npm install" 38 "postinstall": "cd client && npm install"
39 }, 39 },
40 "dependencies": { 40 "dependencies": {