diff --git a/modules/@angular/router/.clang-format b/modules/@angular/router/.clang-format new file mode 100644 index 0000000000..20d8c48f22 --- /dev/null +++ b/modules/@angular/router/.clang-format @@ -0,0 +1,3 @@ +Language: JavaScript +BasedOnStyle: Google +ColumnLimit: 100 \ No newline at end of file diff --git a/modules/@angular/router/package.json b/modules/@angular/router/package.json index 8e5800ddda..0151d75a5e 100644 --- a/modules/@angular/router/package.json +++ b/modules/@angular/router/package.json @@ -12,7 +12,9 @@ "build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json", "postbuild_npm": "cp package.json README.md dist/ && npm run rewrite_npm_package", "rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js", - "build_bundle": "cp -r src router && tsc typings/index.d.ts src/router.ts --rootDir . --module system -t es5 --outFile dist/bundles/router.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators" + "build_bundle": "cp -r src router && tsc typings/index.d.ts src/router.ts --rootDir . --module system -t es5 --outFile dist/bundles/router.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators", + "lint": "tslint \"src/**/*.ts\"", + "format": "clang-format -style=file -i --glob=src/**/*.ts" }, "keywords": [ "angular2", @@ -62,7 +64,10 @@ "tsd": "^0.6.5", "typescript": "^1.9.0-dev.20160409", "typings": "^1.0.4", - "zone.js": "^0.6.6" + "zone.js": "^0.6.6", + "clang-format": "^1.0.35", + "tslint": "^3.6.0", + "codelyzer": "0.0.14" }, "typings": "build/src/index.d.ts" } diff --git a/modules/@angular/router/src/config.ts b/modules/@angular/router/src/config.ts index 6b7086d811..a7c60d3c00 100644 --- a/modules/@angular/router/src/config.ts +++ b/modules/@angular/router/src/config.ts @@ -7,7 +7,7 @@ export interface Route { path?: string; component: Type | string; outlet?: string; - canActivate?: any[], - canDeactivate?: any[], + canActivate?: any[]; + canDeactivate?: any[]; children?: Route[]; } \ No newline at end of file diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index cf2e820d35..745de2bfeb 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -2,7 +2,7 @@ import { UrlTree, UrlSegment } from './url_tree'; import { flatten, first, merge } from './utils/collection'; import { TreeNode } from './utils/tree'; import { RouterStateSnapshot, ActivatedRouteSnapshot } from './router_state'; -import { Params, PRIMARY_OUTLET } from './shared'; +import { PRIMARY_OUTLET } from './shared'; import { RouterConfig, Route } from './config'; import { Type } from '@angular/core'; import { Observable } from 'rxjs/Observable'; @@ -35,7 +35,7 @@ function constructActivatedRoute(match: MatchResult): TreeNode { if (a.value.outlet === PRIMARY_OUTLET) return -1; if (b.value.outlet === PRIMARY_OUTLET) return 1; - return a.value.outlet.localeCompare(b.value.outlet) + return a.value.outlet.localeCompare(b.value.outlet); }); return [new TreeNode(activatedRoute, children)]; } diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index e31bcb70b8..57a2fbf050 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -63,7 +63,7 @@ export class Router { */ constructor(private rootComponentType:Type, private resolver: ComponentResolver, private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap, private location: Location, private injector: Injector, private config: RouterConfig) { this.routerEvents = new Subject(); - this.currentUrlTree = createEmptyUrlTree() + this.currentUrlTree = createEmptyUrlTree(); this.currentRouterState = createEmptyState(this.rootComponentType); } @@ -275,7 +275,7 @@ class GuardChecks { if (this.checks.length === 0) return of(true); return forkJoin(this.checks.map(s => { if (s instanceof CanActivate) { - return this.runCanActivate(s.route) + return this.runCanActivate(s.route); } else if (s instanceof CanDeactivate) { return this.runCanDeactivate(s.component, s.route); } else { @@ -316,7 +316,7 @@ class GuardChecks { private deactivateOutletAndItChildren(route: ActivatedRouteSnapshot, outlet: RouterOutlet): void { if (outlet && outlet.isActivated) { forEach(outlet.outletMap._outlets, (v, k) => this.deactivateOutletAndItChildren(v, outlet.outletMap._outlets[k])); - this.checks.push(new CanDeactivate(outlet.component, route)) + this.checks.push(new CanDeactivate(outlet.component, route)); } } diff --git a/modules/@angular/router/tslint.json b/modules/@angular/router/tslint.json new file mode 100644 index 0000000000..055dc404ce --- /dev/null +++ b/modules/@angular/router/tslint.json @@ -0,0 +1,72 @@ +{ + "rulesDirectory": ["node_modules/codelyzer"], + "rules": { + "max-line-length": [true, 100], + "no-inferrable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "eofline": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-arg": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-bitwise": true, + "no-shadowed-variable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "one-line": [ + true, + "check-catch", + "check-else", + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "semicolon": [true, "always"], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "curly": true, + "variable-name": [ + true, + "ban-keywords", + "check-format", + "allow-trailing-underscore" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "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 + } +} \ No newline at end of file