]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add typescript (and angular2) linter
authorChocobozzz <florian.bigard@gmail.com>
Fri, 8 Apr 2016 18:58:07 +0000 (20:58 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Fri, 8 Apr 2016 19:03:47 +0000 (21:03 +0200)
client/angular/app/app.component.ts
client/angular/friends/services/friends.service.ts
client/angular/users/services/auth.service.ts
client/angular/videos/components/add/videos-add.component.ts
client/angular/videos/components/list/videos-list.component.ts
client/angular/videos/components/watch/videos-watch.component.ts
client/package.json
client/tslint.json [new file with mode: 0644]
package.json

index 1648b887020df7fcaa73cbdca7a5bc264f902e65..68c9ba0090510fd8d9e3c1c3446e74dec5a4283c 100644 (file)
@@ -53,8 +53,11 @@ export class AppComponent {
               private _authService: AuthService,
               private _router: Router
   ) {
-    if (localStorage.getItem('access_token')) this.isLoggedIn = true;
-    else this.isLoggedIn = false;
+    if (localStorage.getItem('access_token')) {
+      this.isLoggedIn = true;
+    } else {
+      this.isLoggedIn = false;
+    }
 
     this._authService.loginChanged$.subscribe(
       status => {
@@ -87,7 +90,7 @@ export class AppComponent {
         }
       },
       error => alert(error)
-    )
+    );
   }
 
   quitFriends() {
@@ -96,6 +99,6 @@ export class AppComponent {
           alert('Quit friends!');
       },
       error => alert(error)
-    )
+    );
   }
 }
index a34ef0d6fb951ae374f3760392974c8558b264bf..4eb1fc67b153f2ca71cd710bb2e8b4e6df43fd33 100644 (file)
@@ -1,6 +1,6 @@
-import {Injectable} from 'angular2/core';
-import {Http, Response, Headers, RequestOptions} from 'angular2/http';
-import {Observable} from 'rxjs/Rx';
+import { Injectable } from 'angular2/core';
+import { Http, Response } from 'angular2/http';
+import { Observable } from 'rxjs/Rx';
 
 @Injectable()
 export class FriendsService {
index a512c3d9cda2697911d9cfd92bd81154526ef1f1..80886346ca529f39d841e084df51184bd09aa24b 100644 (file)
@@ -2,19 +2,18 @@ import { Injectable } from 'angular2/core';
 import { Http, Response, Headers, URLSearchParams } from 'angular2/http';
 import { Observable, Subject } from 'rxjs/Rx';
 
-import { Token } from '../models/token';
 import { AuthStatus } from '../models/authStatus';
 
 @Injectable()
 export class AuthService {
+  loginChanged$ = this._loginChanged.asObservable();
+
   private _loginChanged = new Subject<AuthStatus>();
 
   private _baseLoginUrl = '/api/v1/users/token';
   private _clientId = '56f055587305d40b21904240';
   private _clientSecret = 'megustalabanana';
 
-  loginChanged$ = this._loginChanged.asObservable();
-
   constructor (private http: Http) {}
 
   login(username: string, password: string) {
@@ -32,7 +31,7 @@ export class AuthService {
 
     let options = {
       headers: headers
-    }
+    };
 
     return this.http.post(this._baseLoginUrl, body.toString(), options)
                     .map(res => res.json())
index 0004cfa20f8651471dc3351989e7956be41e530c..7ae11db226db5e5e628172f8391d71a432af1b2b 100644 (file)
@@ -1,8 +1,5 @@
-import { Component, ElementRef, Inject, OnInit } from 'angular2/core';
+import { Component, ElementRef, OnInit } from 'angular2/core';
 import { Router } from 'angular2/router';
-import { NgForm } from 'angular2/common';
-
-import { Video } from '../../models/video';
 
 // TODO: import it with systemjs
 declare var jQuery:any;
index eb23ed1ff61d1a9c72bbe228e7d598ff2e2531b2..ae58f4d7e8abf27a4b1330aac1c8d6ff26c11186 100644 (file)
@@ -33,7 +33,7 @@ export class VideosListComponent implements OnInit {
     if (this.search !== null) {
       observable = this._videosService.searchVideos(this.search);
     } else {
-      observable = this._videosService.getVideos()
+      observable = this._videosService.getVideos();
     }
 
     observable.subscribe(
@@ -46,7 +46,7 @@ export class VideosListComponent implements OnInit {
     this._videosService.removeVideo(id).subscribe(
       status => this.getVideos(),
       error => alert(error)
-    )
+    );
   }
 
 }
index 1a17e2b1ae9a4a8c36c3fcee01e5b1b4147321ab..28786ebb9c129328727eae6e6f14b6b5f4f1445e 100644 (file)
@@ -47,8 +47,8 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
           alert('Cannot append the file.');
           console.error(err);
         }
-      })
-    })
+      });
+    });
   }
 
   routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
