Skip to content

Commit acb09d1

Browse files
committed
refactor(app): fix some ESLint issues
1 parent 96086d1 commit acb09d1

File tree

16 files changed

+43
-101
lines changed

16 files changed

+43
-101
lines changed

Diff for: src/test/get-expected-files.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function app(options) {
9090
'.babelrc',
9191
'.buildignore',
9292
'.editorconfig',
93+
'.eslintignore',
9394
'.eslintrc',
9495
'.gitattributes',
9596
'.gitignore',

Diff for: templates/app/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
client/components/socket/primus.js

Diff for: templates/app/client/.eslintrc(babel)

+6
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
"env": {
44
"browser": true,
55
"commonjs": true
6+
},
7+
"globals": {
8+
"process": true
9+
},
10+
"rules": {
11+
"no-process-env": 0
612
}
713
}

Diff for: templates/app/client/app/account(auth)/account.module.js

-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import { RouterModule, Routes } from '@angular/router';<% } %>
88
<%_ if(filters.oauth) { -%>
99
import { DirectivesModule } from '../../components/directives.module';<% } %>
1010

11-
<%_ if(filters.uirouter) { -%>
12-
import { STATES } from './account.routes';<% } %>
13-
1411
import { LoginComponent } from './login/login.component';
1512
import { SettingsComponent } from './settings/settings.component';
1613
import { SignupComponent } from './signup/signup.component';
@@ -19,7 +16,6 @@ import { SignupComponent } from './signup/signup.component';
1916
const accountRoutes: Routes = [{
2017
path: 'login',
2118
component: LoginComponent,
22-
//data: { title: 'Home' }
2319
}, {
2420
path: 'settings',
2521
component: SettingsComponent,

Diff for: templates/app/client/app/account(auth)/account.routes.js

-42
This file was deleted.

Diff for: templates/app/client/app/admin(auth)/admin.routes.js

-9
This file was deleted.

Diff for: templates/app/client/app/app.module.js

+13-25
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import {
22
NgModule,
3-
ErrorHandler,
43
Injectable,
5-
ApplicationRef,
6-
Provider,
4+
ApplicationRef,<% if(filters.ts || filters.flow) { %>
5+
Provider,<% } %>
76
} from '@angular/core';
87
import { BrowserModule } from '@angular/platform-browser';
98
import {
109
Http,
1110
HttpModule,
12-
BaseRequestOptions,
11+
BaseRequestOptions,<% if(filters.ts || filters.flow) { %>
1312
RequestOptions,
14-
RequestOptionsArgs,
13+
RequestOptionsArgs,<% } %>
1514
} from '@angular/http';
1615
import {
1716
removeNgStyles,
@@ -22,11 +21,10 @@ import {
2221
import { UIRouterModule } from 'ui-router-ng2';<% } %>
2322
<%_ if (filters.ngroute) { -%>
2423
import { RouterModule, Routes } from '@angular/router';<% } %>
25-
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
24+
import { AuthHttp, AuthConfig } from 'angular2-jwt';
2625

2726
import { AppComponent } from './app.component';
2827
import { MainModule } from './main/main.module';
29-
// import { MainComponent } from './main/main.component';
3028
import { DirectivesModule } from '../components/directives.module';
3129
import { AccountModule } from './account/account.module';
3230
import { AdminModule } from './admin/admin.module';
@@ -50,7 +48,7 @@ let providers: Provider[] = [{
5048
if(constants.env === 'development') {
5149
@Injectable()
5250
class HttpOptions extends BaseRequestOptions {
53-
merge(options/*:RequestOptionsArgs*/)/*:RequestOptions*/ {
51+
merge(options: RequestOptionsArgs):RequestOptions {
5452
options.url = `http://localhost:9000${options.url}`;
5553
return super.merge(options);
5654
}
@@ -59,20 +57,10 @@ if(constants.env === 'development') {
5957
providers.push({ provide: RequestOptions, useClass: HttpOptions });
6058
}
6159

62-
const appRoutes: Routes = [
63-
//{ path: 'crisis-center', component: CrisisListComponent },
64-
//{ path: 'hero/:id', component: HeroDetailComponent },
65-
// {
66-
// path: 'home',
67-
// component: MainComponent,
68-
// data: { title: 'Home' }
69-
// },
70-
{ path: '',
71-
redirectTo: '/home',
72-
pathMatch: 'full'
73-
},
74-
//{ path: '**', component: PageNotFoundComponent }
75-
];
60+
const appRoutes: Routes = [{ path: '',
61+
redirectTo: '/home',
62+
pathMatch: 'full'
63+
}];
7664

7765
@NgModule({
7866
providers,
@@ -110,8 +98,8 @@ export class AppModule {
11098
}
11199
// change detection
112100
this.appRef.tick();
113-
delete store.state;
114-
delete store.restoreInputValues;
101+
Reflect.deleteProperty(store, 'state');
102+
Reflect.deleteProperty(store, 'restoreInputValues');
115103
}
116104

117105
hmrOnDestroy(store) {
@@ -131,7 +119,7 @@ export class AppModule {
131119
hmrAfterDestroy(store) {
132120
// display new elements
133121
store.disposeOldHosts()
134-
delete store.disposeOldHosts;
122+
Reflect.deleteProperty(store, 'disposeOldHosts');
135123
// anything you need done the component is removed
136124
}
137125
}

Diff for: templates/app/client/components/auth(auth)/auth.service.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { Injectable, EventEmitter, Output } from '@angular/core';
2-
import { Response } from '@angular/http';
32
import { AuthHttp } from 'angular2-jwt';
43
import { UserService } from './user.service';
54
import { Http } from '@angular/http';
6-
import { Observable } from 'rxjs/Observable';
75
import 'rxjs/add/operator/toPromise';
86
import { safeCb, extractData } from '../util';
97
import constants from '../../app/app.constants';

Diff for: templates/app/client/components/navbar/navbar.component.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ export class NavbarComponent {
5353
}
5454

5555
logout() {
56-
let promise = this.AuthService.logout();
57-
<%_ if(filters.uirouter) { -%>
58-
this.StateService.go('login');<% } -%>
59-
<%_ if(filters.ngroute) { -%>
60-
this.Router.navigateByUrl('/home');<% } -%>
56+
let promise = this.AuthService.logout();<% if(filters.uirouter) { %>
57+
this.StateService.go('login');<% } %><% if(filters.ngroute) { %>
58+
this.Router.navigateByUrl('/home');<% } %>
6159
return promise;
6260
}<% } -%>
6361
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
export class SocketServiceStub {
4-
constructor() {}
54
syncUpdates() {}
65
unsyncUpdates() {}
76
}

Diff for: templates/app/server/api/user(auth)/user.model(mongooseModels).js

+7-5
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,16 @@ UserSchema.methods = {
197197
* @return {String}
198198
* @api public
199199
*/
200-
makeSalt(byteSize, callback) {
200+
makeSalt(...args) {
201201
var defaultByteSize = 16;
202+
let byteSize;
203+
let callback;
202204

203-
if(typeof arguments[0] === 'function') {
204-
callback = arguments[0];
205+
if(typeof args[0] === 'function') {
206+
callback = args[0];
205207
byteSize = defaultByteSize;
206-
} else if(typeof arguments[1] === 'function') {
207-
callback = arguments[1];
208+
} else if(typeof args[1] === 'function') {
209+
callback = args[1];
208210
} else {
209211
throw new Error('Missing Callback');
210212
}

Diff for: templates/app/server/api/user(auth)/user.model(sequelizeModels).js

+7-5
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ export default function(sequelize, DataTypes) {
135135
* @return {String}
136136
* @api public
137137
*/
138-
makeSalt(byteSize, callback) {
138+
makeSalt(...args) {
139139
var defaultByteSize = 16;
140+
let byteSize;
141+
let callback;
140142

141-
if(typeof arguments[0] === 'function') {
142-
callback = arguments[0];
143+
if(typeof args[0] === 'function') {
144+
callback = args[0];
143145
byteSize = defaultByteSize;
144-
} else if(typeof arguments[1] === 'function') {
145-
callback = arguments[1];
146+
} else if(typeof args[1] === 'function') {
147+
callback = args[1];
146148
} else {
147149
throw new Error('Missing Callback');
148150
}

Diff for: templates/app/server/config/environment/shared.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
/*eslint no-process-env:0*/
23

34
module.exports.default = {
45
env: process.env.NODE_ENV,

Diff for: templates/app/server/config/express.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function(app) {
7272
* Lusca - express server security
7373
* https://github.com/krakenjs/lusca
7474
*/
75-
if(env !== 'test' && env !== 'development' && !process.env.SAUCE_USERNAME) {
75+
if(env !== 'test' && env !== 'development' && !process.env.SAUCE_USERNAME) { // eslint-disable-line no-process-env
7676
app.use(lusca({
7777
csrf: true,
7878
xframe: 'SAMEORIGIN',

Diff for: templates/app/server/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
/*eslint no-process-env:0*/
23

34
// Set default node environment to development
45
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';

Diff for: templates/endpoint/basename.controller.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function create(req, res) {
9696
// Upserts the given <%= classedName %> in the DB at the specified ID
9797
export function upsert(req, res) {
9898
if(req.body._id) {
99-
delete req.body._id;
99+
Reflect.deleteProperty(req.body, '_id');
100100
}
101101
<%_ if(filters.mongooseModels) { -%>
102102
return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %>
@@ -113,7 +113,7 @@ export function upsert(req, res) {
113113
// Updates an existing <%= classedName %> in the DB
114114
export function patch(req, res) {
115115
if(req.body._id) {
116-
delete req.body._id;
116+
Reflect.deleteProperty(req.body, '_id');
117117
}
118118
<% if(filters.mongooseModels) { %>return <%= classedName %>.findById(req.params.id).exec()<% }
119119
if(filters.sequelizeModels) { %>return <%= classedName %>.find({

0 commit comments

Comments
 (0)