Skip to content

Commit b26b553

Browse files
committed
Init ESLint support
1 parent 19b1268 commit b26b553

File tree

10 files changed

+53
-6
lines changed

10 files changed

+53
-6
lines changed

generators/app/prompts.json

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
"message": "Would you like to include Moment.js - Library for parse, validate, manipulate, and display dates in JavaScript.",
149149
"default": true
150150
},
151+
{
152+
"type": "confirm",
153+
"name": "eslint",
154+
"message": "Would you like to include ESLint - A configurable linter tool for identifying and reporting on patterns in your JavaScript code.",
155+
"default": true
156+
},
151157
{
152158
"type": "confirm",
153159
"name": "ocLazyLoad",

generators/app/src/files.js

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ module.exports = function (AngularWebpackES6Generator) {
3333
this.templatePath('_.babelrc'),
3434
this.destinationPath('.babelrc')
3535
);
36+
this.fs.copy(
37+
this.templatePath('_.eslintrc.json'),
38+
this.destinationPath('.eslintrc.json')
39+
);
3640

3741
this.fs.copyTpl(
3842
this.templatePath('_config/**/*'),

generators/app/src/install.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module.exports = function (AngularWebpackES6Generator) {
2424
deps.push("moment");
2525
}
2626

27+
if (this.props.eslint) {
28+
deps.push('eslint', 'eslint-loader');
29+
}
30+
2731
deps = _.concat(deps, this.installList);
2832

2933
this.npmInstall(deps, { 'save': true });
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
5+
},
6+
"extends": "eslint:recommended",
7+
"rules": {
8+
"eqeqeq": "warn",
9+
"no-fallthrough": "off",
10+
"no-shadow": "warn",
11+
"arrow-body-style": ["warn", "as-needed"],
12+
"arrow-parens": ["warn", "as-needed"],
13+
"no-var": "error"
14+
},
15+
"globals": {
16+
"angular": false
17+
},
18+
"env": {
19+
"browser": true,
20+
"node": true
21+
}
22+
}

generators/app/templates/_config/webpack/global.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@ module.exports = function (_path) {
5757
}
5858
}
5959
]
60-
}, {
60+
},<% if (props.eslint) { %> {
61+
test: /\.js$/,
62+
exclude: [
63+
path.resolve(_path, "node_modules")
64+
],
65+
enforce: 'pre',
66+
use: [
67+
{
68+
loader: 'eslint-loader'
69+
}
70+
]
71+
},<% } %> {
6172
test: /\.js$/,
6273
exclude: [
6374
path.resolve(_path, "node_modules")

generators/app/templates/_src/_app/_components/_footer/footer.directive.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import footerTpl from './footer.html';
55
function footerComponent($log) {
66
'ngInject';
77

8-
var directive = {
8+
const directive = {
99
restrict: 'E',
1010
templateUrl: footerTpl,
1111
controller: FooterController,
@@ -16,7 +16,7 @@ function footerComponent($log) {
1616
return directive;
1717

1818
function FooterController () {
19-
$log.debug('Hello from footer controller!');
19+
$log.debug('Hello from footer controller!');
2020
}
2121

2222
}

generators/app/templates/_src/_app/_core/_directives/validation-test/validation-test.directive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function (app) {
1414
};
1515

1616
function linkFn (scope, elem, attrs, ngModelCtrl) {
17-
scope.$watch(attrs.ngModel, (newVal) => {
17+
scope.$watch(attrs.ngModel, newVal => {
1818
if (newVal === 'test') {
1919
ngModelCtrl.$setValidity('test', true);
2020
} else {

generators/app/templates/_src/_app/_core/_services/resolver.provider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function (app) {
2626
function asyncPagePrealoading ($q) {
2727
"ngInject";
2828

29-
var defer = $q.defer();
29+
const defer = $q.defer();
3030
// Some async stuff (request, calculations, etc.)
3131
return defer.promise;
3232
}

generators/app/templates/_src/_app/_index.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global NODE_ENV*/
12
'use strict';
23

34
function config($logProvider, $compileProvider) {

generators/app/templates/_src/_app/_index.module.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
import components from './index.components';
43
import config from './index.config';
54
import run from './index.run';
65

0 commit comments

Comments
 (0)