Skip to content

Commit 729f897

Browse files
committed
feat(gen:app): add eslint to the yo write stream
with `fix` enabled. Should automatically get rid of a lot of ESLint issues. fixes #2157
1 parent f1e7a87 commit 729f897

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"glob": "^7.0.5",
4545
"gulp-babel": "^6.1.2",
4646
"gulp-beautify": "^2.0.0",
47+
"gulp-eslint": "^3.0.1",
4748
"gulp-filter": "^4.0.0",
4849
"gulp-tap": "^0.1.3",
4950
"insight": "~0.8.3",

Diff for: src/generators/app/index.js

+12
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,6 +486,8 @@ export class Generator extends Base {
485486
babelPlugins.push('babel-plugin-transform-flow-strip-types');
486487
}
487488

489+
const genDir = path.join(__dirname, '../../');
490+
488491
let jsFilter = filter(['client/**/*.js'], {restore: true});
489492
this.registerTransformStream([
490493
jsFilter,
@@ -523,6 +526,15 @@ export class Generator extends Base {
523526
"wrap_attributes_indent_size": 4,
524527
"end_with_newline": true
525528
}),
529+
eslint({
530+
fix: true,
531+
configFile: path.join(genDir, 'templates/app/.eslintrc'),
532+
env: {
533+
es6: true,
534+
browser: true,
535+
commonjs: true
536+
}
537+
}),
526538
jsFilter.restore
527539
]);
528540

Diff for: templates/app/.eslintrc

+4-1
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

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

+1-4
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,<% } _%>

0 commit comments

Comments
 (0)