index 31c92f8cc2b37cd3a33e3cd017e522d24e4fed73..5fd5beca4686b1e08e6f598a04a6afd5c985b869 100644 (file)
@@ -16,7 +16,8 @@
     "tsc": "tsc",
     "tsc:w": "tsc -w",
     "typings": "typings",
-    "postinstall": "typings install"
+    "postinstall": "typings install",
+    "test": "tslint -c ./tslint.json angular/**/*.ts angular/**/**/*.ts"
   },
   "license": "ISC",
   "dependencies": {
@@ -34,6 +35,8 @@
     "zone.js": "0.5.15"
   },
   "devDependencies": {
+    "codelyzer": "0.0.12",
+    "tslint": "^3.7.1",
     "typescript": "^1.8.2",
     "typings": "^0.6.8"
   }
diff --git a/client/tslint.json b/client/tslint.json
new file mode 100644 (file)
index 0000000..6a40b5b
--- /dev/null
@@ -0,0 +1,46 @@
+{
+  "rulesDirectory": ["./node_modules/codelyzer/dist/src"],
+  "rules": {
+    "class-name": true,
+    "curly": false,
+    "eofline": true,
+    "indent": ["spaces"],
+    "max-line-length": [true, 140],
+    "member-ordering": [true,
+      "public-before-private",
+      "static-before-instance",
+      "variables-before-functions"
+    ],
+    "no-arg": true,
+    "no-construct": true,
+    "no-duplicate-key": true,
+    "no-duplicate-variable": true,
+    "no-empty": true,
+    "no-eval": true,
+    "no-trailing-whitespace": true,
+    "no-unused-expression": true,
+    "no-unused-variable": true,
+    "no-unreachable": true,
+    "no-use-before-declare": true,
+    "one-line": [true,
+      "check-open-brace",
+      "check-catch",
+      "check-else",
+      "check-whitespace"
+    ],
+    "quotemark": [true, "single"],
+    "semicolon": true,
+    "trailing-comma": true,
+    "triple-equals": true,
+    "variable-name": false,
+
+    "component-selector-name": [true, "kebab-case"],
+    "component-selector-type": [true, "element"],
+    "host-parameter-decorator": true,
+    "input-parameter-decorator": true,
+    "output-parameter-decorator": true,
+    "attribute-parameter-decorator": true,
+    "input-property-directive": true,
+    "output-property-directive": true
+  }
+}
index 42e79aae2058395d5bfb296ab924155b751da3d2..076cf6fdba9c0b6252e19894ad93d0f124a58dc4 100644 (file)
@@ -34,7 +34,7 @@
     "dev": "npm run build && NODE_ENV=test concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"",
     "livereload": "livereload ./client",
     "start": "node server",
-    "test": "standard && mocha server/tests",
+    "test": "cd client && npm test && cd .. && standard && mocha server/tests",
     "postinstall": "cd client && npm install"
   },
   "dependencies": {