Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit 60e1d70

Browse files
richavyaskyleledbetter
authored andcommitted
chore(): Lint rule and fixes (#35)
* lint rule modified; fixes * modified files based on angular style guide rule * update(user-form): proper regex pattern for emails - so form could validate
1 parent 39541d7 commit 60e1d70

26 files changed

+72
-67
lines changed

mock-api/schemas/users.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
---
44
initial_entries: 5
55
randomize: false
6-
display_name: _firstname_ _lastname_
6+
displayName: _firstname_ _lastname_
77
id: _firstname_._lastname_
88
email: _firstname_._lastname_@_company_.com
99
created: _createdtimestamp_
10-
last_access: _itemtimestamp_
11-
site_admin: _admin_
10+
lastAccess: _itemtimestamp_
11+
siteAdmin: _admin_
1212
...

src/app/dashboard-product/dashboard-product.component.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ describe('Component: DashboardProduct', () => {
7474
})));
7575
responses.set('data/users.json', new Response(new ResponseOptions({
7676
status: 200, body: JSON.stringify([{
77-
display_name : 'Suzy Cuningham',
77+
displayName : 'Suzy Cuningham',
7878
id : 'suzy.cuningham',
7979
email : '[email protected]',
8080
created : '10/01/2015 11:05 AM',
81-
last_access : '12/23/2015 11:05 AM',
82-
site_admin: true,
81+
lastAccess : '12/23/2015 11:05 AM',
82+
siteAdmin: true,
8383
}, {
84-
display_name : 'Bobby Daniels',
84+
displayName : 'Bobby Daniels',
8585
id : 'bobbyD',
8686
email : '[email protected]',
8787
created : '10/01/2015 11:05 AM',
88-
last_access : '12/23/2015 11:05 AM',
89-
site_admin: false,
88+
lastAccess : '12/23/2015 11:05 AM',
89+
siteAdmin: false,
9090
}]),
9191
})));
9292

src/app/dashboard-product/dashboard-product.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Title } from '@angular/platform-browser';
55
import { TdMediaService } from '@covalent/core';
66

77
@Component({
8-
selector: 'dashboard-product',
8+
selector: 'qs-dashboard-product',
99
templateUrl: './dashboard-product.component.html',
1010
styleUrls: ['./dashboard-product.component.scss'],
1111
})

src/app/dashboard-product/features/+form/form.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router';
55
import { FeaturesService, IFeature } from '../../../../services';
66

