Skip to content

Commit d55d96b

Browse files
committed
chore(Conventions): naming standards
closes PatrickJS#185
1 parent c7fb0e4 commit d55d96b

13 files changed

+38
-33
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"tslint-loader": "^2.1.0",
7171
"typedoc": "^0.3.12",
7272
"typescript": "^1.7.3",
73-
"typings": "^0.3.1",
73+
"typings": "^0.4.1",
7474
"url-loader": "^0.5.6",
7575
"webpack": "^1.12.9",
7676
"webpack-dev-server": "^1.12.1"

src/app/app.spec.ts src/app/components/app.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import {
77
} from 'angular2/testing';
88

99
// Load the implementations that should be tested
10-
import {App} from './app';
10+
import {AppCmp} from './app.component';
1111

1212
describe('App', () => {
1313
// provide our implementations or mocks to the dependency injector
1414
beforeEachProviders(() => [
15-
App
15+
AppCmp
1616
]);
1717

18-
it('should have a url', inject([ App ], (app) => {
18+
it('should have a url', inject([ AppCmp ], (app) => {
1919
expect(app.url).toEqual('https://twitter.com/AngularClass');
2020
}));
2121

src/app/app.ts src/app/components/app.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Component} from 'angular2/core';
55
import {RouteConfig, Router, ROUTER_DIRECTIVES} from 'angular2/router';
66
import {FORM_PROVIDERS} from 'angular2/common';
77

8-
import {Home} from './home/home';
8+
import {HomeCmp} from './home/home.component';
99

1010
/*
1111
* App Component
@@ -36,10 +36,10 @@ import {Home} from './home/home';
3636
`
3737
})
3838
@RouteConfig([
39-
{ path: '/', component: Home, name: 'Index' },
40-
{ path: '/home', component: Home, name: 'Home' }
39+
{ path: '/', component: HomeCmp, name: 'Index' },
40+
{ path: '/home', component: HomeCmp, name: 'Home' }
4141
])
42-
export class App {
42+
export class AppCmp {
4343
name = 'Angular 2 Webpack Starter';
4444
url = 'https://twitter.com/AngularClass';
4545
constructor() {

src/app/home/home.spec.ts src/app/components/home/home.component.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import {BaseRequestOptions, Http} from 'angular2/http';
1212
import {MockBackend} from 'angular2/http/testing';
1313

1414
// Load the implementations that should be tested
15-
import {Home} from './home';
16-
import {Title} from './providers/title';
15+
import {HomeCmp} from './home.component';
16+
import {Title} from '../../providers/title.provider';
1717

1818
describe('Home', () => {
1919
// provide our implementations or mocks to the dependency injector
2020
beforeEachProviders(() => [
2121
Title,
22-
Home,
22+
HomeCmp,
2323
BaseRequestOptions,
2424
MockBackend,
2525
provide(Http, {
@@ -29,15 +29,15 @@ describe('Home', () => {
2929
deps: [MockBackend, BaseRequestOptions]})
3030
]);
3131

32-
it('should have a title', inject([ Home ], (home) => {
32+
it('should have a title', inject([ HomeCmp ], (home) => {
3333
expect(home.title.value).toEqual('Angular 2');
3434
}));
3535

36-
it('should have a http', inject([ Home ], (home) => {
36+
it('should have a http', inject([ HomeCmp ], (home) => {
3737
expect(!!home.http).toEqual(true);
3838
}));
3939

40-
it('should log ngOnInit', inject([ Home ], (home) => {
40+
it('should log ngOnInit', inject([ HomeCmp ], (home) => {
4141
spyOn(console, 'log');
4242
expect(console.log).not.toHaveBeenCalled();
4343

src/app/home/home.ts src/app/components/home/home.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {Component} from 'angular2/core';
1+
import {Component, OnInit} from 'angular2/core';
22
import {FORM_DIRECTIVES} from 'angular2/common';
33
import {Http} from 'angular2/http';
44

5-
import {Title} from './providers/title';
6-
import {XLarge} from './directives/x-large';
5+
import {Title} from '../../providers/title.provider';
6+
import {XLarge} from '../../directives/x-large.directive';
77

88
@Component({
99
// The selector is what angular internally uses
10-
// for `document.querySelectorAll(selector)` in our index.html
10+
// for document.querySelectorAll(selector) in our index.html
1111
// where, in this case, selector is the string 'app'
1212
selector: 'home', // <home></home>
1313
// We need to tell Angular's Dependency Injection which providers are in our app.
@@ -27,7 +27,7 @@ import {XLarge} from './directives/x-large';
2727
// Every Angular template is first compiled by the browser before Angular runs it's compiler
2828
template: require('./home.html')
2929
})
30-
export class Home {
30+
export class HomeCmp implements OnInit {
3131
// TypeScript public modifiers
3232
constructor(public title: Title, public http: Http) {
3333

File renamed without changes.
File renamed without changes.

src/app/home/directives/x-large.spec.ts src/app/directives/x-large.directive.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {BaseRequestOptions, Http} from 'angular2/http';
1212
import {MockBackend} from 'angular2/http/testing';
1313

1414
// Load the implementations that should be tested
15-
import {XLarge} from './x-large';
15+
import {XLarge} from './x-large.directive';
1616

1717
describe('x-large directive', () => {
1818
// Create a test component to test directives
File renamed without changes.

src/app/home/providers/title.spec.ts src/app/providers/title.provider.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
beforeEachProviders,
66
TestComponentBuilder
77
} from 'angular2/testing';
8-
import {Title} from './title';
8+
import {Title} from './title.provider';
99

1010
describe('Title', () => {
1111
let title;
File renamed without changes.

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {HTTP_PROVIDERS} from 'angular2/http';
1010
* App Component
1111
* our top level component that holds all of our components
1212
*/
13-
import {App} from './app/app';
13+
import {AppCmp} from './app/components/app.component';
1414
/*
1515
* Bootstrap our Angular app with a top level component `App` and inject
1616
* our Services and Providers into Angular's dependency injection
1717
*/
1818
document.addEventListener('DOMContentLoaded', function main() {
19-
bootstrap(App, [
19+
bootstrap(AppCmp, [
2020
...('production' === process.env.ENV ? [] : ELEMENT_PROBE_PROVIDERS),
2121
...HTTP_PROVIDERS,
2222
...ROUTER_PROVIDERS,

tsconfig.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
"sourceMap": true
1010
},
1111
"files": [
12-
"typings/main.d.ts",
13-
"test/injector.spec.ts",
14-
"test/sanity-test.spec.ts",
15-
"src/app/app.spec.ts",
16-
"src/app/home/home.spec.ts",
17-
"src/app/home/directives/x-large.spec.ts",
18-
"src/app/home/providers/title.spec.ts",
19-
"src/main.ts",
20-
"src/vendor.ts"
12+
"./src/app/components/app.component.spec.ts",
13+
"./src/app/components/app.component.ts",
14+
"./src/app/components/home/home.component.spec.ts",
15+
"./src/app/components/home/home.component.ts",
16+
"./src/app/directives/x-large.directive.spec.ts",
17+
"./src/app/directives/x-large.directive.ts",
18+
"./src/app/providers/title.provider.spec.ts",
19+
"./src/app/providers/title.provider.ts",
20+
"./src/main.ts",
21+
"./src/vendor.ts",
22+
"./test/injector.spec.ts",
23+
"./test/sanity-test.spec.ts"
2124
],
2225
"filesGlob": [
2326
"./src/**/*.ts",
@@ -26,5 +29,7 @@
2629
],
2730
"compileOnSave": false,
2831
"buildOnSave": false,
29-
"atom": { "rewriteTsconfig": true }
32+
"atom": {
33+
"rewriteTsconfig": true
34+
}
3035
}

0 commit comments

Comments
 (0)