Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 17071a9

Browse files
johnpapawardbell
authored andcommitted
docs(style-guide): add style-guide - v.4 w/ Jesus examples & lint stuff
1 parent 097505b commit 17071a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+871
-177
lines changed

gulpfile.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var globby = require("globby");
2525
var treeKill = require("tree-kill");
2626
var blc = require("broken-link-checker");
2727

28+
var tslint = require('gulp-tslint');
29+
2830
// TODO:
2931
// 1. Think about using runSequence
3032
// 2. Think about using spawn instead of exec in case of long error messages.
@@ -45,6 +47,7 @@ var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZip
4547
var plunkerBuilder = require(path.resolve(TOOLS_PATH, 'plunker-builder/plunkerBuilder'));
4648
var fsUtils = require(path.resolve(TOOLS_PATH, 'fs-utils/fsUtils'));
4749

50+
4851
var _devguideShredOptions = {
4952
examplesDir: path.join(DOCS_PATH, '_examples'),
5053
fragmentsDir: path.join(DOCS_PATH, '_fragments'),
@@ -498,6 +501,20 @@ gulp.task('_zip-examples', function() {
498501
});
499502

500503

504+
// Linting
505+
506+
gulp.task('lint', function() {
507+
return gulp.src(['./public/docs/_examples/style-guide/ts/**/*.ts'])
508+
.pipe(tslint({
509+
rulesDirectory: ['node_modules/codelyzer'],
510+
configuration: require('./tslint.json')
511+
}))
512+
.pipe(tslint.report('prose', {
513+
summarizeFailureOutput: true
514+
}));
515+
});
516+
517+
501518
// Helper functions
502519

503520
function harpCompile() {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"harp": "harp",
1010
"live-server": "live-server",
1111
"test-api-builder": "jasmine-node tools/api-builder",
12-
1312
"protractor": "protractor"
1413
},
1514
"repository": {
@@ -28,10 +27,11 @@
2827
"devDependencies": {
2928
"archiver": "^0.16.0",
3029
"assert-plus": "^0.1.5",
31-
"broken-link-checker":"0.7.0",
30+
"broken-link-checker": "0.7.0",
3231
"browser-sync": "^2.9.3",
3332
"canonical-path": "0.0.2",
3433
"cross-spawn": "^2.1.0",
34+
"codelyzer": "0.0.18",
3535
"del": "^1.2.0",
3636
"dgeni": "^0.4.0",
3737
"dgeni-packages": "^0.11.1",
@@ -42,6 +42,7 @@
4242
"gulp": "^3.5.6",
4343
"gulp-env": "0.4.0",
4444
"gulp-task-listing": "^1.0.1",
45+
"gulp-tslint": "^4.3.5",
4546
"gulp-util": "^3.0.6",
4647
"gulp-watch": "^4.3.4",
4748
"harp": "^0.20.3",
@@ -66,6 +67,7 @@
6667
"protractor": "^3.0.0",
6768
"q": "^1.4.1",
6869
"tree-kill": "^1.0.0",
70+
"tslint": "^3.2.2",
6971
"typescript": "1.7.3",
7072
"yargs": "^3.23.0"
7173
},

public/docs/_examples/style-guide/ts/01-01/app/app.component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
6-
// app.component.ts
2+
/**
3+
* The root AppComponent
4+
*/
75
import { Component, OnInit } from 'angular2/core';
86

9-
import { Hero } from './hero';
7+
import { Hero } from './hero.model';
108
import { HeroService } from './hero.service';
119

1210
@Component({
@@ -17,7 +15,7 @@ import { HeroService } from './hero.service';
1715
styleUrls: ['app/app.component.css'],
1816
providers: [HeroService]
1917
})
20-
export class AppComponent implements OnInit{
18+
export class AppComponent implements OnInit {
2119
heroes: Hero[] = [];
2220

2321
constructor(private heroService: HeroService) {}

public/docs/_examples/style-guide/ts/01-01/app/hero.model.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
2+
/**
3+
* The Hero Model
4+
*/
65
export class Hero {
76
id: number;
87
name: string;

public/docs/_examples/style-guide/ts/01-01/app/hero.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
2+
/**
3+
* The Data Access Service for heroes
4+
*/
65
import { Injectable } from 'angular2/core';
7-
import { HEROES } from './mock-heroes';
6+
import { HEROES } from './mock-heroes';
87

98
@Injectable()
109
export class HeroService {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// #docregion
2+
/**
3+
* Everything in one file ... it's all here!
4+
* AVOID THIS PATTERN
5+
*/
6+
import { bootstrap } from 'angular2/platform/browser';
7+
import { Component, OnInit } from 'angular2/core';
8+
9+
class Hero {
10+
id: number;
11+
name: string;
12+
}
13+
14+
@Component({
15+
selector: 'my-app',
16+
template: `
17+
<h1>{{title}}</h1>
18+
<pre>{{heroes | json}}</pre>
19+
`,
20+
styleUrls: ['app/app.component.css']
21+
})
22+
class AppComponent implements OnInit {
23+
title = 'Tour of Heroes';
24+
25+
heroes: Hero[] = [];
26+
27+
ngOnInit() {
28+
getHeroes().then(heroes => this.heroes = heroes);
29+
}
30+
}
31+
32+
bootstrap(AppComponent, []);
33+
34+
const HEROES: Hero[] = [
35+
{id: 1, name: 'Bombasto'},
36+
{id: 2, name: 'Tornado'},
37+
{id: 3, name: 'Magneta'},
38+
];
39+
40+
function getHeroes(): Promise<Hero[]> {
41+
return Promise.resolve(HEROES); // TODO: get hero data from the server;
42+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
6-
import { bootstrap } from 'angular2/platform/browser';
2+
/**
3+
* Application bootstrapping
4+
*/
5+
import { bootstrap } from 'angular2/platform/browser';
76
import { AppComponent } from './app.component';
87

98
bootstrap(AppComponent, []);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #docregion
2+
/**
3+
* Mock heroes until we can get real data
4+
*/
5+
import { Hero } from './hero.model';
6+
7+
export const HEROES: Hero[] = [
8+
{id: 1, name: 'Bombasto'},
9+
{id: 2, name: 'Tornado'},
10+
{id: 3, name: 'Magneta'},
11+
];

public/docs/_examples/style-guide/ts/01-01/app/placeholder.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'toh-hero'
7+
})
8+
export class HeroComponent {}
9+
// #enddocregion example
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// #docregion
2+
/**
3+
* AVOID THIS PATTERN
4+
*/
5+
6+
/*
7+
* HeroComponent is in the Tour of Heroes feature
8+
*/
9+
@Component({
10+
selector: 'hero'
11+
})
12+
export class HeroComponent {}
13+
14+
/*
15+
* UsersComponent is in an Admin feature
16+
*/
17+
@Component({
18+
selector: 'users'
19+
})
20+
export class UsersComponent {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'admin-users'
7+
})
8+
export class UsersComponent {}
9+
// #enddocregion example
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
/**
3+
* AVOID THIS PATTERN
4+
*/
5+
6+
@Directive({
7+
selector: '[validate]'
8+
})
9+
export class ValidateDirective {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Directive } from 'angular2/core';
3+
4+
// #docregion example
5+
@Directive({
6+
selector: '[tohValidate]'
7+
})
8+
export class ValidateDirective {}
9+
// #enddocregion example
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<toh-hero-button></toh-hero-button>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'toh-hero-button'
7+
})
8+
export class HeroButtonComponent {}
9+
// #enddocregion example
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
/**
3+
* AVOID THIS PATTERN
4+
*/
5+
6+
@Component({
7+
selector: 'tohHeroButton'
8+
})
9+
export class HeroButtonComponent {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<toh-hero-button></toh-hero-button>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'toh-hero-button'
7+
})
8+
export class HeroButtonComponent {}
9+
// #enddocregion example
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- #docregion -->
2+
<!-- AVOID THIS PATTERN -->
3+
<div tohHeroButton></div>

0 commit comments

Comments
 (0)