diff --git a/config/tslint/codelizer.tslint.json b/config/tslint/codelizer.tslint.json new file mode 100644 index 0000000000..fd4295a93d --- /dev/null +++ b/config/tslint/codelizer.tslint.json @@ -0,0 +1,29 @@ +{ + "rulesDirectory": [ + "./../../node_modules/codelyzer" + ], + "rules": { + "directive-selector-name": [true, "camelCase"], + "component-selector-name": [true, "kebab-case"], + "directive-selector-type": [true, "attribute"], + "component-selector-type": [true, "element"], + "directive-selector-prefix": [true, "my"], + "component-selector-prefix": [true, "my"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-attribute-parameter-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "no-forward-ref": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "pipe-naming": [true, "camelCase", "my"], + "component-class-suffix": true, + "directive-class-suffix": true, + "import-destructuring-spacing": true, + "templates-use-public": true, + "no-access-missing-member": true, + "invoke-injectable": true + } +} diff --git a/package.json b/package.json index f02481b243..6fbc834f94 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "@types/webpack": "^1.12.34", "angular2-template-loader": "^0.5.0", "awesome-typescript-loader": "^2.2.1", - "codelyzer": "~0.0.28", + "codelyzer": "^1.0.0-beta.2", "copy-webpack-plugin": "^3.0.1", "css-loader": "^0.25.0", "exports-loader": "^0.6.3", @@ -120,7 +120,7 @@ "to-string-loader": "^1.1.4", "ts-helpers": "1.1.1", "ts-node": "^1.3.0", - "tslint": "3.15.1", + "tslint": "^4.0.0-dev.0", "tslint-loader": "^2.1.3", "typedoc": "^0.4.5", "typescript": "2.0.3", diff --git a/src/app/+detail/detail.component.ts b/src/app/+detail/detail.component.ts index afe5b371f4..d3b8e5eccf 100644 --- a/src/app/+detail/detail.component.ts +++ b/src/app/+detail/detail.component.ts @@ -1,19 +1,15 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; @Component({ - selector: 'detail', + selector: 'my-detail', template: `
this.localState = {{ localState | json }}- ` + `, }) -export class About { - localState: any; +export class AboutComponent implements OnInit { + public localState: any; constructor(public route: ActivatedRoute) { } - ngOnInit() { + public ngOnInit(): void { this.route .data .subscribe((data: any) => { @@ -40,14 +40,14 @@ export class About { this.localState = data.yourData; }); - console.log('hello `About` component'); + console.info('hello `About` component'); // static data that is bundled // var mockData = require('assets/mock-data/mock-data.json'); - // console.log('mockData', mockData); + // console.debug('mockData', mockData); // if you're working with mock data you can also use http.get('assets/mock-data/mock-data.json') this.asyncDataWithWebpack(); } - asyncDataWithWebpack() { + private asyncDataWithWebpack(): void { // you can also async load mock data with 'es6-promise-loader' // you would do this if you don't want the mock-data bundled // remember that 'es6-promise-loader' is a promise @@ -55,7 +55,7 @@ export class About { System.import('../../assets/mock-data/mock-data.json') .then(json => { - console.log('async mockData', json); + console.info('async mockData', json); this.localState = json; }); diff --git a/src/app/about/about.spec.ts b/src/app/about/about.spec.ts index 99933c3666..568958a6dc 100644 --- a/src/app/about/about.spec.ts +++ b/src/app/about/about.spec.ts @@ -1,9 +1,8 @@ import { ActivatedRoute, Data } from '@angular/router'; -import { Component } from '@angular/core'; import { inject, TestBed } from '@angular/core/testing'; // Load the implementations that should be tested -import { About } from './about.component'; +import { AboutComponent } from './about.component'; describe('About', () => { // provide our implementations or mocks to the dependency injector @@ -15,21 +14,21 @@ describe('About', () => { useValue: { data: { subscribe: (fn: (value: Data) => void) => fn({ - yourData: 'yolo' - }) - } - } + yourData: 'yolo', + }), + }, + }, }, - About - ] + AboutComponent, + ], })); - it('should log ngOnInit', inject([About], (about: About) => { - spyOn(console, 'log'); - expect(console.log).not.toHaveBeenCalled(); + it('should log ngOnInit using info', inject([AboutComponent], (about: AboutComponent) => { + spyOn(console, 'info'); + expect(console.info).not.toHaveBeenCalled(); about.ngOnInit(); - expect(console.log).toHaveBeenCalled(); + expect(console.info).toHaveBeenCalled(); })); }); diff --git a/src/app/app.component.html b/src/app/app.component.html new file mode 100644 index 0000000000..59711bdb42 --- /dev/null +++ b/src/app/app.component.html @@ -0,0 +1,40 @@ + + +
this.appState.state = {{ appState.state | json }}+ + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 08148e71e2..260de0f517 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,7 @@ /* * Angular 2 decorators and services */ -import { Component, ViewEncapsulation } from '@angular/core'; +import { Component, ViewEncapsulation, OnInit } from '@angular/core'; import { AppState } from './app.service'; @@ -10,66 +10,25 @@ import { AppState } from './app.service'; * Top Level Component */ @Component({ - selector: 'app', + selector: 'my-app', encapsulation: ViewEncapsulation.None, styleUrls: [ - './app.component.css' + './app.component.css', ], - template: ` - - -
this.appState.state = {{ appState.state | json }}- - - ` + templateUrl: './app.component.html', }) -export class App { - angularclassLogo = 'assets/img/angularclass-avatar.png'; - name = 'Angular 2 Webpack Starter'; - url = 'https://twitter.com/AngularClass'; +export class AppComponent implements OnInit { + public angularclassLogo = 'assets/img/angularclass-avatar.png'; + public name = 'Angular 2 Webpack Starter'; + public url = 'https://twitter.com/AngularClass'; constructor( public appState: AppState) { } - ngOnInit() { - console.log('Initial App State', this.appState.state); + public ngOnInit(): void { + console.info('Initial App State', this.appState.state); } } diff --git a/src/app/app.e2e.ts b/src/app/app.e2e.ts index 59cb21719d..44d74c76b2 100644 --- a/src/app/app.e2e.ts +++ b/src/app/app.e2e.ts @@ -4,7 +4,6 @@ describe('App', () => { browser.get('/'); }); - it('should have a title', () => { let subject = browser.getTitle(); let result = 'Angular2 Webpack Starter by @gdi2290 from @AngularClass'; @@ -17,8 +16,8 @@ describe('App', () => { expect(subject).toEqual(result); }); - it('should have