Skip to content

Commit 8bb4600

Browse files
dhergeskatallaxie
authored andcommitted
Adjustments to the Angular 2 Style Guide (PatrickJS#1091)
* Component class names follow the style guide * Filenames of services, components, and directives follow the style guide
1 parent 1992220 commit 8bb4600

14 files changed

+36
-36
lines changed

src/app/+detail/detail.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Component } from '@angular/core';
77
<router-outlet></router-outlet>
88
`
99
})
10-
export class Detail {
10+
export class DetailComponent {
1111
constructor() {
1212

1313
}

src/app/+detail/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import { FormsModule } from '@angular/forms';
33
import { NgModule } from '@angular/core';
44
import { RouterModule } from '@angular/router';
55

6-
import { Detail } from './detail.component';
6+
import { DetailComponent } from './detail.component';
77

88
console.log('`Detail` bundle loaded asynchronously');
99
// async components must be named routes for WebpackAsyncRoute
1010
export const routes = [
11-
{ path: '', component: Detail, pathMatch: 'full' }
11+
{ path: '', component: DetailComponent, pathMatch: 'full' }
1212
];
1313

1414
@NgModule({
1515
declarations: [
1616
// Components / Directives/ Pipes
17-
Detail
17+
DetailComponent
1818
],
1919
imports: [
2020
CommonModule,

src/app/about/about.spec.ts renamed to src/app/about/about.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component } from '@angular/core';
33
import { inject, TestBed } from '@angular/core/testing';
44

55
// Load the implementations that should be tested
6-
import { About } from './about.component';
6+
import { AboutComponent } from './about.component';
77

88
describe('About', () => {
99
// provide our implementations or mocks to the dependency injector
@@ -20,11 +20,11 @@ describe('About', () => {
2020
}
2121
}
2222
},
23-
About
23+
AboutComponent
2424
]
2525
}));
2626

27-
it('should log ngOnInit', inject([About], (about: About) => {
27+
it('should log ngOnInit', inject([AboutComponent], (about: AboutComponent) => {
2828
spyOn(console, 'log');
2929
expect(console.log).not.toHaveBeenCalled();
3030

src/app/about/about.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ console.log('`About` component loaded asynchronously');
2626
<pre>this.localState = {{ localState | json }}</pre>
2727
`
2828
})
29-
export class About {
29+
export class AboutComponent {
3030
localState: any;
3131
constructor(public route: ActivatedRoute) {
3232

src/app/app.spec.ts renamed to src/app/app.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import {
44
} from '@angular/core/testing';
55

66
// Load the implementations that should be tested
7-
import { App } from './app.component';
7+
import { AppComponent } from './app.component';
88
import { AppState } from './app.service';
99

1010
describe('App', () => {
1111
// provide our implementations or mocks to the dependency injector
1212
beforeEach(() => TestBed.configureTestingModule({
1313
providers: [
1414
AppState,
15-
App
15+
AppComponent
1616
]}));
1717

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

src/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { AppState } from './app.service';
5858
</footer>
5959
`
6060
})
61-
export class App {
61+
export class AppComponent {
6262
angularclassLogo = 'assets/img/angularclass-avatar.png';
6363
name = 'Angular 2 Webpack Starter';
6464
url = 'https://twitter.com/AngularClass';

src/app/app.module.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularcla
1111
import { ENV_PROVIDERS } from './environment';
1212
import { ROUTES } from './app.routes';
1313
// App is our top level component
14-
import { App } from './app.component';
14+
import { AppComponent } from './app.component';
1515
import { APP_RESOLVER_PROVIDERS } from './app.resolver';
1616
import { AppState, InternalStateType } from './app.service';
17-
import { Home } from './home';
18-
import { About } from './about';
19-
import { NoContent } from './no-content';
17+
import { HomeComponent } from './home';
18+
import { AboutComponent } from './about';
19+
import { NoContentComponent } from './no-content';
2020
import { XLarge } from './home/x-large';
2121

2222
// Application wide providers
@@ -35,12 +35,12 @@ type StoreType = {
3535
* `AppModule` is the main entry point into Angular2's bootstraping process
3636
*/
3737
@NgModule({
38-
bootstrap: [ App ],
38+
bootstrap: [ AppComponent ],
3939
declarations: [
40-
App,
41-
About,
42-
Home,
43-
NoContent,
40+
AppComponent,
41+
AboutComponent,
42+
HomeComponent,
43+
NoContentComponent,
4444
XLarge
4545
],
4646
imports: [ // import Angular's modules

src/app/app.routes.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Routes, RouterModule } from '@angular/router';
2-
import { Home } from './home';
3-
import { About } from './about';
4-
import { NoContent } from './no-content';
2+
import { HomeComponent } from './home';
3+
import { AboutComponent } from './about';
4+
import { NoContentComponent } from './no-content';
55

66
import { DataResolver } from './app.resolver';
77

88

99
export const ROUTES: Routes = [
10-
{ path: '', component: Home },
11-
{ path: 'home', component: Home },
12-
{ path: 'about', component: About },
10+
{ path: '', component: HomeComponent },
11+
{ path: 'home', component: HomeComponent },
12+
{ path: 'about', component: AboutComponent },
1313
{
1414
path: 'detail', loadChildren: () => System.import('./+detail')
1515
},
16-
{ path: '**', component: NoContent },
16+
{ path: '**', component: NoContentComponent },
1717
];

src/app/home/home.spec.ts renamed to src/app/home/home.component.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { MockBackend } from '@angular/http/testing';
1212

1313
// Load the implementations that should be tested
1414
import { AppState } from '../app.service';
15-
import { Home } from './home.component';
15+
import { HomeComponent } from './home.component';
1616
import { Title } from './title';
1717

1818
describe('Home', () => {
@@ -30,19 +30,19 @@ describe('Home', () => {
3030
},
3131
AppState,
3232
Title,
33-
Home
33+
HomeComponent
3434
]
3535
}));
3636

37-
it('should have default data', inject([ Home ], (home: Home) => {
37+
it('should have default data', inject([ HomeComponent ], (home: HomeComponent) => {
3838
expect(home.localState).toEqual({ value: '' });
3939
}));
4040

41-
it('should have a title', inject([ Home ], (home: Home) => {
41+
it('should have a title', inject([ HomeComponent ], (home: HomeComponent) => {
4242
expect(!!home.title).toEqual(true);
4343
}));
4444

45-
it('should log ngOnInit', inject([ Home ], (home: Home) => {
45+
it('should log ngOnInit', inject([ HomeComponent ], (home: HomeComponent) => {
4646
spyOn(console, 'log');
4747
expect(console.log).not.toHaveBeenCalled();
4848

src/app/home/home.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { XLarge } from './x-large';
1818
// Every Angular template is first compiled by the browser before Angular runs it's compiler
1919
templateUrl: './home.component.html'
2020
})
21-
export class Home {
21+
export class HomeComponent {
2222
// Set our default values
2323
localState = { value: '' };
2424
// TypeScript public modifiers

src/app/no-content/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './no-content';
1+
export * from './no-content.component';

src/app/no-content/no-content.ts renamed to src/app/no-content/no-content.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import { Component } from '@angular/core';
88
</div>
99
`
1010
})
11-
export class NoContent {
11+
export class NoContentComponent {
1212

1313
}

0 commit comments

Comments
 (0)