Added EsLint
diff --git a/xos/core/xoslib/ngXosLib/README.md b/xos/core/xoslib/ngXosLib/README.md
index f35c2c3..0166efd 100644
--- a/xos/core/xoslib/ngXosLib/README.md
+++ b/xos/core/xoslib/ngXosLib/README.md
@@ -85,6 +85,10 @@
The `npm start` command is watching your dependencies and will automatically inject it in your `index.html`.
+#### Linting
+
+A styleguide is enforced trough [EsLint](http://eslint.org/) and is checked during the build process. We **highly** suggest to install the linter in your editor to have realtime hint.
+
#### Test
The generator set up a test environment with a default test.
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
index 009550a..b790547 100755
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
@@ -86,6 +86,12 @@
this.destinationPath(`${this.config.get('folder')}/${config.name}/spec/sample.test.js`),
{ name: config.name, user: {email: user.git.email(), firstname: userName[0], lastname: userName[1] } }
);
+ },
+ lint: function(){
+ this.fs.copy(
+ this.templatePath('.eslintrc'),
+ this.destinationPath(`${this.config.get('folder')}/${config.name}/.eslintrc`)
+ );
}
},
install: function(){
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/.eslintrc b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/.eslintrc
new file mode 100644
index 0000000..c852748
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/.eslintrc
@@ -0,0 +1,42 @@
+{
+ "ecmaFeatures": {
+ "blockBindings": true,
+ "forOf": true,
+ "destructuring": true,
+ "arrowFunctions": true,
+ "templateStrings": true
+ },
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "plugins": [
+ //"angular"
+ ],
+ "rules": {
+ "quotes": [2, "single"],
+ "camelcase": [1, {"properties": "always"}],
+ "no-underscore-dangle": 1,
+ "eqeqeq": [2, "smart"],
+ "no-alert": 1,
+ "key-spacing": [1, { "beforeColon": false, "afterColon": true }],
+ "indent": [2, 2],
+ "no-irregular-whitespace": 1,
+ "eol-last": 0,
+ "max-nested-callbacks": [2, 4],
+ "comma-spacing": [1, {"before": false, "after": true}],
+ "no-trailing-spaces": [1, { skipBlankLines: true }],
+ "no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
+ "new-cap": 0,
+
+ //"angular/ng_module_name": [2, '/^xos\.*[a-z]*$/'],
+ //"angular/ng_controller_name": [2, '/^[a-z].*Ctrl$/'],
+ //"angular/ng_service_name": [2, '/^[A-Z].*Service$/'],
+ //"angular/ng_directive_name": [2, '/^[a-z]+[[A-Z].*]*$/'],
+ //"angular/ng_di": [0, "function or array"]
+ },
+ "globals" :{
+ "angular": true
+ }
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
index 983a531..679ae1c 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
@@ -1,11 +1,11 @@
'use strict';
// BUILD
-//
+//
// The only purpose of this gulpfile is to build a XOS view and copy the correct files into
// .html => dashboards
// .js (minified and concat) => static/js
-//
+//
// The template are parsed and added to js with angular $templateCache
var gulp = require('gulp');
@@ -13,13 +13,12 @@
var uglify = require('gulp-uglify');
var templateCache = require('gulp-angular-templatecache');
var runSequence = require('run-sequence');
-var minifyHtml = require("gulp-minify-html");
-var concat = require("gulp-concat");
+var concat = require('gulp-concat');
var del = require('del');
var wiredep = require('wiredep');
-var babel = require('gulp-babel');
var angularFilesort = require('gulp-angular-filesort');
var _ = require('lodash');
+var eslint = require('gulp-eslint');
module.exports = function(options){
@@ -42,7 +41,7 @@
// set templates in cache
gulp.task('templates', function(){
- return gulp.src("./src/templates/*.html")
+ return gulp.src('./src/templates/*.html')
.pipe(templateCache({
module: 'xos.<%= name %>',
root: 'templates/'
@@ -53,7 +52,7 @@
// copy js output to Django Folder
gulp.task('copyJs', function(){
return gulp.src('dist/xos<%= fileName %>.js')
- .pipe(gulp.dest(options.static + 'js/'))
+ .pipe(gulp.dest(options.static + 'js/'));
});
// copy vendor js output to Django Folder
@@ -65,7 +64,7 @@
// copy html index to Django Folder
gulp.task('copyHtml', function(){
return gulp.src(options.src + 'xos<%= fileName %>.html')
- .pipe(gulp.dest(options.dashboards))
+ .pipe(gulp.dest(options.dashboards));
});
// minify vendor js files
@@ -86,11 +85,12 @@
.pipe(gulp.dest(options.dist));
});
- // TODO vendor
- // - define a list of common components (eg: angular, angular-route, ...)
- // - find the difference between local components e common components
- // - minify only the local
- // - unify wiredep, filter and copyVendor task
+ gulp.task('lint', function () {
+ return gulp.src(['src/js/**/*.js'])
+ .pipe(eslint())
+ .pipe(eslint.format())
+ .pipe(eslint.failAfterError());
+ });
gulp.task('build', function() {
runSequence(
@@ -105,4 +105,4 @@
'cleanTmp'
);
});
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
index 039dc7a..0988978 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/server.js
@@ -70,7 +70,7 @@
});
// inject scripts
- gulp.task('inject', ['cleanTmp', 'babel'],function(){
+ gulp.task('inject', ['cleanTmp', 'babel'], function(){
return gulp.src(options.src + 'index.html')
.pipe(
inject(
@@ -110,4 +110,4 @@
['browser']
);
});
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
index 95a95e0..c4c5abb 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
@@ -7,7 +7,8 @@
"start": "gulp serve",
"prebuild": "npm install && bower install",
"build": "gulp",
- "test": "karma start"
+ "test": "karma start",
+ "lint": "eslint src/js/"
},
"keywords": [
"XOS",
@@ -34,6 +35,9 @@
"wiredep": "^3.0.0-beta",
"wrench": "^1.5.8",
"gulp-ng-annotate": "^1.1.0",
- "lodash": "^3.10.1"
+ "lodash": "^3.10.1",
+ "eslint": "^1.8.0",
+ "eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
+ "gulp-eslint": "^1.0.0"
}
}
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
index 8f06c3b..ae7f956 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
@@ -1,10 +1,3 @@
-/* global angular */
-/* eslint-disable dot-location*/
-
-// TODO
-// - Add Cache
-// - Refactor routing with ui.router and child views (share the navigation and header)
-
'use strict';
angular.module('xos.<%= name %>', [
@@ -18,7 +11,7 @@
$routeProvider
.when('/', {
- template: '<users-list></users-list>',
+ template: '<users-list></users-list>'
})
.otherwise('/');
})
diff --git a/xos/core/xoslib/ngXosLib/package.json b/xos/core/xoslib/ngXosLib/package.json
index 045699c..16a4150 100644
--- a/xos/core/xoslib/ngXosLib/package.json
+++ b/xos/core/xoslib/ngXosLib/package.json
@@ -15,6 +15,8 @@
"bluebird": "^3.0.5",
"chalk": "^1.1.1",
"concat": "^1.0.0",
+ "eslint": "^1.8.0",
+ "eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
"fetch-swagger-schema": "^0.1.2",
"jsdoc": "^3.3.3",
"swagger-js-codegen": "^1.1.5"
diff --git a/xos/core/xoslib/.eslintrc b/xos/core/xoslib/static/js/.eslintrc
similarity index 87%
rename from xos/core/xoslib/.eslintrc
rename to xos/core/xoslib/static/js/.eslintrc
index 5c8b35d..7cbab96 100644
--- a/xos/core/xoslib/.eslintrc
+++ b/xos/core/xoslib/static/js/.eslintrc
@@ -14,7 +14,7 @@
"afterColon": true
}],
"valid-jsdoc": 2,
- "max-len": [1, 120, 4, {"ignoreComments": true, "ignoreUrls": true}],
+ "max-len": [1, 120, 4],
brace-style: [2, "stroustrup"],
space-before-blocks: [1, 'never']
},