diff --git a/aio/content/examples/ajs-quick-reference/src/app/app.component.ts b/aio/content/examples/ajs-quick-reference/src/app/app.component.ts index e1b71e37dc..91091026ad 100644 --- a/aio/content/examples/ajs-quick-reference/src/app/app.component.ts +++ b/aio/content/examples/ajs-quick-reference/src/app/app.component.ts @@ -19,7 +19,7 @@ export class AppComponent { movie: IMovie = null; movies: IMovie[] = []; showImage = true; - title: string = 'AngularJS to Angular Quick Ref Cookbook'; + title = 'AngularJS to Angular Quick Ref Cookbook'; toggleImage(event: UIEvent) { this.showImage = !this.showImage; this.eventType = (event && event.type) || 'not provided'; diff --git a/aio/content/examples/ajs-quick-reference/src/app/movie-list.component.ts b/aio/content/examples/ajs-quick-reference/src/app/movie-list.component.ts index b0b57f018c..fa71f7a7ab 100644 --- a/aio/content/examples/ajs-quick-reference/src/app/movie-list.component.ts +++ b/aio/content/examples/ajs-quick-reference/src/app/movie-list.component.ts @@ -19,7 +19,7 @@ import { MovieService } from './movie.service'; export class MovieListComponent { // #enddocregion class favoriteHero: string; - showImage: boolean = false; + showImage = false; movies: IMovie[]; // #docregion di diff --git a/aio/content/examples/architecture/e2e-spec.ts b/aio/content/examples/architecture/e2e-spec.ts index e967804483..a5aa78f4fc 100644 --- a/aio/content/examples/architecture/e2e-spec.ts +++ b/aio/content/examples/architecture/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { protractor, browser, element, by, ElementFinder } from 'protractor'; diff --git a/aio/content/examples/attribute-directives/e2e-spec.ts b/aio/content/examples/attribute-directives/e2e-spec.ts index 79425d7923..fd033ce32f 100644 --- a/aio/content/examples/attribute-directives/e2e-spec.ts +++ b/aio/content/examples/attribute-directives/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/attribute-directives/src/app/highlight.directive.2.ts b/aio/content/examples/attribute-directives/src/app/highlight.directive.2.ts index 4696132f64..6778e7e46c 100644 --- a/aio/content/examples/attribute-directives/src/app/highlight.directive.2.ts +++ b/aio/content/examples/attribute-directives/src/app/highlight.directive.2.ts @@ -28,7 +28,7 @@ export class HighlightDirective { private highlight(color: string) { this.el.nativeElement.style.backgroundColor = color; } - // #enddocregion mouse-methods, + // #enddocregion mouse-methods, // #docregion color @Input() highlightColor: string; diff --git a/aio/content/examples/attribute-directives/src/app/highlight.directive.ts b/aio/content/examples/attribute-directives/src/app/highlight.directive.ts index 97b1497013..2269cbbe39 100644 --- a/aio/content/examples/attribute-directives/src/app/highlight.directive.ts +++ b/aio/content/examples/attribute-directives/src/app/highlight.directive.ts @@ -1,5 +1,5 @@ /* tslint:disable:member-ordering */ -// #docregion imports, +// #docregion imports, import { Directive, ElementRef, HostListener, Input } from '@angular/core'; // #enddocregion imports diff --git a/aio/content/examples/component-communication/src/app/hero-parent.component.ts b/aio/content/examples/component-communication/src/app/hero-parent.component.ts index bf3861c455..19ceda7bac 100644 --- a/aio/content/examples/component-communication/src/app/hero-parent.component.ts +++ b/aio/content/examples/component-communication/src/app/hero-parent.component.ts @@ -15,6 +15,6 @@ import { HEROES } from './hero'; }) export class HeroParentComponent { heroes = HEROES; - master: string = 'Master'; + master = 'Master'; } // #enddocregion diff --git a/aio/content/examples/component-communication/src/app/version-parent.component.ts b/aio/content/examples/component-communication/src/app/version-parent.component.ts index bbc9101702..5a8d904c72 100644 --- a/aio/content/examples/component-communication/src/app/version-parent.component.ts +++ b/aio/content/examples/component-communication/src/app/version-parent.component.ts @@ -11,8 +11,8 @@ import { Component } from '@angular/core'; ` }) export class VersionParentComponent { - major: number = 1; - minor: number = 23; + major = 1; + minor = 23; newMinor() { this.minor++; diff --git a/aio/content/examples/dependency-injection-in-action/e2e-spec.ts b/aio/content/examples/dependency-injection-in-action/e2e-spec.ts index 8c9d163d5e..520d2d187e 100644 --- a/aio/content/examples/dependency-injection-in-action/e2e-spec.ts +++ b/aio/content/examples/dependency-injection-in-action/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/dependency-injection-in-action/src/app/app.component.ts b/aio/content/examples/dependency-injection-in-action/src/app/app.component.ts index 3045893c58..250103124a 100644 --- a/aio/content/examples/dependency-injection-in-action/src/app/app.component.ts +++ b/aio/content/examples/dependency-injection-in-action/src/app/app.component.ts @@ -16,7 +16,7 @@ import { UserService } from './user.service'; export class AppComponent { // #enddocregion import-services - private userId: number = 1; + private userId = 1; // #docregion ctor constructor(logger: LoggerService, public userContext: UserContextService) { diff --git a/aio/content/examples/dependency-injection-in-action/src/app/date-logger.service.ts b/aio/content/examples/dependency-injection-in-action/src/app/date-logger.service.ts index 875779be40..465e16cf9b 100644 --- a/aio/content/examples/dependency-injection-in-action/src/app/date-logger.service.ts +++ b/aio/content/examples/dependency-injection-in-action/src/app/date-logger.service.ts @@ -1,4 +1,4 @@ -/* tslint:disable:one-line:check-open-brace*/ +/* tslint:disable:one-line*/ // #docregion import { Injectable } from '@angular/core'; diff --git a/aio/content/examples/dependency-injection-in-action/src/app/hero-of-the-month.component.ts b/aio/content/examples/dependency-injection-in-action/src/app/hero-of-the-month.component.ts index 90ad13d639..ff8e5a24e8 100644 --- a/aio/content/examples/dependency-injection-in-action/src/app/hero-of-the-month.component.ts +++ b/aio/content/examples/dependency-injection-in-action/src/app/hero-of-the-month.component.ts @@ -1,4 +1,4 @@ -/* tslint:disable:one-line:check-open-brace*/ +/* tslint:disable:one-line*/ // #docplaster // #docregion injection-token import { InjectionToken } from '@angular/core'; diff --git a/aio/content/examples/dependency-injection/src/app/heroes/mock-heroes.ts b/aio/content/examples/dependency-injection/src/app/heroes/mock-heroes.ts index 79a91dc03a..a836faa1bd 100644 --- a/aio/content/examples/dependency-injection/src/app/heroes/mock-heroes.ts +++ b/aio/content/examples/dependency-injection/src/app/heroes/mock-heroes.ts @@ -1,7 +1,7 @@ // #docregion import { Hero } from './hero'; -export var HEROES: Hero[] = [ +export const HEROES: Hero[] = [ { id: 11, isSecret: false, name: 'Mr. Nice' }, { id: 12, isSecret: false, name: 'Narco' }, { id: 13, isSecret: false, name: 'Bombasto' }, diff --git a/aio/content/examples/dependency-injection/src/app/providers.component.ts b/aio/content/examples/dependency-injection/src/app/providers.component.ts index a96bfce99e..589de212ed 100644 --- a/aio/content/examples/dependency-injection/src/app/providers.component.ts +++ b/aio/content/examples/dependency-injection/src/app/providers.component.ts @@ -117,7 +117,7 @@ class OldLogger { export class Provider6aComponent { log: string; constructor(newLogger: NewLogger, oldLogger: OldLogger) { - if (newLogger === oldLogger){ + if (newLogger === oldLogger) { throw new Error('expected the two loggers to be different instances'); } oldLogger.log('Hello OldLogger (but we want NewLogger)'); @@ -140,7 +140,7 @@ export class Provider6aComponent { export class Provider6bComponent { log: string; constructor(newLogger: NewLogger, oldLogger: OldLogger) { - if (newLogger !== oldLogger){ + if (newLogger !== oldLogger) { throw new Error('expected the two loggers to be the same instance'); } oldLogger.log('Hello from NewLogger (via aliased OldLogger)'); diff --git a/aio/content/examples/dynamic-component-loader/e2e-spec.ts b/aio/content/examples/dynamic-component-loader/e2e-spec.ts index 5036ac2a88..b04412c28b 100644 --- a/aio/content/examples/dynamic-component-loader/e2e-spec.ts +++ b/aio/content/examples/dynamic-component-loader/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/dynamic-form/e2e-spec.ts b/aio/content/examples/dynamic-form/e2e-spec.ts index 408ac75766..6535e3e0c5 100644 --- a/aio/content/examples/dynamic-form/e2e-spec.ts +++ b/aio/content/examples/dynamic-form/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/ngmodule/e2e-spec.ts b/aio/content/examples/ngmodule/e2e-spec.ts index 0fbce1213d..6113584626 100644 --- a/aio/content/examples/ngmodule/e2e-spec.ts +++ b/aio/content/examples/ngmodule/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/router/src/app/auth.service.ts b/aio/content/examples/router/src/app/auth.service.ts index f86a80ebfe..908a4ae18b 100644 --- a/aio/content/examples/router/src/app/auth.service.ts +++ b/aio/content/examples/router/src/app/auth.service.ts @@ -8,7 +8,7 @@ import 'rxjs/add/operator/delay'; @Injectable() export class AuthService { - isLoggedIn: boolean = false; + isLoggedIn = false; // store the URL so we can redirect after logging in redirectUrl: string; diff --git a/aio/content/examples/router/src/app/compose-message.component.ts b/aio/content/examples/router/src/app/compose-message.component.ts index 17a0953378..6e83e3502b 100644 --- a/aio/content/examples/router/src/app/compose-message.component.ts +++ b/aio/content/examples/router/src/app/compose-message.component.ts @@ -15,7 +15,7 @@ export class ComposeMessageComponent { @HostBinding('style.position') position = 'absolute'; details: string; - sending: boolean = false; + sending = false; constructor(private router: Router) {} diff --git a/aio/content/examples/security/e2e-spec.ts b/aio/content/examples/security/e2e-spec.ts index 23d11cd12b..8ebad58f21 100644 --- a/aio/content/examples/security/e2e-spec.ts +++ b/aio/content/examples/security/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, By } from 'protractor'; diff --git a/aio/content/examples/styleguide/e2e-spec.ts b/aio/content/examples/styleguide/e2e-spec.ts index d143ae5573..e740495858 100644 --- a/aio/content/examples/styleguide/e2e-spec.ts +++ b/aio/content/examples/styleguide/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/content/examples/template-syntax/src/app/click.directive.ts b/aio/content/examples/template-syntax/src/app/click.directive.ts index 09757bfeaf..22b63955ea 100644 --- a/aio/content/examples/template-syntax/src/app/click.directive.ts +++ b/aio/content/examples/template-syntax/src/app/click.directive.ts @@ -1,4 +1,4 @@ -/* tslint:disable use-output-property-decorator */ +/* tslint:disable use-output-property-decorator directive-class-suffix */ // #docplaster import { Directive, ElementRef, EventEmitter, Output } from '@angular/core'; diff --git a/aio/content/examples/testing/src/app/bag/bag.no-testbed.spec.ts b/aio/content/examples/testing/src/app/bag/bag.no-testbed.spec.ts index f29672ecf6..4cb60a8d50 100644 --- a/aio/content/examples/testing/src/app/bag/bag.no-testbed.spec.ts +++ b/aio/content/examples/testing/src/app/bag/bag.no-testbed.spec.ts @@ -3,7 +3,7 @@ import { DependentService, FancyService } from './bag'; ///////// Fakes ///////// export class FakeFancyService extends FancyService { - value: string = 'faked value'; + value = 'faked value'; } //////////////////////// // #docregion FancyService diff --git a/aio/content/examples/testing/src/app/bag/bag.spec.ts b/aio/content/examples/testing/src/app/bag/bag.spec.ts index d6fea7ca94..503ae96c51 100644 --- a/aio/content/examples/testing/src/app/bag/bag.spec.ts +++ b/aio/content/examples/testing/src/app/bag/bag.spec.ts @@ -677,5 +677,5 @@ class FakeGrandchildComponent { } @Injectable() class FakeFancyService extends FancyService { - value: string = 'faked value'; + value = 'faked value'; } diff --git a/aio/content/examples/testing/src/app/bag/bag.ts b/aio/content/examples/testing/src/app/bag/bag.ts index 521f390cfe..4ffe576b64 100644 --- a/aio/content/examples/testing/src/app/bag/bag.ts +++ b/aio/content/examples/testing/src/app/bag/bag.ts @@ -20,7 +20,7 @@ export class Hero { // #docregion FancyService @Injectable() export class FancyService { - protected value: string = 'real value'; + protected value = 'real value'; getValue() { return this.value; } setValue(value: string) { this.value = value; } diff --git a/aio/content/examples/testing/src/app/model/test-heroes.ts b/aio/content/examples/testing/src/app/model/test-heroes.ts index d40ce5d564..2dc0f92502 100644 --- a/aio/content/examples/testing/src/app/model/test-heroes.ts +++ b/aio/content/examples/testing/src/app/model/test-heroes.ts @@ -1,7 +1,7 @@ // #docregion import { Hero } from './hero'; -export var HEROES: Hero[] = [ +export const HEROES: Hero[] = [ new Hero(11, 'Mr. Nice'), new Hero(12, 'Narco'), new Hero(13, 'Bombasto'), diff --git a/aio/content/examples/testing/src/app/model/testing/fake-hero.service.ts b/aio/content/examples/testing/src/app/model/testing/fake-hero.service.ts index 79a865cc44..02e1484df4 100644 --- a/aio/content/examples/testing/src/app/model/testing/fake-hero.service.ts +++ b/aio/content/examples/testing/src/app/model/testing/fake-hero.service.ts @@ -5,7 +5,7 @@ export { HeroService } from '../hero.service'; import { Hero } from '../hero'; import { HeroService } from '../hero.service'; -export var HEROES: Hero[] = [ +export const HEROES: Hero[] = [ new Hero(41, 'Bob'), new Hero(42, 'Carol'), new Hero(43, 'Ted'), diff --git a/aio/content/examples/toh-pt1/e2e-spec.ts b/aio/content/examples/toh-pt1/e2e-spec.ts index 75f99788a6..b684a358fd 100644 --- a/aio/content/examples/toh-pt1/e2e-spec.ts +++ b/aio/content/examples/toh-pt1/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by, ElementFinder } from 'protractor'; import { promise } from 'selenium-webdriver'; diff --git a/aio/content/examples/toh-pt2/e2e-spec.ts b/aio/content/examples/toh-pt2/e2e-spec.ts index 34f9fba573..53474d98b3 100644 --- a/aio/content/examples/toh-pt2/e2e-spec.ts +++ b/aio/content/examples/toh-pt2/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by, ElementFinder } from 'protractor'; import { promise } from 'selenium-webdriver'; diff --git a/aio/content/examples/toh-pt3/e2e-spec.ts b/aio/content/examples/toh-pt3/e2e-spec.ts index 842716c5fc..2699ac8ccd 100644 --- a/aio/content/examples/toh-pt3/e2e-spec.ts +++ b/aio/content/examples/toh-pt3/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by, ElementFinder } from 'protractor'; import { promise } from 'selenium-webdriver'; diff --git a/aio/content/examples/toh-pt4/e2e-spec.ts b/aio/content/examples/toh-pt4/e2e-spec.ts index d6a223dd12..3a008d27f4 100644 --- a/aio/content/examples/toh-pt4/e2e-spec.ts +++ b/aio/content/examples/toh-pt4/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by, ElementFinder } from 'protractor'; import { promise } from 'selenium-webdriver'; diff --git a/aio/content/examples/ts-to-js/ts/src/app/hero-title.component.ts b/aio/content/examples/ts-to-js/ts/src/app/hero-title.component.ts index 48aaae7d44..078421ecc7 100644 --- a/aio/content/examples/ts-to-js/ts/src/app/hero-title.component.ts +++ b/aio/content/examples/ts-to-js/ts/src/app/hero-title.component.ts @@ -8,7 +8,7 @@ import { Attribute, Component, Inject, Optional } from '@angular/core'; }) // #enddocregion templateUrl export class HeroTitleComponent { - msg: string = ''; + msg = ''; constructor( @Inject('titlePrefix') @Optional() private titlePrefix: string, @Attribute('title') private title: string diff --git a/aio/content/examples/tslint.json b/aio/content/examples/tslint.json new file mode 100644 index 0000000000..2e81c99035 --- /dev/null +++ b/aio/content/examples/tslint.json @@ -0,0 +1,94 @@ +{ + "rulesDirectory": [ + "../../node_modules/codelyzer" + ], + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": true, + "no-string-literal": false, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "import-destructuring-spacing": true + } +} diff --git a/aio/content/examples/webpack/e2e-spec.ts b/aio/content/examples/webpack/e2e-spec.ts index 9bca9810eb..b13f93552e 100644 --- a/aio/content/examples/webpack/e2e-spec.ts +++ b/aio/content/examples/webpack/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; diff --git a/aio/package.json b/aio/package.json index a443c91395..0d4e2d80aa 100644 --- a/aio/package.json +++ b/aio/package.json @@ -9,7 +9,7 @@ "ng": "yarn check-env && ng", "start": "yarn check-env && ng serve", "build": "yarn check-env && yarn setup && ng build -prod -sm", - "lint": "yarn check-env && yarn docs-lint && ng lint", + "lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint", "test": "yarn check-env && ng test", "pree2e": "yarn ~~update-webdriver", "e2e": "yarn check-env && ng e2e --no-webdriver-update", @@ -18,6 +18,7 @@ "test-pwa-score-local": "concurrently --kill-others --success first \"http-server dist -p 4200 --silent\" \"yarn test-pwa-score -- http://localhost:4200 90\"", "test-pwa-score": "node scripts/test-pwa-score", "example-e2e": "node ./tools/examples/run-example-e2e", + "example-lint": "tslint -c \"content/examples/tslint.json\" \"content/examples/**/*.ts\" -e \"content/examples/styleguide/**/*.avoid.ts\"", "deploy-preview": "scripts/deploy-preview.sh", "deploy-staging": "scripts/deploy-staging.sh", "check-env": "node ../tools/check-environment.js",