77
@Component({
8-
selector: 'feature-form',
8+
selector: 'qs-feature-form',
99
templateUrl: './form.component.html',
1010
styleUrls: ['./form.component.scss'],
1111
viewProviders: [ FeaturesService ],

src/app/dashboard-product/features/features.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { TdDialogService } from '@covalent/core';
77
import { FeaturesService, IFeature } from '../../../services';
88

99
@Component({
10-
selector: 'product-features',
10+
selector: 'qs-product-features',
1111
templateUrl: './features.component.html',
1212
styleUrls: ['./features.component.scss'],
1313
viewProviders: [ FeaturesService ],

src/app/dashboard-product/overview/overview.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h3 md-line> {{item.name}} </h3>
7171
<template let-user let-last="last" ngFor [ngForOf]="users">
7272
<md-list-item layout-align="row">
7373
<md-icon md-list-icon>account_box</md-icon>
74-
<h3 md-line> {{user.display_name}} </h3>
74+
<h3 md-line> {{user.displayName}} </h3>
7575
<p md-line> {{user.id}} </p>
7676
</md-list-item>
7777
<md-divider *ngIf="!last" md-inset></md-divider>

src/app/dashboard-product/overview/overview.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TdLoadingService } from '@covalent/core';
66
import { ItemsService, UsersService } from '../../../services';
77

88
@Component({
9-
selector: 'product-overview',
9+
selector: 'qs-product-overview',
1010
templateUrl: './overview.component.html',
1111
styleUrls: ['./overview.component.scss'],
1212
viewProviders: [ ItemsService, UsersService ],

src/app/dashboard-product/stats/stats.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const NUMBER_FORMAT: any = (v: {value: number}) => v.value;
88
const DECIMAL_FORMAT: any = (v: {value: number}) => v.value.toFixed(2);
99

1010
@Component({
11-
selector: 'product-stats',
11+
selector: 'qs-product-stats',
1212
templateUrl: './stats.component.html',
1313
styleUrls: ['./stats.component.scss'],
1414
})

src/app/dashboard/dashboard.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ItemsService, UsersService, ProductsService, AlertsService } from '../.
99
import { multi } from './data';
1010

1111
@Component({
12-
selector: 'covalent-dashboard',
12+
selector: 'qs-dashboard',
1313
templateUrl: './dashboard.component.html',
1414
styleUrls: ['./dashboard.component.scss'],
1515
viewProviders: [ ItemsService, UsersService, ProductsService, AlertsService ],

src/app/dashboard/data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export var single: any = [
1+
export let single: any = [
22
{
33
'name': 'Germany',
44
'value': 8940000,
@@ -13,7 +13,7 @@ export var single: any = [
1313
},
1414
];
1515

16-
export var multi: any = [
16+
export let multi: any = [
1717
{
1818
'name': 'Container Apps',
1919
'series': [

src/app/form/form.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, AfterViewInit } from '@angular/core';
33
import { StepState, TdMediaService } from '@covalent/core';
44

55
@Component({
6-
selector: 'product-form',
6+
selector: 'qs-product-form',
77
templateUrl: './form.component.html',
88
styleUrls: ['./form.component.scss'],
99
})

src/app/templates/dashboard/dashboard.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component } from '@angular/core';
33
import { single, multi } from './data';
44

55
@Component({
6-
selector: 'covalent-dashboard',
6+
selector: 'qs-dashboard',
77
templateUrl: './dashboard.component.html',
88
styleUrls: ['./dashboard.component.scss'],
99
})

src/app/templates/dashboard/data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export var single: any = [
1+
export let single: any = [
22
{
33
'name': 'Germany',
44
'value': 8940000,
@@ -13,7 +13,7 @@ export var single: any = [
1313
},
1414
];
1515

16-
export var multi: any = [
16+
export let multi: any = [
1717
{
1818
'name': 'Containers',
1919
'series': [

src/app/templates/editor/data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export var single: any = [
1+
export let single: any = [
22
{
33
'name': 'Germany',
44
'value': 8940000,
@@ -13,7 +13,7 @@ export var single: any = [
1313
},
1414
];
1515

16-
export var multi: any = [
16+
export let multi: any = [
1717
{
1818
'name': 'Containers',
1919
'series': [

src/app/templates/editor/editor.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const DECIMAL_FORMAT: any = (v: {value: number}) => v.value.toFixed(2);
1111
import { multi } from './data';
1212

1313
@Component({
14-
selector: 'covalent-editor',
14+
selector: 'qs-editor',
1515
templateUrl: './editor.component.html',
1616
styleUrls: ['./editor.component.scss'],
1717
})

src/app/templates/email/email.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, AfterViewInit } from '@angular/core';
33
import { TdMediaService } from '@covalent/core';
44

55
@Component({
6-
selector: 'covalent-email',
6+
selector: 'qs-email',
77
templateUrl: './email.component.html',
88
styleUrls: ['./email.component.scss'],
99
})

src/app/templates/templates.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: 'covalent-templates',
4+
selector: 'qs-templates',
55
templateUrl: './templates.component.html',
66
styleUrls: ['./templates.component.scss'],
77
})

src/app/users/+form/form.component.html

+10-5
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@
4949
#displayNameControl="ngModel"
5050
type="text"
5151
placeholder="Display Name"
52-
[(ngModel)]="display_name"
53-
name="display_name"
52+
[(ngModel)]="displayName"
53+
name="displayName"
5454
maxlength="20"
5555
required>
5656
<md-hint align="start">
57-
<span [hidden]="displayNameControl.pristine || !displayNameControl.errors?.required" class="tc-red-600">Display Name is required!</span>
57+
<span [hidden]="displayNameControl.pristine" class="tc-red-600">
58+
<span [hidden]="!displayNameControl.errors?.required">Required</span>
59+
</span>
5860
</md-hint>
5961
<md-hint align="end">{{displayNameElement.value.length}} / 20</md-hint>
6062
</md-input-container>
@@ -69,10 +71,13 @@
6971
[(ngModel)]="email"
7072
name="email"
7173
maxlength="30"
72-
pattern="^\w+@\w+$"
74+
pattern="^[a-zA-Z0-9]+(\.[_a-zA-Z0-9]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,15})$"
7375
required>
7476
<md-hint align="start">
75-
<span [hidden]="emailControl.pristine || !emailControl.errors?.pattern" class="tc-red-600">That's not an email!</span>
77+
<span [hidden]="emailControl.pristine" class="tc-red-600">
78+
<span [hidden]="!emailControl.errors?.required">Required</span>
79+
<span [hidden]="!emailControl.errors?.pattern">incorrect pattern</span>
80+
</span>
7681
</md-hint>
7782
<md-hint align="end">{{emailElement.value.length}} / 30</md-hint>
7883
</md-input-container>

src/app/users/+form/form.component.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { TdMediaService } from '@covalent/core';
77
import { UsersService, IUser } from '../../../services';
88

99
@Component({
10-
selector: 'source-form',
10+
selector: 'qs-user-form',
1111
templateUrl: './form.component.html',
1212
styleUrls: ['./form.component.scss'],
1313
viewProviders: [ UsersService ],
1414
})
1515
export class UsersFormComponent implements OnInit, AfterViewInit {
1616

17-
display_name: string;
17+
displayName: string;
1818
email: string;
1919
id: string;
2020
admin: boolean;
@@ -41,24 +41,24 @@ export class UsersFormComponent implements OnInit, AfterViewInit {
4141
this._route.params.subscribe((params: {id: string}) => {
4242
let userId: string = params.id;
4343
this._usersService.get(userId).subscribe((user: any) => {
44-
this.display_name = user.display_name;
44+
this.displayName = user.displayName;
4545
this.email = user.email;
46-
this.admin = (user.site_admin === 1 ? true : false);
46+
this.admin = (user.siteAdmin === 1 ? true : false);
4747
this.id = user.id;
4848
});
4949
});
5050
}
5151

5252
save(): void {
53-
let site_admin: number = (this.admin ? 1 : 0);
53+
let siteAdmin: number = (this.admin ? 1 : 0);
5454
let now: Date = new Date();
5555
this.user = {
56-
display_name: this.display_name,
56+
displayName: this.displayName,
5757
email: this.email,
58-
site_admin: site_admin,
59-
id: this.id || this.display_name.replace(/\s+/g, '.'),
58+
siteAdmin: siteAdmin,
59+
id: this.id || this.displayName.replace(/\s+/g, '.'),
6060
created: now,
61-
last_access: now,
61+
lastAccess: now,
6262
};
6363
if (this.action === 'add') {
6464
this._usersService.create(this.user).subscribe(() => {

src/app/users/users.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ <h3>No users to display.</h3>
5656
<template let-user let-last="last" ngFor [ngForOf]="filteredUsers">
5757
<md-list-item>
5858
<md-icon md-list-avatar>person</md-icon>
59-
<h3 md-line> {{user.display_name}} </h3>
59+
<h3 md-line> {{user.displayName}} </h3>
6060
<p md-line> {{user.email}} </p>
61-
<p md-line hide-gt-md class="md-caption"> last login: {{ user.last_access | timeAgo }} </p>
61+
<p md-line hide-gt-md class="md-caption"> last login: {{ user.lastAccess | timeAgo }} </p>
6262
<span flex></span>
6363
<span hide-xs hide-sm hide-md flex-gt-xs="60" flex-xs="40" layout-gt-xs="row">
6464
<div class="md-caption tc-grey-500" flex-gt-xs="50"> {{ user.created | date }} </div>
65-
<div class="md-caption tc-grey-500" flex-gt-xs="50"> {{ user.last_access | timeAgo }} </div>
65+
<div class="md-caption tc-grey-500" flex-gt-xs="50"> {{ user.lastAccess | timeAgo }} </div>
6666
</span>
6767
<span>
6868
<button md-icon-button [md-menu-trigger-for]="menu">

src/app/users/users.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class UsersComponent implements AfterViewInit {
4141

4242
filterUsers(displayName: string = ''): void {
4343
this.filteredUsers = this.users.filter((user: IUser) => {
44-
return user.display_name.toLowerCase().indexOf(displayName.toLowerCase()) > -1;
44+
return user.displayName.toLowerCase().indexOf(displayName.toLowerCase()) > -1;
4545
});
4646
}
4747

src/components/chart/chart.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: 'chart-component',
4+
selector: 'qs-chart-component',
55
templateUrl: './chart.component.html',
66
styleUrls: ['./chart.component.scss'],
77
})

src/data/users.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
[
22
{
3-
"display_name" : "Suzy Cuningham",
3+
"displayName" : "Suzy Cuningham",
44
"id" : "suzy.cuningham",
55
"email" : "[email protected]",
66
"created" : "10/01/2015 11:05 AM",
7-
"last_access" : "12/23/2015 11:05 AM",
8-
"site_admin": true
7+
"lastAccess" : "12/23/2015 11:05 AM",
8+
"siteAdmin": true
99
},
1010
{
11-
"display_name" : "Bobby Daniels",
11+
"displayName" : "Bobby Daniels",
1212
"id" : "bobbyD",
1313
"email" : "[email protected]",
1414
"created" : "10/01/2015 11:05 AM",
15-
"last_access" : "12/23/2015 11:05 AM",
16-
"site_admin": false
15+
"lastAccess" : "12/23/2015 11:05 AM",
16+
"siteAdmin": false
1717
},
1818
{
19-
"display_name" : "John Walker",
19+
"displayName" : "John Walker",
2020
"id" : "johnnyWalker",
2121
"email" : "[email protected]",
2222
"created" : "10/01/2015 11:05 AM",
23-
"last_access" : "12/23/2015 11:05 AM",
24-
"site_admin": false
23+
"lastAccess" : "12/23/2015 11:05 AM",
24+
"siteAdmin": false
2525
},
2626
{
27-
"display_name" : "Eddy Stevens",
27+
"displayName" : "Eddy Stevens",
2828
"id" : "eStevens",
2929
"email" : "[email protected]",
3030
"created" : "10/01/2015 11:05 AM",
31-
"last_access" : "12/23/2015 11:05 AM",
32-
"site_admin": false
31+
"lastAccess" : "12/23/2015 11:05 AM",
32+
"siteAdmin": false
3333
},
3434
{
35-
"display_name" : "Jan Williams",
35+
"displayName" : "Jan Williams",
3636
"id" : "jDubz",
3737
"email" : "[email protected]",
3838
"created" : "10/01/2015 11:05 AM",
39-
"last_access" : "12/23/2015 11:05 AM",
40-
"site_admin": false
39+
"lastAccess" : "12/23/2015 11:05 AM",
40+
"siteAdmin": false
4141
}
4242
]

src/services/users.service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { HttpInterceptorService, RESTService } from '@covalent/http';
66
import { MOCK_API } from '../config/api.config';
77

88
export interface IUser {
9-
display_name: string;
9+
displayName: string;
1010
id: string;
1111
email: string;
1212
created: Date;
13-
last_access: Date;
14-
site_admin: number;
13+
lastAccess: Date;
14+
siteAdmin: number;
1515
}
1616

1717
@Injectable()

src/test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Promise.all([
2222
.then(([testing, testingBrowser]: any[]) => {
2323
testing.getTestBed().initTestEnvironment(
2424
testingBrowser.BrowserDynamicTestingModule,
25-
testingBrowser.platformBrowserDynamicTesting()
25+
testingBrowser.platformBrowserDynamicTesting(),
2626
);
2727
})
2828
// Then we find all the tests.

0 commit comments

Comments
 (0)