Skip to content

Commit

Permalink
feat(gen:app): add eslint to the yo write stream
Browse files Browse the repository at this point in the history
with `fix` enabled. Should automatically get rid of a lot of ESLint issues.

fixes #2157
  • Loading branch information
Awk34 committed Aug 17, 2016
1 parent f1e7a87 commit 85921be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"prepublish": "gulp build"
},
"dependencies": {
"babel-eslint": "^6.1.2",
"babel-plugin-syntax-class-properties": "^6.5.0",
"babel-plugin-syntax-flow": "^6.5.0",
"babel-plugin-transform-flow-strip-types": "^6.7.0",
Expand All @@ -44,6 +45,7 @@
"glob": "^7.0.5",
"gulp-babel": "^6.1.2",
"gulp-beautify": "^2.0.0",
"gulp-eslint": "^3.0.1",
"gulp-filter": "^4.0.0",
"gulp-tap": "^0.1.3",
"insight": "~0.8.3",
Expand Down
12 changes: 12 additions & 0 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import babelStream from 'gulp-babel';
import beaufityStream from 'gulp-beautify';
import tap from 'gulp-tap';
import filter from 'gulp-filter';
import eslint from 'gulp-eslint';
import semver from 'semver';

export class Generator extends Base {
Expand Down Expand Up @@ -485,6 +486,8 @@ export class Generator extends Base {
babelPlugins.push('babel-plugin-transform-flow-strip-types');
}

const genDir = path.join(__dirname, '../../');

let jsFilter = filter(['client/**/*.js'], {restore: true});
this.registerTransformStream([
jsFilter,
Expand Down Expand Up @@ -523,6 +526,15 @@ export class Generator extends Base {
"wrap_attributes_indent_size": 4,
"end_with_newline": true
}),
eslint({
fix: true,
configFile: path.join(genDir, 'templates/app/.eslintrc'),
env: {
es6: true,
browser: true,
commonjs: true
}
}),
jsFilter.restore
]);

Expand Down
5 changes: 4 additions & 1 deletion templates/app/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@
"new-parens": 2, //disallow the omission of parentheses when invoking a constructor with no arguments
"newline-after-var": 0, //require or disallow an empty newline after variable declarations
"newline-before-return": 0, //require newline before return statement
"newline-per-chained-call": 0, //enforce newline after each call when chaining the calls
"newline-per-chained-call": [
"error",
{"ignoreChainWithDepth": 2}
], //enforce newline after each call when chaining the calls
"no-array-constructor": 2, //disallow use of the Array constructor
"no-bitwise": 0, //disallow use of bitwise operators
"no-continue": 0, //disallow use of the continue statement
Expand Down
5 changes: 1 addition & 4 deletions templates/app/client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import uiRouter from 'angular-ui-router';<% } %>
import uiBootstrap from 'angular-ui-bootstrap';<% } %>
// import ngMessages from 'angular-messages';
<%_ if(filters.auth) { _%>
//import ngValidationMatch from 'angular-validation-match';<% } %>
// import ngValidationMatch from 'angular-validation-match';<% } %>
import {routeConfig} from './app.config';
Expand All @@ -35,7 +35,6 @@ import socket from '../components/socket/socket.service';<% } %>
import './app.<%= styleExt %>';

angular.module('<%= scriptAppName %>', [
// ngAnimate,
ngCookies,
ngResource,
ngSanitize,
Expand All @@ -47,9 +46,7 @@ angular.module('<%= scriptAppName %>', [
uiRouter,<% } _%>
<%_ if(filters.uibootstrap) { %>
uiBootstrap,<% } %>
// ngMessages,
<%_ if(filters.auth) { %>
// ngValidationMatch,
_Auth,
account,
admin,<% } _%>
Expand Down

0 comments on commit 85921be

Please sign in to comment.