Skip to content

Commit 675d84b

Browse files
SFX build: phase 1 (antonybudianto#74)
* init new build * update dependencies * Integrate with Codelyzer * chore(tslint.json): update semicolon value * change tslint order and separate
1 parent bdb070a commit 675d84b

22 files changed

+70
-39
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
## Introduction
2424
Welcome to Angular 2 Starter!
2525
This starter contains almost everything you need to start developing [Angular 2](https://angular.io/):
26+
* [NPM](https://www.npmjs.com/) for package manager
2627
* [TypeScript](http://www.typescriptlang.org/) for the base language
2728
* with [Typings](https://github.com/typings/typings) for TypeScript definition manager
2829
* [Gulp](http://gulpjs.com/) for workflow (from *serve*, *watch*, *compile*, *test* to *build*)
29-
* [NPM](https://www.npmjs.com/) for package manager
3030
* [Browsersync](https://www.browsersync.io/) for development server & reload capability
3131
* [SystemJS](https://github.com/systemjs/systemjs) for module loader
32+
* [Codelyzer](https://github.com/mgechev/codelyzer) for static code analyzer
3233
* [Karma](http://karma-runner.github.io/) for test-runner
3334
* [Jasmine](http://jasmine.github.io/) for test framework
3435
* [Istanbul](https://github.com/gotwarlost/istanbul) for test coverage

app/app.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { AppComponent } from './app.component';
2222
import { LoggerService } from './blocks/logger.service';
2323

2424
@Component({
25-
selector: 'test',
26-
template: '<div><main-app></main-app></div>',
25+
selector: 'as-test',
26+
template: '<div><as-main-app></as-main-app></div>',
2727
directives: [AppComponent]
2828
})
2929
class TestComponent {

app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {NavbarComponent} from './navbar/navbar.component';
55
import {LoggerService} from './blocks/logger.service';
66

77
@Component({
8-
selector: 'main-app',
8+
selector: 'as-main-app',
99
templateUrl: 'app/app.html',
1010
directives: [RouterOutlet, NavbarComponent]
1111
})

app/app.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<navbar [routes]="appRoutes" brand="Angular 2 Starter"></navbar>
1+
<as-navbar [routes]="appRoutes" brand="Angular 2 Starter"></as-navbar>
22
<div class="container" style="margin-top: 100px;">
33
<router-outlet></router-outlet>
44
</div>

app/home/home.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component} from '@angular/core';
22

33
@Component({
4-
selector: 'home',
4+
selector: 'as-home',
55
templateUrl: 'app/home/home.html',
66
styleUrls: [
77
'app/home/home.css'

app/navbar/navbar.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {CORE_DIRECTIVES} from '@angular/common';
33
import {RouterLink, RouteDefinition} from '@angular/router-deprecated';
44

55
@Component({
6-
selector: 'navbar',
6+
selector: 'as-navbar',
77
templateUrl: 'app/navbar/navbar.html',
88
changeDetection: ChangeDetectionStrategy.OnPush,
99
directives: [RouterLink, CORE_DIRECTIVES]

app/simplebind/child.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { Component } from '@angular/core';
1313
import { ChildComponent } from './child.component';
1414

1515
@Component({
16-
selector: 'test',
16+
selector: 'as-test',
1717
template: `
18-
<child text="Hello test" [(fromParent)]="testName"></child>
18+
<as-child text="Hello test" [(fromParent)]="testName"></as-child>
1919
`,
2020
directives: [ChildComponent]
2121
})

app/simplebind/child.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component, Input, Output, EventEmitter} from '@angular/core';
22

33
@Component({
4-
selector: 'child',
4+
selector: 'as-child',
55
template: `
66
<h5>{{text}}</h5>
77
<h6>{{fromParent}}</h6>

app/simplebind/simplebind.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { Component } from '@angular/core';
1212
import { SimplebindComponent } from './simplebind.component';
1313

1414
@Component({
15-
selector: 'test',
16-
template: '<div><simplebind></simplebind></div>',
15+
selector: 'as-test',
16+
template: '<div><as-simplebind></as-simplebind></div>',
1717
directives: [SimplebindComponent]
1818
})
1919
class TestComponent {

app/simplebind/simplebind.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Component} from '@angular/core';
22
import {ChildComponent} from './child.component';
33

44
@Component({
5-
selector: 'simplebind',
5+
selector: 'as-simplebind',
66
templateUrl: 'app/simplebind/simplebind.html',
77
directives: [ChildComponent]
88
})

app/simplebind/simplebind.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ <h5>Parent component</h5>
2020
<div class="form-group">
2121
<div class="well">
2222
<h5>Child component:</h5>
23-
<child text="Custom 1-way Binding" [fromParent]="myname"></child>
24-
<child text="Custom 2-way Binding" [(fromParent)]="myname"></child>
23+
<as-child text="Custom 1-way Binding" [fromParent]="myname"></as-child>
24+
<as-child text="Custom 2-way Binding" [(fromParent)]="myname"></as-child>
2525
</div>
2626
</div>
2727
</div>

app/todolist/completed-filter.pipe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Todo} from './todo.model';
33
import {filter} from 'lodash';
44

55
@Pipe({
6-
name: 'completedFilter'
6+
name: 'asCompletedFilter'
77
})
88
export class CompletedFilterPipe implements PipeTransform {
99
transform(todos: Todo[], done): Todo[] {

app/todolist/todolist.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { Todo } from './todo.model';
1414
import { TodolistComponent } from './todolist.component';
1515

1616
@Component({
17-
selector: 'test',
18-
template: '<todolist></todolist>',
17+
selector: 'as-test',
18+
template: '<as-todolist></as-todolist>',
1919
directives: [TodolistComponent]
2020
})
2121
class TestComponent {

app/todolist/todolist.component.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import {Component} from '@angular/core';
1+
import {
2+
Component,
3+
ChangeDetectorRef,
4+
ChangeDetectionStrategy
5+
} from '@angular/core';
26
import {CORE_DIRECTIVES} from '@angular/common';
37
import {Todo} from './todo.model';
48
import {CompletedFilterPipe} from './completed-filter.pipe';
59

610
@Component({
7-
selector: 'todolist',
11+
selector: 'as-todolist',
812
templateUrl: 'app/todolist/todolist.html',
913
directives: [CORE_DIRECTIVES],
10-
pipes: [CompletedFilterPipe]
14+
pipes: [CompletedFilterPipe],
15+
changeDetection: ChangeDetectionStrategy.OnPush
1116
})
1217
export class TodolistComponent {
1318
public todo: Todo;
1419
private list: Todo[];
1520
private showCompleted: Boolean;
1621

17-
constructor() {
22+
constructor(private _ref: ChangeDetectorRef) {
1823
this.showCompleted = true;
1924
this.todo = new Todo('Add me to list!', false);
2025
this.list = [
@@ -24,11 +29,16 @@ export class TodolistComponent {
2429
}
2530

2631
addTodo() {
27-
this.list.push(Todo.clone(this.todo));
32+
this.list = this.list.concat(Todo.clone(this.todo));
2833
this.todo.clear();
34+
this._ref.markForCheck();
2935
}
3036

3137
delTodo(index: number) {
32-
this.list.splice(index, 1);
38+
this.list = [].concat(
39+
this.list.slice(0, index),
40+
this.list.slice(index + 1, this.list.length)
41+
);
42+
this._ref.markForCheck();
3343
}
3444
}

app/todolist/todolist.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h3 class="panel-title"><i class="fa fa-list"></i> To Do List &nbsp;<span class=
3939
<div class="row">
4040
<div class="col-md-5">
4141
<ul class="list-group">
42-
<li *ngFor="let todo of (list | completedFilter:showCompleted); let i=index" class="list-group-item">
42+
<li *ngFor="let todo of (list | asCompletedFilter:showCompleted); let i=index" class="list-group-item">
4343
<span title="Remove todo" class="badge" (click)="delTodo(i) ">x</span>
4444
<label><input type="checkbox" [(ngModel)]="todo.done"> {{todo.name}}</label>
4545
</li>

gulp.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = function () {
4545
},
4646
files: [
4747
"index.html",
48+
"systemjs.conf.js",
4849
"assets/styles/main.css",
4950
"app/**/*.js",
5051
"app/**/*.html"

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<!-- endbuild -->
1313
</head>
1414
<body>
15-
<main-app>
15+
<as-main-app>
1616
<i class="center-fix main-spinner fa fa-spin fa-spinner"></i>
17-
</main-app>
17+
</as-main-app>
1818

1919
<!-- build:js assets/bundle.js -->
2020
<script src="node_modules/jquery/dist/jquery.js"></script>

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
},
5252
"devDependencies": {
5353
"browser-sync": "^2.12.5",
54+
"codelyzer": "0.0.19",
5455
"connect-history-api-fallback": "^1.2.0",
5556
"coveralls": "^2.11.9",
5657
"del": "~2.2.0",
5758
"glob": "^7.0.3",
5859
"gulp": "^3.9.1",
5960
"gulp-cssnano": "^2.1.2",
6061
"gulp-if": "~2.0.0",
61-
"gulp-inject": "^4.0.0",
6262
"gulp-protractor": "^2.3.0",
6363
"gulp-replace": "^0.5.4",
6464
"gulp-rev": "^7.0.0",
@@ -71,9 +71,9 @@
7171
"gulp-useref": "~3.1.0",
7272
"jasmine-core": "~2.4.1",
7373
"karma": "~0.13.22",
74-
"karma-coverage": "~0.5.5",
74+
"karma-coverage": "~1.0.0",
7575
"karma-ie-launcher": "^1.0.0",
76-
"karma-jasmine": "~0.3.8",
76+
"karma-jasmine": "~1.0.2",
7777
"karma-phantomjs-launcher": "~1.0.0",
7878
"karma-sourcemap-loader": "^0.3.7",
7979
"path": "^0.12.7",

systemjs.conf.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
// packages tells the System loader how to load when no filename and/or no extension
2323
var packages = {
2424
'app': {
25-
defaultExtension: 'js',
26-
format: 'register'
25+
defaultExtension: 'js'
2726
},
2827
'test': {
29-
defaultExtension: 'js',
30-
format: 'register'
28+
defaultExtension: 'js'
3129
},
3230
'rxjs': {
3331
defaultExtension: 'js'

tasks/build.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var gulp = require('gulp');
22
var runSequence = require('run-sequence');
33
var config = require('../gulp.config')();
4-
var inject = require('gulp-inject');
54
var useref = require('gulp-useref');
65
var gulpif = require('gulp-if');
76
var rev = require('gulp-rev');

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
3-
"target": "ES5",
4-
"module": "system",
3+
"target": "es5",
4+
"module": "commonjs",
55
"moduleResolution": "node",
66
"sourceMap": true,
77
"emitDecoratorMetadata": true,

tslint.json

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"rulesDirectory": [
3+
"node_modules/codelyzer"
4+
],
25
"rules": {
36
"class-name": true,
47
"comment-format": [true, "check-space"],
@@ -50,7 +53,7 @@
5053
],
5154
"quotemark": [true, "single"],
5255
"radix": true,
53-
"semicolon": true,
56+
"semicolon": [true, "always"],
5457
"triple-equals": [true, "allow-null-check"],
5558
"typedef-whitespace": [true, {
5659
"call-signature": "nospace",
@@ -66,6 +69,25 @@
6669
"check-operator",
6770
"check-separator",
6871
"check-type"
69-
]
72+
],
73+
74+
"directive-selector-name": [true, "camelCase"],
75+
"component-selector-name": [true, "kebab-case"],
76+
"directive-selector-type": [true, "attribute"],
77+
"component-selector-type": [true, "element"],
78+
"directive-selector-prefix": [true, "as"],
79+
"component-selector-prefix": [true, "as"],
80+
"pipe-naming": [true, "camelCase", "as"],
81+
"use-input-property-decorator": true,
82+
"use-output-property-decorator": true,
83+
"use-host-property-decorator": true,
84+
"no-attribute-parameter-decorator": true,
85+
"no-input-rename": true,
86+
"no-output-rename": true,
87+
"no-forward-ref" :true,
88+
"use-life-cycle-interface": true,
89+
"use-pipe-transform-interface": true,
90+
"component-class-suffix": true,
91+
"directive-class-suffix": true
7092
}
7193
}

0 commit comments

Comments
 (0)