Skip to content

Commit 9f98f7c

Browse files
authored
Merge pull request #2158 from angular-fullstack/gen-run-eslint-fix
Fix ESLint errors
2 parents 34457bb + 231e500 commit 9f98f7c

File tree

27 files changed

+99
-75
lines changed

27 files changed

+99
-75
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"prepublish": "gulp build"
3636
},
3737
"dependencies": {
38+
"babel-eslint": "^6.1.2",
3839
"babel-plugin-syntax-class-properties": "^6.5.0",
3940
"babel-plugin-syntax-flow": "^6.5.0",
4041
"babel-plugin-transform-flow-strip-types": "^6.7.0",
@@ -44,6 +45,7 @@
4445
"glob": "^7.0.5",
4546
"gulp-babel": "^6.1.2",
4647
"gulp-beautify": "^2.0.0",
48+
"gulp-eslint": "^3.0.1",
4749
"gulp-filter": "^4.0.0",
4850
"gulp-tap": "^0.1.3",
4951
"insight": "~0.8.3",

src/generators/app/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import babelStream from 'gulp-babel';
1313
import beaufityStream from 'gulp-beautify';
1414
import tap from 'gulp-tap';
1515
import filter from 'gulp-filter';
16+
import eslint from 'gulp-eslint';
1617
import semver from 'semver';
1718

1819
export class Generator extends Base {
@@ -485,9 +486,11 @@ export class Generator extends Base {
485486
babelPlugins.push('babel-plugin-transform-flow-strip-types');
486487
}
487488

488-
let jsFilter = filter(['client/**/*.js'], {restore: true});
489+
const genDir = path.join(__dirname, '../../');
490+
491+
let clientJsFilter = filter(['client/**/*.js'], {restore: true});
489492
this.registerTransformStream([
490-
jsFilter,
493+
clientJsFilter,
491494
babelStream({
492495
plugins: babelPlugins.map(require.resolve),
493496
/* Babel get's confused about these if you're using an `npm link`ed
@@ -523,7 +526,11 @@ export class Generator extends Base {
523526
"wrap_attributes_indent_size": 4,
524527
"end_with_newline": true
525528
}),
526-
jsFilter.restore
529+
eslint({
530+
fix: true,
531+
configFile: path.join(genDir, 'templates/app/client/.eslintrc(babel)')
532+
}),
533+
clientJsFilter.restore
527534
]);
528535

529536
/**
@@ -563,6 +570,16 @@ export class Generator extends Base {
563570
]);
564571
}
565572

573+
let serverJsFilter = filter(['server/**/*.js'], {restore: true});
574+
this.registerTransformStream([
575+
serverJsFilter,
576+
eslint({
577+
fix: true,
578+
configFile: path.join(genDir, 'templates/app/server/.eslintrc')
579+
}),
580+
serverJsFilter.restore
581+
]);
582+
566583
let self = this;
567584
this.sourceRoot(path.join(__dirname, '../../templates/app'));
568585
this.processDirectory('.', '.');

templates/app/.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@
175175
"new-parens": 2, //disallow the omission of parentheses when invoking a constructor with no arguments
176176
"newline-after-var": 0, //require or disallow an empty newline after variable declarations
177177
"newline-before-return": 0, //require newline before return statement
178-
"newline-per-chained-call": 0, //enforce newline after each call when chaining the calls
178+
"newline-per-chained-call": [
179+
"error",
180+
{"ignoreChainWithDepth": 2}
181+
], //enforce newline after each call when chaining the calls
179182
"no-array-constructor": 2, //disallow use of the Array constructor
180183
"no-bitwise": 0, //disallow use of bitwise operators
181184
"no-continue": 0, //disallow use of the continue statement

templates/app/client/app/account(auth)/login/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import angular from 'angular';
23
import LoginController from './login.controller';
34

45
export default angular.module('<%= scriptAppName %>.login', [])

templates/app/client/app/account(auth)/settings/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import angular from 'angular';
23
import SettingsController from './settings.controller';
34

45
export default angular.module('<%= scriptAppName %>.settings', [])

templates/app/client/app/account(auth)/signup/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
2+
import angular from 'angular';
33
import SignupController from './signup.controller';
44

55
export default angular.module('<%= scriptAppName %>.signup', [])

templates/app/client/app/account(auth)/signup/signup.controller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22
// @flow
3+
import angular from 'angular';
4+
35
<%_ if(filters.flow) { -%>
46
type User = {
57
name: string;

templates/app/client/app/admin(auth)/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import angular from 'angular';
23
import routes from './admin.routes';
34
import AdminController from './admin.controller';
45

templates/app/client/app/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import uiRouter from 'angular-ui-router';<% } %>
1414
import uiBootstrap from 'angular-ui-bootstrap';<% } %>
1515
// import ngMessages from 'angular-messages';
1616
<%_ if(filters.auth) { _%>
17-
//import ngValidationMatch from 'angular-validation-match';<% } %>
17+
// import ngValidationMatch from 'angular-validation-match';<% } %>
1818

1919

2020
import {routeConfig} from './app.config';
@@ -35,7 +35,6 @@ import socket from '../components/socket/socket.service';<% } %>
3535
import './app.<%= styleExt %>';
3636

3737
angular.module('<%= scriptAppName %>', [
38-
// ngAnimate,
3938
ngCookies,
4039
ngResource,
4140
ngSanitize,
@@ -47,9 +46,7 @@ angular.module('<%= scriptAppName %>', [
4746
uiRouter,<% } _%>
4847
<%_ if(filters.uibootstrap) { %>
4948
uiBootstrap,<% } %>
50-
// ngMessages,
5149
<%_ if(filters.auth) { %>
52-
// ngValidationMatch,
5350
_Auth,
5451
account,
5552
admin,<% } _%>

templates/app/client/components/auth(auth)/auth.service.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
// @flow
3-
class User {
3+
class _User {
44
_id: string = '';
55
name: string = '';
66
email: string = '';
@@ -11,7 +11,7 @@ class User {
1111
export function AuthService($location, $http, $cookies, $q, appConfig, Util, User) {
1212
'ngInject';
1313
var safeCb = Util.safeCb;
14-
var currentUser: User = new User();
14+
var currentUser: _User = new _User();
1515
var userRoles = appConfig.userRoles || [];
1616
/**
1717
* Check if userRole is >= role
@@ -27,7 +27,6 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
2727
}
2828

2929
var Auth = {
30-
3130
/**
3231
* Authenticate user and save token
3332
*

0 commit comments

Comments
 (0)